private void btnSave_Click(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());
            }
        }
 private void Usp_BindMedicalPaymentGrid()
 {
     try
     {
         DataTable dt = new DataTable();
         BLMedicalPayment objBL = new BLMedicalPayment();
         dt = objBL.BindFullGrid();
         if (dt.Rows.Count > 0)
         {
             dgvMedicalPayment.DataSource = dt;
         }
         else
         {
             dgvMedicalPayment.DataSource = null;
         }
         dgvMedicalPayment.Refresh();
         dgvMedicalPayment.Show();
         {
             dgvMedicalPayment.DataSource = dt;
             //dgvMedicalPayment.Columns[0].HeaderCell.Value = "Sale Invoice Number";
             dgvMedicalPayment.Columns[0].Visible = false;
             dgvMedicalPayment.AllowUserToAddRows = false;
             dgvMedicalPayment.AllowUserToDeleteRows = false;
             ////dgvMedicalPayment.Columns[1].HeaderCell.Value = "Total Amount";
             //dgvMedicalPayment.Columns[1].HeaderCell.Value = "Paid Amount";
             ////dgvMedicalPayment.Columns[3].HeaderCell.Value = "Remaining Balance";
             //dgvMedicalPayment.Columns[2].HeaderCell.Value = "Payment Date";
             dgvMedicalPayment.Refresh();
             dgvMedicalPayment.Show();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
Example #3
0
        private void dgvMedicalPayment_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (dgvMedicalPayment.SelectedRows.Count > 0)
                {
                    //cbMedical.Text = Convert.ToString(dgvMedicalPayment.SelectedRows[0].Cells[2].Value);
                    cmbSaleinvoiceno.Text = Convert.ToString(dgvMedicalPayment.SelectedRows[0].Cells[0].Value);
                    txtTotalbalance.Text = Convert.ToString(dgvMedicalPayment.SelectedRows[0].Cells[1].Value);
                    string Totalbalance = txtTotalbalance.Text;
                    BLMedicalPayment objMedicalPayment = new BLMedicalPayment();
                    DataTable dt = objMedicalPayment.GetID(Totalbalance);
                    if (dt.Rows.Count != 0)
                    {
                        lblID.Text = dt.Rows[0]["MedicalPaymentID"].ToString();
                    }

                    txtPaidamount.Text = Convert.ToString(dgvMedicalPayment.SelectedRows[0].Cells[2].Value);
                    txtRemaingbalance.Text = Convert.ToString(dgvMedicalPayment.SelectedRows[0].Cells[3].Value);
                    btnSave.Text = "Update";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }