james6754 39 Junior Poster

There is no need to do all this, you are opening and closing your connection to the db twice. Instead of this, why dont you store 'isactive' in your table row depending on which button is clicked (submit or reject).

    DataGridItem drow = (DataGridItem)(sender as Control).Parent.Parent;
    RadioButton rbpApprove = (RadioButton)drow.FindControl("rbtnapprove");
    RadioButton rbpReject = (RadioButton)drow.FindControl("rbtnreject");

    SqlCommand cmd;

    string empid = dgi.Cells[0].Text;
    string employeename = dgi.Cells[2].Text;
    string designation = dgi.Cells[3].Text;

    if (rbpApprove.Checked == true)
    {
    cmd = new SqlCommand("insert into [table] values ('" + empid + "','" +     employeename + "','" + designation + "',1)", conn);
    //see here you are inserting a 1 which will be for column 'isactive'
    }
    else if (rbpReject.Checked == true)
    {
    cmd = new SqlCommand("insert into [table] values ('" + empid + "','" + employeename + "','" + designation + "',0)",conn);
    //see here you are inserting a 0 which will be for column 'isactive'
    }

    conn.Open();
    cmd.ExecuteNonQuery();
    conn.Close(); 
    }
james6754 39 Junior Poster

Try running your program with administrative access.

james6754 39 Junior Poster

Yes perfectly fine.

james6754 39 Junior Poster

Hmmm, can you post your sql for updating aswell and does that work? maybe you are providing parameters in the wrong order than you are in the one above. basically your trying to fill the dataset with the wrong order of parameters?

james6754 39 Junior Poster

Ok, at least it has given you something to start with..good luck.

james6754 39 Junior Poster

Hi, from what I can gather, you want to spcify exactly which cell is being changed and then send your value off to wherever from that?

You would be better off using the CurrentDirtyStateChanged event of your DGV.

 private void dataGridView1_CurrentCellDirtyStateChanged(object sender, EventArgs e)
 {
  DataGridViewRow dgrv = dgv.CurrentRow; //get the row clicked
  int row = dgvr.Index;

  int colIndex = dgv.CurrentCell.ColumnIndex;//with row and colIndex, 
  //work out exactly which cell has been clicked.

  //if for instance you want to specify exactly where your comboBox is..
  if(row == 1 && colIndex == 3)
  {
  dgv.CommitEdit(DataGridDataErrorContexts.Commit);//you must commit first

  DataGridViewComboBoxCell cb = (DataGridViewComboBoxCell) dgv.rows[row].Cells[colIndex];

  string value = cb.Value.ToString();//this is your value, do whatever you want with it...
  }
  }

Hope that helps I think that is what you are trying to do? Sorry it is a bit messy.

james6754 39 Junior Poster

So you could raise the CellContentClick event on the DGV..

private void dataGridViewMain_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if(e.ColumnIndex == 2)//2 is whichever column your combobox is
            {
                //do something with value
            }

        }

Is that what you mean or did you want to get the value of the ComboBox??

james6754 39 Junior Poster

you mean like this?

private void btn_MakeFullScreenClick(object sender, EventArgs e)
{
            this.TopMost = true;
            this.FormBorderStyle = FormBorderStyle.None;
            this.WindowState = FormWindowState.Maximized;
}

You will have to have another that makes it return to normal size...

private void button2_Click(object sender, EventArgs e)
        {
            this.TopMost = false;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;//(return to whatever borderstyle you want)
            this.WindowState = FormWindowState.Normal;
        }
james6754 39 Junior Poster

You should add a reference to this namespace also...right click your project, click add reference and find System.Data then click add reference.

Lemorlenny commented: Many thanks this solved!. +0
james6754 39 Junior Poster
string address = "123 w elm"; //so here u would just change to address =                                         /                               //textbox1.Text
         
            string[] myArray = address.Split(' ');

            foreach (var item in myArray)
            {
                label1.Text = myArray[0];
                label2.Text = myArray[1];
                label3.Text = myArray[2];
            }

Something like the above

james6754 39 Junior Poster

And what compiler are you using exactly. I have not long started learning C++, but I did not think variable length arrays were valid C++?

james6754 39 Junior Poster

How about....

string[] romanNumerals = {  //Roman Numerals in Here....    };
int input;

Console.Write("Please enter the number you would like converting to numeral");

input = Convert.ToInt16(Console.ReadLine());

Console.Write(romanNumerals[input]);



What you could also do is put all your roman numerals in to a text file and read each roman numeral in to the array...

anyway think that way may be a bit easier than many many if or switch statements...
james6754 39 Junior Poster

You are trying to hold a number in 'm_CardNumber' that is too large...

use a 'long(int64)' instead, this should solve your problem.

johnt68 commented: Thank you +2
james6754 39 Junior Poster

Can you post your code..

james6754 39 Junior Poster

Hmmm...you are saying

passNameAr[position] == name; //passNameAr EQUALS name.
            seatAr[position] == seat;

what you want is the value of name putting in to passNameAr[position].

passNameAr[position] = name; //passNameAr is equal to the value of name
            seatAr[position] = seat;
james6754 39 Junior Poster

now this is a simple way..there are better ways but hopefully will give you a nice simple understanding...

class Program
    {
        static void Main(string[] args)
        {
            int num1 = 0;
            int num2 = 0;
            int num3 = 0;

            string op1 = null;
            string op2 = null;
            string op3 = null;

int result = 0;//will hold final calculation

            Console.WriteLine("enter first num");
            num1 = Convert.ToInt32(Console.ReadLine());

            Console.Write("enter op you want to perform on number");
            op1 = Console.ReadLine();

            Console.WriteLine("enter second num");
            num2 = Convert.ToInt32(Console.ReadLine());

            Console.Write("enter op you want to perform on number");
            op2 = Console.ReadLine();

            Console.WriteLine("enter third number");
            num3 = Convert.ToInt32(Console.ReadLine());

            Console.Write("enter op you want to perform on number");
            op3 = Console.ReadLine();
        }

now when you type your numbers and operations they will be stored in the variables that are declared at the top of the code....

you can then use your if statements to perform actions on these variables..for example

if (op1 == "-")
            {
                result = num1 - num2;
            }

you could then print the result to the console screen as so...

Console.WriteLine("your result is: {0}",result);

does this help you at all?

james6754 39 Junior Poster

is it required that you use switch statements?

james6754 39 Junior Poster

well you are using "operation1" in a switch statement and the other numbers and operations you enter are not being considered...what are you wanting to achieve with the program?

james6754 39 Junior Poster

Can you give more info about what you are trying to achieve, you are inputting in three numbers, what calculation are you wanting to perform on those numbers?

james6754 39 Junior Poster

1

james6754 39 Junior Poster

Well when you enter command line arguments they are stored in the args array..

static void Main(string[] args) //"someinput" would be stored in here.
        {
            string a=Console.ReadLine(); //this is wrong..Console.ReadLine() reads input from the user when enter is pressed
            Console.WriteLine(a);
            Console.ReadKey();
        }
static void Main(string[] args)
        {
            foreach (string arg in args)
            {
               Console.WriteLine(arg);
             }
        }

You would be better off using a foreach loop to print each argument to the console. The simple loop above will just cycle through each argument you enter.

http://msdn.microsoft.com/en-us/library/ttw7t8t6(v=vs.80).aspx

take a look at that and it explains the foreach loop.

onlinessp commented: Thanks +0
james6754 39 Junior Poster

Well something like this will read a random line...there isnt actually a method to do this...

int totalnumoflines = File.ReadAllLines(@"C:\whatever\whatever\whatever\whatever.txt").Length;
            Random random = new Random();
            int myrandline = random.Next(0, totalnumoflines);
            
            using (StreamReader readme = new StreamReader(@"C:\whatever\whatever\whatever\whatever.txt"))
            {
              
                string randline = null;
                for (int i = 0; i < myrandline; ++i)
                {      
                    randline = readme.ReadLine();
                }
               
                Console.WriteLine("The random line of text is, {0}", randline);
            }
james6754 39 Junior Poster

return a random number..?? in what context do you mean???

to get a random number..use the next method of the random class....

Random myRand = new Random();

MessageBox.Show(myRand.Next(1,100)); //this will return a number between 1 and 100.

is this what you want?
james6754 39 Junior Poster

have you set a breakpoint to see what is happening..you can then step through the code with f11..

something is obviously being run somewhere whenever you load your form...

post more code so we can see what is happening..

james6754 39 Junior Poster

This may sound silly but the program does not have to actually work right?? just show message boxes when you click the buttons??

james6754 39 Junior Poster

OK...yeh thats not a bad assignment...

You need to make a start yourself though...

What code have you got so far?

james6754 39 Junior Poster
Form newForm = new winnerForm();//show if NAUGHTS wins - pass winner and score

newForm.Show();



//call above then output a messagebox from winnerForm

any good?

james6754 39 Junior Poster

Hmmm..just a simple problem here i think...say for instance num2 is returned as 5...

The path to your .jpg file is say "\front5.jpg"...

I believe if you put another two backslashes where i put the stars..you should be good to go...let me know..

int num2 = randomNum(1,6);
dice2PictureBox.Image = Image.FromFile("C:\\dice\\front*****\\****" + num2 + ".jpg");
james6754 39 Junior Poster

.SubString will return the rest of the string from the element you specify onwards...

Example:

string yourstring = "HELLO";

Console.WriteLine(yourstring.SubString(2))

in this case the output on the console would be LLO...

Hope that makes sense?