Int64 ICRMPaymentScheduleMapDataAccess.Add(CRMPaymentScheduleMapEntity cRMPaymentScheduleMapEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(cRMPaymentScheduleMapEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(cRMPaymentScheduleMapEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private Int64 Update(CRMPaymentScheduleMapEntity cRMPaymentScheduleMapEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CRMPaymentScheduleMap_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@PaymentScheduleMapID", DbType.Int64, cRMPaymentScheduleMapEntity.PaymentScheduleMapID); Database.AddInParameter(cmd, "@LinkPaymentScheduleMapID", DbType.Int64, cRMPaymentScheduleMapEntity.LinkPaymentScheduleMapID); Database.AddInParameter(cmd, "@PaymentScheduleID", DbType.Int64, cRMPaymentScheduleMapEntity.PaymentScheduleID); Database.AddInParameter(cmd, "@InstallmentName", DbType.String, cRMPaymentScheduleMapEntity.InstallmentName); Database.AddInParameter(cmd, "@InstallmentDueDate", DbType.DateTime, cRMPaymentScheduleMapEntity.InstallmentDueDate); Database.AddInParameter(cmd, "@InstallmentDueDateNew", DbType.DateTime, cRMPaymentScheduleMapEntity.InstallmentDueDateNew); Database.AddInParameter(cmd, "@AgreementID", DbType.Int64, cRMPaymentScheduleMapEntity.AgreementID); Database.AddInParameter(cmd, "@AgreementAAmount", DbType.Decimal, cRMPaymentScheduleMapEntity.AgreementAAmount); Database.AddInParameter(cmd, "@AgreementBAmount", DbType.Decimal, cRMPaymentScheduleMapEntity.AgreementBAmount); Database.AddInParameter(cmd, "@AgreementCAmount", DbType.Decimal, cRMPaymentScheduleMapEntity.AgreementCAmount); Database.AddInParameter(cmd, "@AgreementDAmount", DbType.Decimal, cRMPaymentScheduleMapEntity.AgreementDAmount); Database.AddInParameter(cmd, "@AgreementEAmount", DbType.Decimal, cRMPaymentScheduleMapEntity.AgreementEAmount); Database.AddInParameter(cmd, "@PaymentDueDate", DbType.DateTime, cRMPaymentScheduleMapEntity.PaymentDueDate); Database.AddInParameter(cmd, "@FinalPayment", DbType.Boolean, cRMPaymentScheduleMapEntity.FinalPayment); Database.AddInParameter(cmd, "@Revised", DbType.Boolean, cRMPaymentScheduleMapEntity.Revised); Database.AddInParameter(cmd, "@RevisedIP", DbType.String, cRMPaymentScheduleMapEntity.RevisedIP); Database.AddInParameter(cmd, "@LastRevisedByEmployeeID", DbType.Int64, cRMPaymentScheduleMapEntity.LastRevisedByEmployeeID); Database.AddInParameter(cmd, "@LastRevisedDate", DbType.DateTime, cRMPaymentScheduleMapEntity.LastRevisedDate); Database.AddInParameter(cmd, "@Remarks", DbType.String, cRMPaymentScheduleMapEntity.Remarks); Database.AddInParameter(cmd, "@CreateDate", DbType.DateTime, cRMPaymentScheduleMapEntity.CreateDate); Database.AddInParameter(cmd, "@CreateByEmployeeID", DbType.Int64, cRMPaymentScheduleMapEntity.CreateByEmployeeID); Database.AddInParameter(cmd, "@IP", DbType.String, cRMPaymentScheduleMapEntity.IP); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("CRMPaymentScheduleMapEntity already exists. Please specify another CRMPaymentScheduleMapEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CRMPaymentScheduleMapEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CRMPaymentScheduleMapEntity already exists. Please specify another CRMPaymentScheduleMapEntity."); } } } } return(returnCode); }
private void SaveCRMPaymentScheduleMapEntity() { if (IsValid) { try { CRMPaymentScheduleMapEntity cRMPaymentScheduleMapEntity = BuildCRMPaymentScheduleMapEntity(); Int64 result = -1; if (cRMPaymentScheduleMapEntity.IsNew) { result = FCCCRMPaymentScheduleMap.GetFacadeCreate().Add(cRMPaymentScheduleMapEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CRMPaymentScheduleMapEntity.FLD_NAME_PaymentScheduleMapID, cRMPaymentScheduleMapEntity.PaymentScheduleMapID.ToString(), SQLMatchType.Equal); result = FCCCRMPaymentScheduleMap.GetFacadeCreate().Update(cRMPaymentScheduleMapEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _PaymentScheduleMapID = 0; _CRMPaymentScheduleMapEntity = new CRMPaymentScheduleMapEntity(); PrepareInitialView(); BindCRMPaymentScheduleMapList(); if (cRMPaymentScheduleMapEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "C RMPayment Schedule Map Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "C RMPayment Schedule Map Information has been updated successfully.", false); } } else { if (cRMPaymentScheduleMapEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add C RMPayment Schedule Map Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update C RMPayment Schedule Map Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private void PrepareEditView() { CRMPaymentScheduleMapEntity cRMPaymentScheduleMapEntity = CurrentCRMPaymentScheduleMapEntity; if (!cRMPaymentScheduleMapEntity.IsNew) { if (ddlLinkPaymentScheduleMapID.Items.Count > 0 && cRMPaymentScheduleMapEntity.LinkPaymentScheduleMapID != null) { ddlLinkPaymentScheduleMapID.SelectedValue = cRMPaymentScheduleMapEntity.LinkPaymentScheduleMapID.ToString(); } if (ddlPaymentScheduleID.Items.Count > 0 && cRMPaymentScheduleMapEntity.PaymentScheduleID != null) { ddlPaymentScheduleID.SelectedValue = cRMPaymentScheduleMapEntity.PaymentScheduleID.ToString(); } txtInstallmentName.Text = cRMPaymentScheduleMapEntity.InstallmentName.ToString(); txtInstallmentDueDate.Text = cRMPaymentScheduleMapEntity.InstallmentDueDate.ToStringDefault(); txtInstallmentDueDateNew.Text = cRMPaymentScheduleMapEntity.InstallmentDueDateNew.ToStringDefault(); if (ddlAgreementID.Items.Count > 0 && cRMPaymentScheduleMapEntity.AgreementID != null) { ddlAgreementID.SelectedValue = cRMPaymentScheduleMapEntity.AgreementID.ToString(); } txtAgreementAAmount.Text = cRMPaymentScheduleMapEntity.AgreementAAmount.ToString(); txtAgreementBAmount.Text = cRMPaymentScheduleMapEntity.AgreementBAmount.ToString(); txtAgreementCAmount.Text = cRMPaymentScheduleMapEntity.AgreementCAmount.ToString(); txtAgreementDAmount.Text = cRMPaymentScheduleMapEntity.AgreementDAmount.ToString(); txtAgreementEAmount.Text = cRMPaymentScheduleMapEntity.AgreementEAmount.ToString(); txtPaymentDueDate.Text = cRMPaymentScheduleMapEntity.PaymentDueDate.ToStringDefault(); chkFinalPayment.Checked = cRMPaymentScheduleMapEntity.FinalPayment; chkRevised.Checked = cRMPaymentScheduleMapEntity.Revised; txtRevisedIP.Text = cRMPaymentScheduleMapEntity.RevisedIP.ToString(); if (ddlLastRevisedByEmployeeID.Items.Count > 0 && cRMPaymentScheduleMapEntity.LastRevisedByEmployeeID != null) { ddlLastRevisedByEmployeeID.SelectedValue = cRMPaymentScheduleMapEntity.LastRevisedByEmployeeID.ToString(); } txtLastRevisedDate.Text = cRMPaymentScheduleMapEntity.LastRevisedDate.ToStringDefault(); txtRemarks.Text = cRMPaymentScheduleMapEntity.Remarks.ToString(); txtCreateDate.Text = cRMPaymentScheduleMapEntity.CreateDate.ToStringDefault(); if (ddlCreateByEmployeeID.Items.Count > 0 && cRMPaymentScheduleMapEntity.CreateByEmployeeID != null) { ddlCreateByEmployeeID.SelectedValue = cRMPaymentScheduleMapEntity.CreateByEmployeeID.ToString(); } txtIP.Text = cRMPaymentScheduleMapEntity.IP.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
protected void lvCRMPaymentScheduleMap_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 PaymentScheduleMapID; Int64.TryParse(e.CommandArgument.ToString(), out PaymentScheduleMapID); if (PaymentScheduleMapID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _PaymentScheduleMapID = PaymentScheduleMapID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(CRMPaymentScheduleMapEntity.FLD_NAME_PaymentScheduleMapID, PaymentScheduleMapID.ToString(), SQLMatchType.Equal); CRMPaymentScheduleMapEntity cRMPaymentScheduleMapEntity = new CRMPaymentScheduleMapEntity(); result = FCCCRMPaymentScheduleMap.GetFacadeCreate().Delete(cRMPaymentScheduleMapEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _PaymentScheduleMapID = 0; _CRMPaymentScheduleMapEntity = new CRMPaymentScheduleMapEntity(); PrepareInitialView(); BindCRMPaymentScheduleMapList(); MiscUtil.ShowMessage(lblMessage, "C RMPayment Schedule Map has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete C RMPayment Schedule Map.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(CRMPaymentScheduleMapEntity cRMPaymentScheduleMapEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CRMPaymentScheduleMap_SET"; Database db = DatabaseFactory.CreateDatabase(); using (DbCommand cmd = db.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd, db); AddFilterExpressionParameter(cmd, filterExpression, db); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { using (IDataReader reader = db.ExecuteReader(cmd, transaction)) { returnCode = GetReturnCodeFromParameter(cmd); } if (returnCode >= 0) { transaction.Commit(); } else { throw new ArgumentException("Error Code." + returnCode.ToString()); } } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { transaction.Dispose(); connection.Close(); connection = null; } } return(returnCode); }
private Int64 Delete(CRMPaymentScheduleMapEntity cRMPaymentScheduleMapEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CRMPaymentScheduleMap_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("CRMPaymentScheduleMapEntity already exists. Please specify another CRMPaymentScheduleMapEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CRMPaymentScheduleMapEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CRMPaymentScheduleMapEntity already exists. Please specify another CRMPaymentScheduleMapEntity."); } } } } return(returnCode); }
protected void btnAddNew_Click(object sender, EventArgs e) { _PaymentScheduleMapID = 0; _CRMPaymentScheduleMapEntity = new CRMPaymentScheduleMapEntity(); PrepareInitialView(); }
private CRMPaymentScheduleMapEntity BuildCRMPaymentScheduleMapEntity() { CRMPaymentScheduleMapEntity cRMPaymentScheduleMapEntity = CurrentCRMPaymentScheduleMapEntity; if (ddlLinkPaymentScheduleMapID.Items.Count > 0) { if (ddlLinkPaymentScheduleMapID.SelectedValue == "0") { cRMPaymentScheduleMapEntity.LinkPaymentScheduleMapID = null; } else { cRMPaymentScheduleMapEntity.LinkPaymentScheduleMapID = Int64.Parse(ddlLinkPaymentScheduleMapID.SelectedValue); } } if (ddlPaymentScheduleID.Items.Count > 0) { if (ddlPaymentScheduleID.SelectedValue == "0") { } else { cRMPaymentScheduleMapEntity.PaymentScheduleID = Int64.Parse(ddlPaymentScheduleID.SelectedValue); } } cRMPaymentScheduleMapEntity.InstallmentName = txtInstallmentName.Text.Trim(); if (txtInstallmentDueDate.Text.Trim().IsNotNullOrEmpty()) { cRMPaymentScheduleMapEntity.InstallmentDueDate = MiscUtil.ParseToDateTime(txtInstallmentDueDate.Text); } if (txtInstallmentDueDateNew.Text.Trim().IsNotNullOrEmpty()) { cRMPaymentScheduleMapEntity.InstallmentDueDateNew = MiscUtil.ParseToDateTime(txtInstallmentDueDateNew.Text); } else { cRMPaymentScheduleMapEntity.InstallmentDueDateNew = null; } if (ddlAgreementID.Items.Count > 0) { if (ddlAgreementID.SelectedValue == "0") { } else { cRMPaymentScheduleMapEntity.AgreementID = Int64.Parse(ddlAgreementID.SelectedValue); } } if (!txtAgreementAAmount.Text.Trim().IsNullOrEmpty()) { cRMPaymentScheduleMapEntity.AgreementAAmount = Decimal.Parse(txtAgreementAAmount.Text.Trim()); } else { cRMPaymentScheduleMapEntity.AgreementAAmount = null; } if (!txtAgreementBAmount.Text.Trim().IsNullOrEmpty()) { cRMPaymentScheduleMapEntity.AgreementBAmount = Decimal.Parse(txtAgreementBAmount.Text.Trim()); } else { cRMPaymentScheduleMapEntity.AgreementBAmount = null; } if (!txtAgreementCAmount.Text.Trim().IsNullOrEmpty()) { cRMPaymentScheduleMapEntity.AgreementCAmount = Decimal.Parse(txtAgreementCAmount.Text.Trim()); } else { cRMPaymentScheduleMapEntity.AgreementCAmount = null; } if (!txtAgreementDAmount.Text.Trim().IsNullOrEmpty()) { cRMPaymentScheduleMapEntity.AgreementDAmount = Decimal.Parse(txtAgreementDAmount.Text.Trim()); } else { cRMPaymentScheduleMapEntity.AgreementDAmount = null; } if (!txtAgreementEAmount.Text.Trim().IsNullOrEmpty()) { cRMPaymentScheduleMapEntity.AgreementEAmount = Decimal.Parse(txtAgreementEAmount.Text.Trim()); } else { cRMPaymentScheduleMapEntity.AgreementEAmount = null; } if (txtPaymentDueDate.Text.Trim().IsNotNullOrEmpty()) { cRMPaymentScheduleMapEntity.PaymentDueDate = MiscUtil.ParseToDateTime(txtPaymentDueDate.Text); } else { cRMPaymentScheduleMapEntity.PaymentDueDate = null; } cRMPaymentScheduleMapEntity.FinalPayment = chkFinalPayment.Checked; cRMPaymentScheduleMapEntity.Revised = chkRevised.Checked; cRMPaymentScheduleMapEntity.RevisedIP = txtRevisedIP.Text.Trim(); if (ddlLastRevisedByEmployeeID.Items.Count > 0) { if (ddlLastRevisedByEmployeeID.SelectedValue == "0") { cRMPaymentScheduleMapEntity.LastRevisedByEmployeeID = null; } else { cRMPaymentScheduleMapEntity.LastRevisedByEmployeeID = Int64.Parse(ddlLastRevisedByEmployeeID.SelectedValue); } } if (txtLastRevisedDate.Text.Trim().IsNotNullOrEmpty()) { cRMPaymentScheduleMapEntity.LastRevisedDate = MiscUtil.ParseToDateTime(txtLastRevisedDate.Text); } cRMPaymentScheduleMapEntity.Remarks = txtRemarks.Text.Trim(); if (txtCreateDate.Text.Trim().IsNotNullOrEmpty()) { cRMPaymentScheduleMapEntity.CreateDate = MiscUtil.ParseToDateTime(txtCreateDate.Text); } if (ddlCreateByEmployeeID.Items.Count > 0) { if (ddlCreateByEmployeeID.SelectedValue == "0") { } else { cRMPaymentScheduleMapEntity.CreateByEmployeeID = Int64.Parse(ddlCreateByEmployeeID.SelectedValue); } } cRMPaymentScheduleMapEntity.IP = txtIP.Text.Trim(); return(cRMPaymentScheduleMapEntity); }
Int64 ICRMPaymentScheduleMapFacade.Delete(CRMPaymentScheduleMapEntity cRMPaymentScheduleMapEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCRMPaymentScheduleMapDataAccess().Delete(cRMPaymentScheduleMapEntity, filterExpression, option, reqTran)); }
Int64 ICRMPaymentScheduleMapFacade.Add(CRMPaymentScheduleMapEntity cRMPaymentScheduleMapEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCRMPaymentScheduleMapDataAccess().Add(cRMPaymentScheduleMapEntity, option, reqTran)); }
private Int64 UpdateTran(CRMPaymentScheduleMapEntity cRMPaymentScheduleMapEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CRMPaymentScheduleMap_SET"; Database db = DatabaseFactory.CreateDatabase(); using (DbCommand cmd = db.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option, db); AddOutputParameter(cmd, db); AddFilterExpressionParameter(cmd, filterExpression, db); db.AddInParameter(cmd, "@PaymentScheduleMapID", DbType.Int64, cRMPaymentScheduleMapEntity.PaymentScheduleMapID); db.AddInParameter(cmd, "@LinkPaymentScheduleMapID", DbType.Int64, cRMPaymentScheduleMapEntity.LinkPaymentScheduleMapID); db.AddInParameter(cmd, "@PaymentScheduleID", DbType.Int64, cRMPaymentScheduleMapEntity.PaymentScheduleID); db.AddInParameter(cmd, "@InstallmentName", DbType.String, cRMPaymentScheduleMapEntity.InstallmentName); db.AddInParameter(cmd, "@InstallmentDueDate", DbType.DateTime, cRMPaymentScheduleMapEntity.InstallmentDueDate); db.AddInParameter(cmd, "@InstallmentDueDateNew", DbType.DateTime, cRMPaymentScheduleMapEntity.InstallmentDueDateNew); db.AddInParameter(cmd, "@AgreementID", DbType.Int64, cRMPaymentScheduleMapEntity.AgreementID); db.AddInParameter(cmd, "@AgreementAAmount", DbType.Decimal, cRMPaymentScheduleMapEntity.AgreementAAmount); db.AddInParameter(cmd, "@AgreementBAmount", DbType.Decimal, cRMPaymentScheduleMapEntity.AgreementBAmount); db.AddInParameter(cmd, "@AgreementCAmount", DbType.Decimal, cRMPaymentScheduleMapEntity.AgreementCAmount); db.AddInParameter(cmd, "@AgreementDAmount", DbType.Decimal, cRMPaymentScheduleMapEntity.AgreementDAmount); db.AddInParameter(cmd, "@AgreementEAmount", DbType.Decimal, cRMPaymentScheduleMapEntity.AgreementEAmount); db.AddInParameter(cmd, "@PaymentDueDate", DbType.DateTime, cRMPaymentScheduleMapEntity.PaymentDueDate); db.AddInParameter(cmd, "@FinalPayment", DbType.Boolean, cRMPaymentScheduleMapEntity.FinalPayment); db.AddInParameter(cmd, "@Revised", DbType.Boolean, cRMPaymentScheduleMapEntity.Revised); db.AddInParameter(cmd, "@RevisedIP", DbType.String, cRMPaymentScheduleMapEntity.RevisedIP); db.AddInParameter(cmd, "@LastRevisedByEmployeeID", DbType.Int64, cRMPaymentScheduleMapEntity.LastRevisedByEmployeeID); db.AddInParameter(cmd, "@LastRevisedDate", DbType.DateTime, cRMPaymentScheduleMapEntity.LastRevisedDate); db.AddInParameter(cmd, "@Remarks", DbType.String, cRMPaymentScheduleMapEntity.Remarks); db.AddInParameter(cmd, "@CreateDate", DbType.DateTime, cRMPaymentScheduleMapEntity.CreateDate); db.AddInParameter(cmd, "@CreateByEmployeeID", DbType.Int64, cRMPaymentScheduleMapEntity.CreateByEmployeeID); db.AddInParameter(cmd, "@IP", DbType.String, cRMPaymentScheduleMapEntity.IP); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { using (IDataReader reader = db.ExecuteReader(cmd, transaction)) { returnCode = GetReturnCodeFromParameter(cmd); } if (returnCode > 0) { transaction.Commit(); } else { throw new ArgumentException("Error Code." + returnCode.ToString()); } } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { transaction.Dispose(); connection.Close(); connection = null; } } return(returnCode); }