private void btnReturn_Button_Click(object sender, RoutedEventArgs e)
        {
            // NOTE :- if productcode is blank then no preoduct is selected so cannot be returned
            if (txtProductCode.Text == "")
            {
                // If value is not selected from data grid view then we cannot return it even when return button is clicked
                MessageBox.Show("Please select the product to be returned first.");
                return;
            }
            float updatedQty = float.Parse(txtSoldQty.Text) - float.Parse(txtReturnQty.Text);

            // return quantity constraints
            if (IsTextAllowed(txtReturnQty.Text) && (float.Parse(txtReturnQty.Text) > 0) && (updatedQty) >= 0)
            {
                // increase credit amount then update the quantity if partially returned and remove the row if completely returned
                MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure you want to return these items?", "Return Confirmation", System.Windows.MessageBoxButton.YesNo);
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    int billNo = Int32.Parse(txtSearch.Text);
                    //credit amount = unitcost * returnQty - discount % *(unitcost * returnQty) for that item
                    float discountOnReturnItem = discountPercent * (unitSellingPrice * float.Parse(txtReturnQty.Text));// ie discount % *(unitcost * returnQty) part
                    float creditAmount         = unitSellingPrice * float.Parse(txtReturnQty.Text) - discountOnReturnItem;
                    //String.Format("{0:0.00}", 123.4567);      // "123.46"

                    txtCreditAmount.Text = String.Format("{0:0.00}", creditAmount);

                    //TransactionScope: For transactions, eg all the steps in the transaction should be completed for the transaction to actually happen,
                    //so transaction scope makes sure that either all the steps are carried out or non of it are.
                    using (TransactionScope scope = new TransactionScope())
                    {
                        if (billData.Update(billNo, id, float.Parse(txtReturnQty.Text), creditAmount, discountOnReturnItem))
                        {
                            billData.histInsert(billNo, txtProductCode.Text, float.Parse(txtReturnQty.Text), creditAmount);
                            MessageBox.Show("Product Returned Successfully");
                        }

                        else
                        {
                            MessageBox.Show("Product Could Not Be Returned", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        scope.Complete();
                    }
                }
            }

            else
            {
                MessageBox.Show("Invalid input on return quantity!");
            }
        }
예제 #2
0
 public int Update(Bill obj)
 {
     return(billDAL.Update(obj));
 }
 public void Update(string id, string id_sim, DateTime date_ex, DateTime date_cut, int postage, int fare, bool status)
 {
     bill_dal.setBill(id, id_sim, date_ex, date_cut, postage, fare, status);
     bill_dal.Update();
 }
예제 #4
0
파일: Bill.cs 프로젝트: vibhum21/dotnet2
        public static void Update()
        {
            Bill bill = new Bill(4, DateTime.Parse("3-Oct-15"), 500.0000, 400.0000, 4);

            BillDAL.Update(bill);
        }