Exemple #1
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (Validation())
     {
         try
         {
             dataAcess.BeginTransaction();
             VM.DeleteVoucharDetailByMasterId(this.VoucherMasterId, dataAcess);
             VM.UpdateVoucharMaster(this.VoucherMasterId, Convert.ToDateTime(dtpVoucher.Value), this.VoucherType, "H", txtNaration.Text, Convert.ToDecimal(txtTotalDebit.Text), Convert.ToDecimal(txtTotalCredit.Text), MainForm.User_Id, DateTime.Now, "", dataAcess);
             foreach (DataRow dr in dsMain.Tables["VoucherDetail"].Rows)
             {
                 if (dr.RowState != DataRowState.Deleted)
                 {
                     VM.InsertVoucherDetail(VoucherMasterId, "", "", Convert.ToInt32(dr["COAId"]), dr["AccountCode"].ToString(), dr["FlagDC"].ToString(), Convert.ToDecimal(dr["Amount"]), dr["Remarks"].ToString(), dataAcess);
                 }
             }
             manageBank.InsertUpdateBankVoucherDetail(BankVoucherDetailId, dtpVoucher.Value, string.Empty, string.Empty, -1, -1, (string.IsNullOrEmpty(txtChequeAmount.Text) ? 0 : Convert.ToDecimal(txtChequeAmount.Text)), dtpCheque.Value, (cmbChequeBank.SelectedIndex > 0 ? Convert.ToInt32(cmbChequeBank.SelectedValue) : -1), txtChequeNumber.Text, ((this.VoucherType == "BR") ? "Receipt" : "Payment"), VoucherMasterId, this.VoucherType, txtBillNo.Text, dtpBillDate.Value, dataAcess);
             dataAcess.TransCommit();
             MessageBox.Show("Voucher Update Successfull", "Record Updated.", MessageBoxButtons.OK, MessageBoxIcon.Information);
             ClearFeilds();
         }
         catch (SqlException sqlex)
         {
             dataAcess.TransRollback();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             dataAcess.ConnectionClose();
         }
     }
 }
Exemple #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (Validation())
            {
                try
                {
                    int CashCOAId, VendorCOAId = -1;
                    VendorCOAId = manageAccount.GetCOAIdByCode(txtAccCode.Text); // yeh Creadit hoga yani "C"
                    CashCOAId   = manageAccount.GetCOAIdByCode(txtCashAcc.Text); //yeh Debit hoga yani "D"

                    if (VendorCOAId <= 0 || CashCOAId <= 0)
                    {
                        MessageBox.Show("Error While Save Cash Payment. Account Code or Cash Account is missing", "Account Missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (VendorCOAId == CashCOAId)
                    {
                        MessageBox.Show("Account Code and Cash Account should not be Same.", "Same Account Restriction", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    dataAcess.BeginTransaction();
                    if (dataAcess.getDBCommand().Transaction == null)
                    {
                        dataAcess.SetDBTransaction();
                    }

                    VM.DeleteVoucharDetailByMasterId(this.VoucherMasterId, dataAcess);
                    VM.UpdateVoucharMaster(this.VoucherMasterId, Convert.ToDateTime(dtpVoucher.Value), "CP", "K", txtNaration.Text, Convert.ToDecimal(txtAmount.Text), Convert.ToDecimal(txtAmount.Text), MainForm.User_Id, DateTime.Now.Date, "", dataAcess);

                    VM.InsertVoucherDetail(this.VoucherMasterId, "", "", VendorCOAId, txtAccCode.Text, "C", Convert.ToDecimal(txtAmount.Text), txtRemarks.Text, dataAcess);
                    VM.InsertVoucherDetail(this.VoucherMasterId, "", "", CashCOAId, txtCashAcc.Text, "D", Convert.ToDecimal(txtAmount.Text), txtRemarks.Text, dataAcess);

                    //int VendorId = Vendor.GetVendorIdByCode(txtVendorCode.Text);
                    //int VendorLedgerId = Convert.ToInt32(Vendor.GetVendorLedgerByCashPayment(txtCashPaymentCode.Text).Rows[0]["LedgerId"]);
                    //Vendor.UpdateVendorLedger(VendorLedgerId, VendorId, Convert.ToDateTime(dtpVoucher.Value), "", -1, 0, txtCashPaymentCode.Text, this.VoucherMasterId, Convert.ToDecimal(txtAmount.Text), dataAcess);
                    dataAcess.TransCommit();
                    MessageBox.Show("Cash Payment Record Update Successfull.", "Record Updated.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //if (VoucherMasterId > 0)
                    //{
                    //    LoadVoucher(VoucherMasterId);
                    //}
                    ClearFeilds();
                }
                catch (SqlException sqlex)
                {
                    dataAcess.TransRollback();
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    dataAcess.ConnectionClose();
                }
            }
        }
    private void btnUpdate_Click(object sender, EventArgs e)
    {
        if (Validation())
        {
            try
            {
                int BankCOAId, VendorCOAId = -1;
                VendorCOAId = manageAccount.GetCOAIdByCode(txtAccCode.Text); // yeh Debit hoga yani "C"
                BankCOAId   = manageAccount.GetCOAIdByCode(txtBankAcc.Text); //yeh Credit hoga yani "D"

                if (VendorCOAId <= 0 || BankCOAId <= 0)
                {
                    MessageBox.Show("Error While Save Bank Payment. Vendor Account or Bank Account is missing", "Account Missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (VendorCOAId == BankCOAId)
                {
                    MessageBox.Show("Vendor Account and Bank Account should not be Same.", "Same Account Restriction", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                dataAcess.BeginTransaction();
                if (dataAcess.getDBCommand().Transaction == null)
                {
                    dataAcess.SetDBTransaction();
                }

                VM.DeleteVoucharDetailByMasterId(this.VoucherMasterId, dataAcess);
                VM.UpdateVoucharMaster(this.VoucherMasterId, Convert.ToDateTime(dtpVoucher.Value), "BP", "H", txtNaration.Text, Convert.ToDecimal(txtAmount.Text), Convert.ToDecimal(txtAmount.Text), MainForm.User_Id, DateTime.Now.Date, "", dataAcess);
                VM.InsertVoucherDetail(this.VoucherMasterId, "", txtVendorCode.Text, VendorCOAId, txtAccCode.Text, "C", Convert.ToDecimal(txtAmount.Text), "", dataAcess);
                VM.InsertVoucherDetail(this.VoucherMasterId, "", "", BankCOAId, txtBankAcc.Text, "D", Convert.ToDecimal(txtAmount.Text), "", dataAcess);
                manageBank.InsertUpdateBankVoucherDetail(BankVoucherDetailId, dtpVoucher.Value, txtVendorCode.Text, string.Empty, BankId, BankACId, Convert.ToDecimal(txtAmount.Text), dtpCheque.Value, (cmbChequeBank.SelectedIndex > 0 ? Convert.ToInt32(cmbChequeBank.SelectedValue) : -1), txtChequeNumber.Text, "Payment", VoucherMasterId, "BP", "", DateTime.Now, dataAcess);
                dataAcess.TransCommit();
                MessageBox.Show("Bank Payment Updated Successfull", "Record Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearFeilds();
            }
            catch (SqlException sqlex)
            {
                dataAcess.TransRollback();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                dataAcess.ConnectionClose();
            }
        }
    }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (Validation())
            {
                try
                {
                    int CashCOAId, CustomerCOAId = -1;
                    CustomerCOAId = manageAccount.GetCOAIdByCode(txtAccCode.Text); // yeh Debit hoga yani "D"
                    CashCOAId     = manageAccount.GetCOAIdByCode(txtCashAcc.Text); //yeh Credit hoga yani "C"

                    if (CustomerCOAId <= 0 || CashCOAId <= 0)
                    {
                        MessageBox.Show("Error While Save Cash Receipt. Customer Account or Cash Account is missing", "Account Missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (CustomerCOAId == CashCOAId)
                    {
                        MessageBox.Show("Account Code and Cash Account should not be Same.", "Same Account Restriction", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    dataAcess.BeginTransaction();
                    if (dataAcess.getDBCommand().Transaction == null)
                    {
                        dataAcess.SetDBTransaction();
                    }

                    VM.DeleteVoucharDetailByMasterId(this.VoucherMasterId, dataAcess);
                    VM.UpdateVoucharMaster(this.VoucherMasterId, Convert.ToDateTime(dtpVoucher.Value), "CR", "K", txtNaration.Text, Convert.ToDecimal(txtAmount.Text), Convert.ToDecimal(txtAmount.Text), MainForm.User_Id, DateTime.Now.Date, "", dataAcess);
                    VM.InsertVoucherDetail(this.VoucherMasterId, "", "", CustomerCOAId, txtAccCode.Text, "D", Convert.ToDecimal(txtAmount.Text), txtRemarks.Text, dataAcess);
                    VM.InsertVoucherDetail(this.VoucherMasterId, "", "", CashCOAId, txtCashAcc.Text, "C", Convert.ToDecimal(txtAmount.Text), txtRemarks.Text, dataAcess);
                    dataAcess.TransCommit();
                    MessageBox.Show("Cash Receipt Updated Successfull", "Record Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearFeilds();
                }
                catch (SqlException sqlex)
                {
                    dataAcess.TransRollback();
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    dataAcess.ConnectionClose();
                }
            }
        }