Example #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (button1.Tag == null)
     {
         services.Insert(textBox1.Text, decimal.Parse(txt_fees.Text));
     }
     else
     {
         services.Update(textBox1.Text, int.Parse(button1.Tag.ToString()), decimal.Parse(txt_fees.Text));
     }
     dataGridView1.AutoGenerateColumns = false;
     dataGridView1.DataSource          = services.SelectAll();
     txt_fees.Text = textBox1.Text = "";
     button1.Tag   = null;
 }
Example #2
0
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            int count = 0;

            if (dataGridView1.Rows[e.RowIndex].Cells[9].Value != null)
            {
                count = int.Parse(dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString());
            }
            decimal add = 0;

            if (dataGridView1.Rows[e.RowIndex].Cells["Column11"].Value != null)
            {
                add = decimal.Parse(dataGridView1.Rows[e.RowIndex].Cells["Column11"].Value.ToString());
            }
            decimal ship = 0;

            if (dataGridView1.Rows[e.RowIndex].Cells["Column10"].Value != null)
            {
                ship = decimal.Parse(dataGridView1.Rows[e.RowIndex].Cells["Column10"].Value.ToString());
            }
            decimal price = 0;

            if (dataGridView1.Rows[e.RowIndex].Cells["price"].Value != null)
            {
                price = decimal.Parse(dataGridView1.Rows[e.RowIndex].Cells["price"].Value.ToString());
            }
            if (e.ColumnIndex == 0)
            {
                if (dataGridView1.Rows[e.RowIndex].Cells[9].Value == null)
                {
                    string serviceID = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                    List <usp_SelectAllServicesByID_Result> _services = services.SelectAll(int.Parse(serviceID));
                    dataGridView1.Rows[e.RowIndex].Cells["price"].Value = _services[0].ServicesFees.ToString();
                }
                else
                {
                    string serviceID = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                    List <usp_SelectAllServicesByID_Result> _services = services.SelectAll(int.Parse(serviceID));
                    dataGridView1.Rows[e.RowIndex].Cells["price"].Value = _services[0].ServicesFees.ToString();
                    //decimal price = decimal.Parse(dataGridView1.Rows[e.RowIndex].Cells["price"].Value.ToString());
                    //int count = int.Parse(dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString());
                    txt_total.Text = ((price * count) + add + ship).ToString();
                }
            }
            else if (e.ColumnIndex == 9)
            {
                try
                {
                    txt_total.Text = ((price * count) + add + ship).ToString();
                }
                catch
                { }
            }
            else if (e.ColumnIndex == 10)
            {
                try
                {
                    txt_total.Text = ((price * count) + add + ship).ToString();
                }
                catch
                { }
            }
            else if (e.ColumnIndex == 11)
            {
                try
                {
                    //dataGridView1.Rows[e.RowIndex].Cells["price"].Value = _services[0].ServicesFees.ToString();
                    txt_total.Text = ((price * count) + add + ship).ToString();
                }
                catch
                { }
            }
        }