public int SaveHeadData() { int iRes = 0; string strSQL = ""; try { if (flagUpdate == false) { GenerateVoucherId(); strSQL = " INSERT INTO FA_VOUCHER_OTHERS(VCO_COMPANY_CODE" + ",VCO_BRANCH_CODE" + ",VCO_FIN_YEAR" + ",VCO_DOC_TYPE" + ",VCO_VOUCHER_ID" + ",VCO_VOUCHER_DATE" + ",VCO_NARRATION_1" + ",VCO_NARRATION_2" + ",VCO_EFFECT_NAME" + ",VCO_VOUCHER_NO" + ",VCO_CREATED_BY" + ",VCO_CREATED_DATE" + ") VALUES('" + CommonData.CompanyCode + "','" + CommonData.BranchCode + "','" + CommonData.FinancialYear + "','CR'" + ",'" + txtVoucherId.Text + "','" + dtpVoucherDate.Value.ToString("dd/MMM/yyyy") + "','" + txtDesc1.Text + "','" + txtDesc2.Text + //"','" + txtVoucherNo.Text + "','" + "','" + CommonData.LogUserId + "',getdate())"; } else { objInvDB = new InvoiceDB(); objInvDB.BeforeUpdatingOutStandingAmt(CommonData.CompanyCode, CommonData.BranchCode, CommonData.FinancialYear, "CR", Convert.ToInt32(txtVoucherId.Text)); strSQL = " DELETE FROM FA_VOUCHER_BILLS WHERE VCB_COMPANY_CODE='" + CommonData.CompanyCode + "' AND VCB_BRANCH_CODE='" + CommonData.BranchCode + "' AND VCB_FIN_YEAR='" + CommonData.FinancialYear + "' AND VCB_DOC_TYPE='CR'" + " AND VCB_VOUCHER_ID='" + txtVoucherId.Text + //"' AND VCB_VOUCHER_DATE='" + dtpVoucherDate.Value.ToString("dd/MMM/yyyy")+ "'"; strSQL += " DELETE FROM FA_VOUCHER WHERE VC_COMPANY_CODE='" + CommonData.CompanyCode + "' AND VC_BRANCH_CODE='" + CommonData.BranchCode + "' AND VC_FIN_YEAR='" + CommonData.FinancialYear + "' AND VC_DOC_TYPE='CR'" + " AND VC_VOUCHER_ID='" + txtVoucherId.Text + "'"; objSQLdb = new SQLDB(); iRes = objSQLdb.ExecuteSaveData(strSQL); strSQL = ""; strSQL = " UPDATE FA_VOUCHER_OTHERS SET VCO_COMPANY_CODE='" + CommonData.CompanyCode + "',VCO_BRANCH_CODE='" + CommonData.BranchCode + "',VCO_FIN_YEAR='" + CommonData.FinancialYear + "',VCO_DOC_TYPE='CR'" + ",VCO_VOUCHER_DATE='" + dtpVoucherDate.Value.ToString("dd/MMM/yyyy") + "',VCO_NARRATION_1='" + txtDesc1.Text + "',VCO_NARRATION_2='" + txtDesc2.Text + "',VCO_EFFECT_NAME='" + //"',VCO_VOUCHER_NO='" + txtVoucherNo.Text + "',VCO_LAST_MODIFIED_BY='" + CommonData.LogUserId + "',VCO_LAST_MODIFIED_DATE=getdate()" + " WHERE VCO_VOUCHER_ID='" + txtVoucherId.Text + "'"; } objSQLdb = new SQLDB(); iRes = objSQLdb.ExecuteSaveData(strSQL); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { } return(iRes); }
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 { } } } } }