예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (varify(0) == true)
            {
                if (SaleBillControl.type == "Add")
                {
                    int sum = 0;
                    for (int i = 0; i < dataGridView1.Rows.Count; ++i)
                    {
                        sum += Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value);
                    }
                    int SaleBillID = sale.InsertBill(dateTimePicker1.Text, Party_CB.Text, sum.ToString());

                    if (SaleBillID > 0)
                    {
                        for (int i = 0; i < dataGridView1.Rows.Count; ++i)
                        {
                            sale.InsertBill(SaleBillID, dataGridView1.Rows[i].Cells[2].Value.ToString(),
                                            Convert.ToInt32(dataGridView1.Rows[i].Cells[3].Value), Convert.ToInt32(dataGridView1.Rows[i].Cells[4].Value),
                                            Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value));
                            it.InsertItem(dataGridView1.Text, dataGridView1.Rows[i].Cells[2].Value.ToString(), Location_CB.Text, "Sale",
                                          Convert.ToInt32(dataGridView1.Rows[i].Cells[3].Value));
                        }
                    }
                    this.Close();
                }
                else if (SaleBillControl.type == "Edit")
                {
                    int sum = 0;
                    for (int i = 0; i < dataGridView1.Rows.Count; ++i)
                    {
                        sum += Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value);
                    }
                    sale.EditBill(eid, dateTimePicker1.Text, Party_CB.Text, sum.ToString());
                    sale.DeleteBill(eid, null);
                    if (eid > 0)
                    {
                        for (int i = 0; i < dataGridView1.Rows.Count; ++i)
                        {
                            sale.InsertBill(eid, dataGridView1.Rows[i].Cells[2].Value.ToString(),
                                            Convert.ToInt32(dataGridView1.Rows[i].Cells[3].Value), Convert.ToInt32(dataGridView1.Rows[i].Cells[4].Value),
                                            Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value));
                        }
                    }
                    this.Close();
                }
            }
        }
예제 #2
0
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 4)
     {
         id    = Convert.ToInt32(dataGridView1.CurrentRow.Cells[1].Value.ToString());
         Party = dataGridView1.CurrentRow.Cells[2].Value.ToString();
         Date  = dataGridView1.CurrentRow.Cells[0].Value.ToString();
         type  = "Edit";
         Add_SaleBill a = new Add_SaleBill();
         a.Text = "Edit";
         a.ShowDialog();
         initialize();
     }
     if (e.ColumnIndex == 5)
     {
         if (DialogResult.Yes == MessageBox.Show("Do You Want Delete ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
         {
             sale.DeleteBill(Convert.ToInt32(dataGridView1.CurrentRow.Cells[1].Value.ToString()));
         }
         initialize();
     }
 }