Beispiel #1
0
 private void msbTrans_FA_DLRecieptVoucher_Click(object sender, EventArgs e)
 {
     if (childReceiptVoucher == null || childReceiptVoucher.Text == "")
     {
         childReceiptVoucher           = new ReceiptVoucher();
         childReceiptVoucher.MdiParent = this;
         childReceiptVoucher.Show();
     }
 }
Beispiel #2
0
        private void gvVoucherList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                string strCompCode   = gvVoucherList.Rows[e.RowIndex].Cells["compcode"].Value.ToString();
                string strBranchCode = gvVoucherList.Rows[e.RowIndex].Cells["branchcode"].Value.ToString();
                string strFinYear    = gvVoucherList.Rows[e.RowIndex].Cells["finYear"].Value.ToString();
                string strDocType    = gvVoucherList.Rows[e.RowIndex].Cells["doctype"].Value.ToString();
                string strVoucherId  = gvVoucherList.Rows[e.RowIndex].Cells["VoucherId"].Value.ToString();


                if (gvVoucherList.Rows[e.RowIndex].Cells["Edit"].Value.ToString().Trim() != "")
                {
                    if (e.ColumnIndex == gvVoucherList.Columns["Edit"].Index)
                    {
                        if (gvVoucherList.Rows[e.RowIndex].Cells["AM_ACCOUNT_TYPE_ID"].Value.ToString() == "CASH" && gvVoucherList.Rows[e.RowIndex].Cells["doctype"].Value.ToString() == "CR")
                        {
                            ReceiptVoucher objReceiptVoucher = new ReceiptVoucher(strCompCode, strBranchCode, strFinYear, strDocType, strVoucherId);
                            objReceiptVoucher.objVoucher = this;
                            objReceiptVoucher.ShowDialog();
                        }
                        if (gvVoucherList.Rows[e.RowIndex].Cells["AM_ACCOUNT_TYPE_ID"].Value.ToString() == "CASH" && gvVoucherList.Rows[e.RowIndex].Cells["doctype"].Value.ToString() == "DR")
                        {
                            CashPayment objReceiptVoucher = new CashPayment(strCompCode, strBranchCode, strFinYear, strDocType, strVoucherId);
                            objReceiptVoucher.objVoucher = this;
                            objReceiptVoucher.ShowDialog();
                        }
                        if (gvVoucherList.Rows[e.RowIndex].Cells["AM_ACCOUNT_TYPE_ID"].Value.ToString() == "BANK" && gvVoucherList.Rows[e.RowIndex].Cells["doctype"].Value.ToString() == "CR")
                        {
                            BankRecieptVoucher objReceiptVoucher = new BankRecieptVoucher(strCompCode, strBranchCode, strFinYear, strDocType, strVoucherId);
                            objReceiptVoucher.objVoucher = this;
                            objReceiptVoucher.ShowDialog();
                        }
                        if (gvVoucherList.Rows[e.RowIndex].Cells["AM_ACCOUNT_TYPE_ID"].Value.ToString() == "BANK" && gvVoucherList.Rows[e.RowIndex].Cells["doctype"].Value.ToString() == "DR")
                        {
                            BankPayment objReceiptVoucher = new BankPayment(strCompCode, strBranchCode, strFinYear, strDocType, strVoucherId);
                            objReceiptVoucher.objVoucher = this;
                            objReceiptVoucher.ShowDialog();
                        }
                    }
                }
                if (e.ColumnIndex == gvVoucherList.Columns["Delete"].Index)
                {
                    DialogResult dlgResult = MessageBox.Show("Do you want delete this record?", "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dlgResult == DialogResult.Yes)
                    {
                        try
                        {
                            objInvDB = new InvoiceDB();
                            objSQLdb = new SQLDB();
                            string strSQL = null;
                            if (gvVoucherList.Rows[e.RowIndex].Cells["doctype"].Value.ToString() == "CR")
                            {
                                objInvDB.BeforeUpdatingOutStandingAmt(strCompCode, strBranchCode, strFinYear, "CR", Convert.ToInt32(strVoucherId));


                                strSQL = " DELETE FROM FA_VOUCHER_BILLS WHERE VCB_COMPANY_CODE='" + strCompCode +
                                         "' AND VCB_BRANCH_CODE='" + strBranchCode +
                                         "' AND VCB_FIN_YEAR='" + strFinYear +
                                         "' AND VCB_DOC_TYPE='CR'" +
                                         " AND VCB_VOUCHER_ID='" + strVoucherId +
                                         //"' AND VCB_VOUCHER_DATE='" + dtpVoucherDate.Value.ToString("dd/MMM/yyyy")+
                                         "'";

                                strSQL += " DELETE FROM FA_VOUCHER WHERE VC_COMPANY_CODE='" + strCompCode +
                                          "' AND VC_BRANCH_CODE='" + strBranchCode +
                                          "' AND VC_FIN_YEAR='" + strFinYear +
                                          "' AND VC_DOC_TYPE='CR'" +
                                          " AND VC_VOUCHER_ID='" + strVoucherId + "'";

                                strSQL += " DELETE FROM FA_VOUCHER_OTHERS WHERE VCO_COMPANY_CODE='" + strCompCode +
                                          "' AND VCO_BRANCH_CODE='" + strBranchCode +
                                          "' AND VCO_FIN_YEAR='" + strFinYear +
                                          "' AND VCO_DOC_TYPE='CR'" +
                                          " AND VCO_VOUCHER_ID='" + strVoucherId + "'";
                            }
                            else if (gvVoucherList.Rows[e.RowIndex].Cells["doctype"].Value.ToString() == "DR")
                            {
                                objSQLdb = new SQLDB();
                                strSQL  += " DELETE FROM FA_VOUCHER WHERE VC_COMPANY_CODE='" + strCompCode +
                                           "' AND VC_BRANCH_CODE='" + strBranchCode +
                                           "' AND VC_FIN_YEAR='" + strFinYear +
                                           "' AND VC_DOC_TYPE='DR'" +
                                           " AND VC_VOUCHER_ID='" + strVoucherId + "'";

                                strSQL += " DELETE FROM FA_VOUCHER_OTHERS WHERE VCO_COMPANY_CODE='" + strCompCode +
                                          "' AND VCO_BRANCH_CODE='" + strBranchCode +
                                          "' AND VCO_FIN_YEAR='" + strFinYear +
                                          "' AND VCO_DOC_TYPE='DR'" +
                                          " AND VCO_VOUCHER_ID='" + strVoucherId + "'";
                            }
                            int iRes = objSQLdb.ExecuteSaveData(strSQL);
                            if (iRes > 0)
                            {
                                MessageBox.Show("Selected  Record is Deleted");
                                //btnDisplay_Click(null, null);

                                objSQLdb = new SQLDB();
                                DataTable dt = new DataTable();
                                try
                                {
                                    //string strCmd = "SELECT DISTINCT TOP 100 VCO_COMPANY_CODE,VCO_BRANCH_CODE,VCO_FIN_YEAR,VCO_DOC_TYPE,VCO_VOUCHER_ID,VCO_VOUCHER_DATE,VCO_VOUCHER_NO," +
                                    //    " VC_CASH_BANK_ID,VC_VOUCHER_AMOUNT FROM FA_VOUCHER_OTHERS INNER JOIN FA_VOUCHER ON VC_VOUCHER_ID=VCO_VOUCHER_ID" +
                                    //    " WHERE VCO_COMPANY_CODE ='" + cbCompany.SelectedValue.ToString() + "' AND" +
                                    //    " (VCO_VOUCHER_DATE BETWEEN '" + dtpFromDate.Value.ToString("dd/MMM/yyyy") + "' AND '" + dtpToDate.Value.ToString("dd/MMM/yyyy") + "') " +
                                    //    "ORDER BY VCO_VOUCHER_DATE DESC  ";
                                    objInvDB = new InvoiceDB();

                                    dt = objInvDB.GetVoucherListData(cbCompany.SelectedValue.ToString(), dtpFromDate.Value.ToString("dd/MMM/yyyy"), dtpToDate.Value.ToString("dd/MMM/yyyy"), "0").Tables[0];

                                    FillDataToGrid(dt);
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.ToString());
                                }
                                finally
                                {
                                    dt       = null;
                                    objSQLdb = null;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                        finally
                        {
                        }
                    }
                }
            }
        }