public static void InsertAllotment(int argCCId, int argFlatId, int argBuyerId, decimal argNetAmt, decimal argPaidAmt, decimal argPenaltyAmt, decimal argBalAmt, DateTime argDate, string argCancelType, string argRemarks, int argBlockId, string argFlatNo, DataTable dtChk, bool argChkSend, string argCCName) { SqlConnection conn = new SqlConnection(); conn = BsfGlobal.OpenCRMDB(); SqlTransaction tran = conn.BeginTransaction(); try { string sSql = "INSERT INTO dbo.AllotmentCancel(CostCentreId,FlatId,BuyerId,NetAmount,PaidAmount,PenaltyAmt,BalanceAmount,CancelDate,AllotType,Remarks) VALUES " + " (" + argCCId + "," + argFlatId + "," + argBuyerId + "," + argNetAmt + "," + argPaidAmt + "," + argPenaltyAmt + "," + argBalAmt + ", " + " '" + string.Format("{0:dd/MMM/yyyy}", Convert.ToDateTime(CommFun.IsNullCheck(argDate, CommFun.datatypes.VarTypeDate))) + "', " + " '" + argCancelType + "','" + argRemarks + "') SELECT SCOPE_IDENTITY();"; SqlCommand cmd = new SqlCommand(sSql, conn, tran); int iCancelId = int.Parse(cmd.ExecuteScalar().ToString()); cmd.Dispose(); sSql = string.Format("Select * from dbo.FlatCarPark Where CostCentreId={0} AND FlatId={1}", argCCId, argFlatId); cmd = new SqlCommand(sSql, conn, tran); DataTable dt = new DataTable(); SqlDataReader dreader = cmd.ExecuteReader(); dt.Load(dreader); dreader.Close(); cmd.Dispose(); for (int i = 0; i <= dt.Rows.Count - 1; i++) { sSql = string.Format("Insert into dbo.CancelledCarPark(CancelId, CostCentreId, FlatId, TypeId, TotalCP) Values({0}, {1}, {2}, {3}, {4})", iCancelId, argCCId, argFlatId, Convert.ToInt32(CommFun.IsNullCheck(dt.Rows[i]["TypeId"], CommFun.datatypes.vartypenumeric)), Convert.ToInt32(CommFun.IsNullCheck(dt.Rows[i]["TotalCP"], CommFun.datatypes.vartypenumeric))); cmd = new SqlCommand(sSql, conn, tran); cmd.ExecuteNonQuery(); cmd.Dispose(); } CRM.BusinessLayer.UnitDirBL.InsertFlatCheckList(dtChk, argFlatId, "C", argChkSend, argCCId, argFlatNo); string sStr = "Flat No-" + argFlatNo + " in " + argCCName + " is Cancelled"; BsfGlobal.InsertAlert("CRM-Flat-Cancel", sStr, argCCId, BsfGlobal.g_sCRMDBName); tran.Commit(); BsfGlobal.InsertLog(DateTime.Now, "Flat-Cancellation-Create", "N", "Flat-Cancellation", iCancelId, argCCId, 0, BsfGlobal.g_sCRMDBName, argFlatNo, BsfGlobal.g_lUserId); } catch (Exception ex) { tran.Rollback(); BsfGlobal.CustomException(ex.Message, ex.StackTrace); } finally { conn.Dispose(); conn.Close(); } }
public static bool InsertCompDetails(string argAlert) { int iIRegId = 0; bool bUpdate; SqlConnection conn = new SqlConnection(); SqlCommand cmd; conn = BsfGlobal.OpenCRMDB(); using (SqlTransaction tran = conn.BeginTransaction()) { string sSql = ""; try { sSql = String.Format("INSERT INTO dbo.Complaint_Entry(CostCentreId,FlatId,LeadId,TenantId,TransDate,NatureId,ExecutiveId,AttDate,Remarks,complaintNo,ChargeType,ExeAttnId,AttnRemarks) Values({0},{1},{2},{3},'{4}', {5},{6},'{7}','{8}','{9}','{10}',{11},'{12}') SELECT SCOPE_IDENTITY()", ComplaintDetBO.CostCentreId, ComplaintDetBO.FlatId, ComplaintDetBO.BuyerId, ComplaintDetBO.TenantId, ComplaintDetBO.TransDate, ComplaintDetBO.NatureId, ComplaintDetBO.ExecutiveId, ComplaintDetBO.AttDate, ComplaintDetBO.Remarks, ComplaintDetBO.complaintNo, ComplaintDetBO.ChargeTYpe, ComplaintDetBO.ExeAttnId, ComplaintDetBO.AttnRemarks); cmd = new SqlCommand(sSql, conn, tran); iIRegId = int.Parse(cmd.ExecuteScalar().ToString()); cmd.Dispose(); tran.Commit(); bUpdate = true; BsfGlobal.InsertLog(DateTime.Now, "Complaint-Entry-Add", "N", "ComplaintEntry", iIRegId, ComplaintDetBO.CostCentreId, 0, BsfGlobal.g_sCRMDBName, ComplaintDetBO.complaintNo, BsfGlobal.g_lUserId); BsfGlobal.InsertAlert("CRM-Complaint-Alert", argAlert, ComplaintDetBO.CostCentreId, BsfGlobal.g_sCRMDBName); } catch (Exception ex) { tran.Rollback(); bUpdate = false; System.Windows.Forms.MessageBox.Show(ex.Message, "PMS", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); BsfGlobal.CustomException(ex.Message, ex.StackTrace); } finally { conn.Close(); conn.Dispose(); } } return(bUpdate); }
private void cmdOK_Click(object sender, EventArgs e) { int iTypeId = 0; if (optStatusType.SelectedIndex == 0) { iTypeId = 18; } else if (optStatusType.SelectedIndex == 1) { iTypeId = 19; } else if (optStatusType.SelectedIndex == 2) { iTypeId = 20; } bool bChange = false; if (Validation() == true) { if (m_lRegTransId == 0) { UpdateRegNo(); } else { if (m_dOldDate != Convert.ToDateTime(dtpDate.Text)) { if (oVType.PeriodWise == true) { if (BsfGlobal.CheckPeriodChange(m_dOldDate, Convert.ToDateTime(dtpDate.Text))) { oVType = new BsfGlobal.VoucherType(); oVType = BsfGlobal.GetVoucherNo(iTypeId, Convert.ToDateTime(dtpDate.Text), 0, 0); txtRefNo.Text = oVType.VoucherNo; bChange = true; } } } } m_oRegister.RegTransId = m_lRegTransId; m_oRegister.RegisterId = Convert.ToInt32(cboReg.EditValue); m_oRegister.RegDate = Convert.ToDateTime(dtpDate.EditValue); m_oRegister.RegNo = txtRefNo.Text; m_oRegister.VendorId = Convert.ToInt32(txtVendorName.Tag); if (optStatusType.SelectedIndex == 0) { m_oRegister.StatusType = "R"; } else if (optStatusType.SelectedIndex == 1) { m_oRegister.StatusType = "S"; } else if (optStatusType.SelectedIndex == 2) { m_oRegister.StatusType = "B"; } m_oRegister.Supply = chkSupply.Checked; m_oRegister.SFDate = Convert.ToDateTime(dtpSFDate.EditValue); m_oRegister.STDate = Convert.ToDateTime(dtpSTDate.EditValue); m_oRegister.SLife = chkSLife.Checked; m_oRegister.SGradeId = Convert.ToInt32(txtSGradeName.Tag); m_oRegister.Contract = chkContract.Checked; m_oRegister.CFDate = Convert.ToDateTime(dtpCFDate.EditValue); m_oRegister.CTDate = Convert.ToDateTime(dtpCTDate.EditValue); m_oRegister.CLife = chkCLife.Checked; m_oRegister.CGradeId = Convert.ToInt32(txtCGradeName.Tag); m_oRegister.Service = chkService.Checked; m_oRegister.HFDate = Convert.ToDateTime(dtpHFDate.EditValue); m_oRegister.HTDate = Convert.ToDateTime(dtpHTDate.EditValue); m_oRegister.HLife = chkHLife.Checked; m_oRegister.HGradeId = Convert.ToInt32(txtHGradeName.Tag); m_oRegister.Remarks = txtRemarks.Text; if (m_lRegTransId == 0) { m_oRegister.InsertRegTrans(m_oRegister, iTypeId); BsfGlobal.UpdateMaxNo(iTypeId, oVType, 0, 0); if (optStatusType.SelectedIndex == 0) { BsfGlobal.InsertAlert("Vendor-Renewal", "" + cboReg.Text + " - Renewed Successfully", 0, BsfGlobal.g_sVendorDBName); } else if (optStatusType.SelectedIndex == 1) { BsfGlobal.InsertAlert("Vendor-BlackList", "" + cboReg.Text + " - Blocked", 0, BsfGlobal.g_sVendorDBName); } else if (optStatusType.SelectedIndex == 2) { BsfGlobal.InsertAlert("Vendor-Suspend", "" + cboReg.Text + " - Suspended", 0, BsfGlobal.g_sVendorDBName); } } else { m_oRegister.UpdateRegTrans(m_oRegister); if (bChange == true) { BsfGlobal.UpdateMaxNo(iTypeId, oVType, 0, 0); } } m_oRegUpdate.UpdateRegistration(Convert.ToInt32(txtVendorName.Tag)); this.Close(); } }
private void cmdOK_Click(object sender, EventArgs e) { bool bChange = false; if (Validation() == true) { if (m_lRegisterId == 0) { UpdateRegNo(); } else { if (m_dOldDate != Convert.ToDateTime(dtpDate.Value)) { if (oVType.PeriodWise == true) { if (BsfGlobal.CheckPeriodChange(m_dOldDate, Convert.ToDateTime(dtpDate.Value))) { oVType = new BsfGlobal.VoucherType(); oVType = BsfGlobal.GetVoucherNo(17, Convert.ToDateTime(dtpDate.Value), 0, 0); txtRegNo.Text = oVType.VoucherNo; bChange = true; } } } } if (CheckRegNo() == true) { m_oRegister.RegisterId = m_lRegisterId; m_oRegister.RegDate = dtpDate.Value; m_oRegister.RegNo = txtRegNo.Text; m_oRegister.VendorId = m_lVendorId; m_oRegister.Supply = chkSupply.Checked; m_oRegister.SFDate = dtpSFDate.Value; m_oRegister.STDate = dtpSTDate.Value; m_oRegister.SLife = chkSLife.Checked; m_oRegister.SGradeId = Convert.ToInt32(txtSGradeName.Tag); m_oRegister.Contract = chkContract.Checked; m_oRegister.CFDate = dtpCFDate.Value; m_oRegister.CTDate = dtpCTDate.Value; m_oRegister.CLife = chkCLife.Checked; m_oRegister.CGradeId = Convert.ToInt32(txtCGradeName.Tag); m_oRegister.Service = chkService.Checked; m_oRegister.HFDate = dtpHFDate.Value; m_oRegister.HTDate = dtpHTDate.Value; m_oRegister.HLife = chkHLife.Checked; m_oRegister.HGradeId = Convert.ToInt32(txtHGradeName.Tag); m_oRegister.Remarks = txtRemarks.Text; if (m_lRegisterId == 0) { m_oRegister.InsertRegistration(m_oRegister); BsfGlobal.UpdateMaxNo(17, oVType, 0, 0); BsfGlobal.InsertAlert("Vendor-Register", "" + txtVendorName.Text + " - Registered Successfully", 0, BsfGlobal.g_sVendorDBName); PopulateData(); MessageBox.Show("Registered Successfully!", "Vendor", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { m_oRegister.UpdateRegistration(m_oRegister); if (bChange == true) { BsfGlobal.UpdateMaxNo(17, oVType, 0, 0); } MessageBox.Show("Registration Updated Successfully!", "Vendor", MessageBoxButtons.OK, MessageBoxIcon.Information); } m_oRegUpdate.UpdateRegistration(m_lVendorId); //this.Close(); } } }