Example #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int c;

            try
            {
                count = 0;
                ado_project ado      = new ado_project();
                string      descripe = "";
                Int64       num      = 0;
                double      value    = 0;

                for (int i = 0; i < dataGridView1.RowCount - 1; i++)
                {
                    c = int.Parse(dataGridView1.Rows[i].Cells[1].Value.ToString());
                    Int64 n = Int64.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString());
                    ado.select_invoice_info(c, ref descripe, ref num, ref value);
                    dataGridView1.Rows[i].Cells[2].Value = descripe;
                    dataGridView1.Rows[i].Cells[3].Value = value;


                    if (num >= n)
                    {
                        double calculate = n * value;
                        dataGridView1.Rows[i].Cells[4].Value = calculate;
                        count += Int64.Parse(dataGridView1.Rows[i].Cells[4].Value.ToString());
                    }


                    else
                    {
                        DialogResult dialogResult = MessageBox.Show("The Amount Not Enough Clik Ok To Remove It ,click No To Edit", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (dialogResult == DialogResult.Yes)
                        {
                            dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);
                        }
                    }
                }
                label9.Text = count.ToString();
            }

            catch
            {
                c = 0;
            }
        }