Example #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && comboBox1.Text != "" && dataGridView1[0, 0].Value.ToString() != "")
     {
         sale s = new TMS.sale();
         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  = "SALE";
         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");
     }
 }
Example #2
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))

            {
                sale s = new TMS.sale();
                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  = "SALE";
                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();
        }
Example #3
0
        public void loadrecord(int id)
        {
            dataGridView1.Rows.Clear();
            int  key = id;
            sale s   = new TMS.sale();

            textBox1.Text = id.ToString();
            order[] sorder = s.search(key);
            if (sorder[0] != null)
            {
                comboBox1.Text       = s.prty;
                textBox2.Text        = s.dsc;
                textBox3.Text        = s.tm.ToString();
                dateTimePicker1.Text = s.dt;

                for (int i = 0; i < s.row; i++)
                {
                    dataGridView1.Rows.Add(1);
                    dataGridView1[0, i].Value = sorder[i].code.ToString();
                    dataGridView1[1, i].Value = sorder[i].pname.ToString();
                    dataGridView1[2, i].Value = sorder[i].bag.ToString();
                    dataGridView1[3, i].Value = sorder[i].pc.ToString();
                    dataGridView1[4, i].Value = sorder[i].kg.ToString();
                    dataGridView1[5, i].Value = sorder[i].rate.ToString();
                    dataGridView1[6, i].Value = sorder[i].amt.ToString();
                }
                button2.Show();
                button3.Show();
                button5.Show();
                button1.Hide();
            }
            else
            {
                MessageBox.Show("No Record Found");
            }
        }