Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if ((MessageBox.Show("Are You Sure to Update the Record", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes))

            {
                purchase s = new TMS.purchase();
                s.sn   = Convert.ToInt32(textBox1.Text);
                s.prty = comboBox1.Text;
                s.dt   = dateTimePicker1.Text;
                s.dsc  = textBox2.Text;
                s.tm   = Convert.ToInt32(textBox3.Text);
                s.typ  = "PURCHASE";
                s.row  = dataGridView1.Rows.Count - 1;
                order[] sorder = new order[100];
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    sorder[i]      = new order();
                    sorder[i].amt  = Convert.ToInt32(dataGridView1[6, i].Value.ToString());
                    sorder[i].no   = s.sn;
                    sorder[i].rate = Convert.ToInt32(dataGridView1[5, i].Value);
                    sorder[i].bag  = Convert.ToInt32(dataGridView1[2, i].Value);
                    sorder[i].kg   = Convert.ToInt32(dataGridView1[4, i].Value);
                    sorder[i].pc   = Convert.ToInt32(dataGridView1[3, i].Value);
                    sorder[i].type = s.typ;
                    sorder[i].code = dataGridView1[0, i].Value.ToString();
                }
                int key = Convert.ToInt32(textBox1.Text);
                s.update(sorder, key);
            }
            clear();
        }