Ejemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && comboBox1.Text != "" && dataGridView1[0, 0].Value.ToString() != "")
     {
         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();
         }
         bool success = s.insert(sorder);
         MessageBox.Show("Insertion Succesful", "Insert");
         clear();
     }
     else
     {
         MessageBox.Show("PLEASE FILL ALL TEXT BOXES", "ERROR");
     }
 }