示例#1
0
        private void btnPay_Click(object sender, EventArgs e)
        {
            if ((numCash.Value == 0 || Convert.ToDouble(lblBalance.Text) > 0) && lblTotalService.Text == "0.00")
            {
                MessageBox.Show("Full payment required when purchasing only products.", "Point of Sale", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else if ((Convert.ToDouble(lblTotalAmount.Text) / 2) < Convert.ToDouble(lblBalance.Text) && lblTotalService.Text != "0.00")
            {
                MessageBox.Show("Partial payment must be at least half.", "Point of Sale", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                //select max+1 from tables where transaction has foreign key

                //assign those keys to a variable
                //insert first to tables where it is foreign key
                //then insert the same key to transaction table
                ContPointOfSale clspos = new ContPointOfSale();
                ContPointOfSale.paid    = Convert.ToDecimal(lblPaid.Text);
                ContPointOfSale.cash    = numCash.Value;
                ContPointOfSale.balance = Convert.ToDecimal(lblBalance.Text);
                ContPointOfSale.change  = Convert.ToDecimal(lblChange.Text);
                if (isOngoing)
                {
                    contPos.UpdateToDb();
                }
                else
                {
                    contPos.SaveToDb();
                }
                this.Close();
            }
        }