예제 #1
0
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            try
            {
                if (SaveValidate())
                {
                    if (btnSave.Text == "Save_Print")
                    {
                        DataSet ds = obj_SaleTransaction.getData(rst);
                        int count = ds.Tables[0].Rows.Count;
                        int cnt = 0;
                        for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
                        {
                            int SaleTransactionDetailID = 0;
                            int SaleTansactionID = rst;
                            int ProductID = Convert.ToInt32(ds.Tables[0].Rows[i]["ProductID"]);
                            int WarehouseID = Convert.ToInt32(ds.Tables[0].Rows[i]["WarehouseID"]);
                            double Quantity = Convert.ToDouble(ds.Tables[0].Rows[i]["Quantity"]);
                            double SellingPrice = Convert.ToDouble(ds.Tables[0].Rows[i]["SalePrice"]);
                            string IsActive = "Yes";
                            string IsDelete = "No";
                            string Result = obj_SaleTransaction.saveSaleTransaction(SaleTransactionDetailID, SaleTansactionID, ProductID, Quantity, SellingPrice, IsActive, IsDelete,WarehouseID);
                            int ret = obj_SaleTransaction.AddMedicalStock(dtpDate.Text, Quantity, MedID, ProductID);
                            if ((Result == "2" || Result == "1") && (ret == 2))
                            {
                                cnt++;
                            }
                        }
                        if (cnt == count)
                        {
                            DiscountAmount = FinalDiscountAmount;//Convert.ToDouble(txtDiscount.Text);
                            BalanceAmount = Convert.ToDouble(txtBalanceAmount.Text);
                            int UpdatedByUserID = 1;
                            string newResult = obj_SaleTransaction.UpdateBalance(DiscountAmount, BalanceAmount, rst, UpdatedByUserID);
                            if (newResult == "1")
                            {
                                AmountPaid = Convert.ToDouble(txtAmountPaid.Text);
                                string AmountPaidDate = dtpDate.Text;
                                //genrate payment invoice no
                                BLMedicalPayment obj_MedicalPayment = new BLMedicalPayment();
                                DataTable dt = obj_MedicalPayment.getMedicalPaymentID();
                                string MedicalPaymentNo = dt.Rows[0][0].ToString();
                                //end gerate payment Invoice no
                                string Place = cbWarehouse.Text;
                                string ReceivedBy = txtBillGenrateBy.Text;
                                double newBalanceAmount = Convert.ToDouble(txtBalanceAmount.Text);
                                int MedicalResult = obj_SaleTransaction.SaveMedicalShopPayment(rst, AmountPaid, AmountPaidDate, UpdatedByUserID, ReceivedBy, Place, MedicalPaymentNo, newBalanceAmount);
                                if (MedicalResult == 2)
                                {

                                    string res = obj_SaleTransaction.deletetempdata(rst);
                                    MessageBox.Show("Sale Transactin Details Saved Successfully...");
                                    //string res = obj_SaleTransaction.Temp_SaleProduct(rst);
                                    dgvSellTransaction.DataSource = null;
                                    TempRST = rst;
                                    FormSaleTransaction_Print ob = new FormSaleTransaction_Print(rst);
                                    ob.Show();
                                }
                                else
                                {
                                    MessageBox.Show("Payment Not Saved");
                                }
                            }
                            else
                            {
                                MessageBox.Show("Remaining Balance Not Stored");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Some Records Not Saved");

                        }
                        clearAllFields();
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
예제 #2
0
 private void BrnSaveAndPrint_Click(object sender, EventArgs e)
 {
     FormSaleTransaction_Print ob = new FormSaleTransaction_Print(rst);
     ob.Show();
 }