Esempio n. 1
0
 private void Button1_Click(object sender, EventArgs e)
 {
     //writeorder to database and detect quantity from stock...
     if (dataGridView1.Rows.Count > 1)
     {
         orderController.OrderRecord(dataGridView1, int.Parse(BillNumberTextBox.Text), textBox1.Text);
         dataGridView1.Rows.Clear();
         textBox1.Clear();
         BillNumberTextBox.Clear();
         label2.ResetText();
     }
     else
     {
         MessageBox.Show("Empty Cart");
     }
 }
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            MessageBox.Show("");
            string date    = BillIssueDateDateTimePicker.Value.ToString("yyyy-MM-dd");
            bool   isempty = true;

            for (int i = 0; i < BillDataGridView.RowCount - 1; i++)
            {
                for (int j = 0; j < BillDataGridView.ColumnCount; j++)
                {
                    if (j == 6 || j == 9)
                    {
                        continue;
                    }
                    try
                    {
                        if (string.IsNullOrWhiteSpace(BillDataGridView.Rows[i].Cells[j].Value.ToString()) || BillDataGridView.Rows[i].Cells[j].Value == null)
                        {
                            isempty = true;
                            break;
                        }
                        else
                        {
                            isempty = false;
                        }
                    }
                    catch (NullReferenceException) { isempty = true; }
                }
                if (isempty)
                {
                    break;
                }
                if (i == BillDataGridView.RowCount - 1)
                {
                    isempty = false;
                }
            }
            if (string.IsNullOrWhiteSpace(BillNumberTextBox.Text))
            {
                isempty = true;
            }
            if (!isempty)
            {
                if (IsImgUploaded)
                {
                    Button1_Click_1(sender, e);
                    orderController.CompleteOrderRecord(BillDataGridView, BillNumberTextBox.Text, date, dealer.UserId, o1.FileName);
                }
                else
                {
                    Button1_Click_1(sender, e);
                    orderController.CompleteOrderRecord(BillDataGridView, BillNumberTextBox.Text, date, dealer.UserId, string.Empty);
                }
                if (DynamicPanel != null)
                {
                    DynamicPanel.Dispose();
                }

                BillNumberTextBox.Clear();
                BillIssueDateDateTimePicker.ResetText();
                BillDataGridView.Rows.Clear();
            }
            else
            {
                MessageBox.Show("please input complete information");
            }
        }