Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string operation = "Points Added";


            if (txtBillAmount.Text == string.Empty || txtCustomerID.Text == string.Empty || txtReceiptNo.Text == string.Empty)
            {
                MessageBox.Show("ERROR!! One or more Fields is empty");
            }
            else
            {
                if (rd.DuplicateBill(txtReceiptNo.Text.Trim()) == true)
                {
                    MessageBox.Show("SORRY!! This Bill has already been used!");
                }
                else
                {
                    rb.ReceiptNo     = txtReceiptNo.Text.Trim();
                    rb.BillAmount    = double.Parse(txtBillAmount.Text.Trim());
                    cb.Customer_Type = cd.CustomerType(txtCustomerID.Text.Trim(), cb.Customer_Type).ToString();
                    switch (cb.Customer_Type)
                    {
                    case "Retailer":
                        rb.PointsAdded = (double.Parse(txtBillAmount.Text.Trim()) * 0.05);
                        break;

                    case "Wholesaler":
                        rb.PointsAdded = (double.Parse(txtBillAmount.Text.Trim()) * 0.01);
                        break;

                    default:
                        rb.PointsAdded = (double.Parse(txtBillAmount.Text.Trim()) * 0.05);
                        break;
                    }
                    rb.Operation      = operation;
                    rb.PointsRedeemed = 0.00;
                    rb.CustomerID     = txtCustomerID.Text.Trim();
                    rb.date           = DateTime.Now.ToString();

                    if (cd.DuplicateCustomer(cb.CustomerID) == true)
                    {
                        MessageBox.Show("This card has NOT been registered to any Customer. Kindly register it");
                    }

                    else
                    {
                        bool success = rd.Insert(rb);

                        if (success == true)
                        {
                            MessageBox.Show("Points Successfully Added");

                            Clear();
                        }
                        else
                        {
                            MessageBox.Show("Failed adding points");
                            Clear();
                        }
                    }
                }
            }
        }