Int64 ICRMSurveyMasterDataAccess.Add(CRMSurveyMasterEntity cRMSurveyMasterEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(cRMSurveyMasterEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(cRMSurveyMasterEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void SaveCRMSurveyMasterEntity() { if (IsValid) { try { CRMSurveyMasterEntity cRMSurveyMasterEntity = BuildCRMSurveyMasterEntity(); Int64 result = -1; if (cRMSurveyMasterEntity.IsNew) { result = FCCCRMSurveyMaster.GetFacadeCreate().Add(cRMSurveyMasterEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CRMSurveyMasterEntity.FLD_NAME_SurveyMasterID, cRMSurveyMasterEntity.SurveyMasterID.ToString(), SQLMatchType.Equal); result = FCCCRMSurveyMaster.GetFacadeCreate().Update(cRMSurveyMasterEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _SurveyMasterID = 0; _CRMSurveyMasterEntity = new CRMSurveyMasterEntity(); PrepareInitialView(); BindCRMSurveyMasterList(); if (cRMSurveyMasterEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Survey Master Information has been added successfully.", false); String NavigationUrl = UrlHelper.BuildSecureUrl("~/CRM/CRMSurvey.aspx", string.Empty, UrlConstants.OVERVIEW_SURVEY_MASTER_ID, result.ToString()).ToString(); Response.Redirect(NavigationUrl); } else { MiscUtil.ShowMessage(lblMessage, "Survey Master Information has been updated successfully.", false); String NavigationUrl = UrlHelper.BuildSecureUrl("~/CRM/CRMSurvey.aspx", string.Empty, UrlConstants.OVERVIEW_SURVEY_MASTER_ID, result.ToString()).ToString(); Response.Redirect(NavigationUrl); } } else { if (cRMSurveyMasterEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Survey Master Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Survey Master Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private Int64 UpdateTran(CRMSurveyMasterEntity cRMSurveyMasterEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CRMSurveyMaster_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, "@SurveyMasterID", DbType.Int64, cRMSurveyMasterEntity.SurveyMasterID); db.AddInParameter(cmd, "@Title", DbType.String, cRMSurveyMasterEntity.Title); db.AddInParameter(cmd, "@StartDate", DbType.DateTime, cRMSurveyMasterEntity.StartDate); db.AddInParameter(cmd, "@EndDate", DbType.DateTime, cRMSurveyMasterEntity.EndDate); db.AddInParameter(cmd, "@CreateDate", DbType.DateTime, cRMSurveyMasterEntity.CreateDate); db.AddInParameter(cmd, "@CreatedByEmployeeID", DbType.Int64, cRMSurveyMasterEntity.CreateByEmployeeID); 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); }
protected void lvCRMSurveyMaster_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 SurveyMasterID; Int64.TryParse(e.CommandArgument.ToString(), out SurveyMasterID); if (SurveyMasterID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _SurveyMasterID = SurveyMasterID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(CRMSurveyMasterEntity.FLD_NAME_SurveyMasterID, SurveyMasterID.ToString(), SQLMatchType.Equal); CRMSurveyMasterEntity cRMSurveyMasterEntity = new CRMSurveyMasterEntity(); result = FCCCRMSurveyMaster.GetFacadeCreate().Delete(cRMSurveyMasterEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _SurveyMasterID = 0; _CRMSurveyMasterEntity = new CRMSurveyMasterEntity(); PrepareInitialView(); BindCRMSurveyMasterList(); MiscUtil.ShowMessage(lblMessage, "Survey Master has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Survey Master.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private void PrepareEditView() { CRMSurveyMasterEntity cRMSurveyMasterEntity = CurrentCRMSurveyMasterEntity; if (!cRMSurveyMasterEntity.IsNew) { txtTitle.Text = cRMSurveyMasterEntity.Title.ToString(); txtStartDate.Text = cRMSurveyMasterEntity.StartDate.ToStringDefault(); txtEndDate.Text = cRMSurveyMasterEntity.EndDate.ToStringDefault(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private Int64 Update(CRMSurveyMasterEntity cRMSurveyMasterEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CRMSurveyMaster_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@SurveyMasterID", DbType.Int64, cRMSurveyMasterEntity.SurveyMasterID); Database.AddInParameter(cmd, "@Title", DbType.String, cRMSurveyMasterEntity.Title); Database.AddInParameter(cmd, "@StartDate", DbType.DateTime, cRMSurveyMasterEntity.StartDate); Database.AddInParameter(cmd, "@EndDate", DbType.DateTime, cRMSurveyMasterEntity.EndDate); Database.AddInParameter(cmd, "@CreateDate", DbType.DateTime, cRMSurveyMasterEntity.CreateDate); Database.AddInParameter(cmd, "@CreatedByEmployeeID", DbType.Int64, cRMSurveyMasterEntity.CreateByEmployeeID); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("CRMSurveyMasterEntity already exists. Please specify another CRMSurveyMasterEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CRMSurveyMasterEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CRMSurveyMasterEntity already exists. Please specify another CRMSurveyMasterEntity."); } } } } return(returnCode); }
protected void lvCRMServeyMaster_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { ListViewDataItem dataItem = (ListViewDataItem)e.Item; CRMSurveyMasterEntity ent = (CRMSurveyMasterEntity)dataItem.DataItem; HyperLink hypTitle = (HyperLink)e.Item.FindControl("hypTitle"); HyperLink hypSurveyMasterReport = (HyperLink)e.Item.FindControl("hypSurveyMasterReport"); hypTitle.NavigateUrl = UrlHelper.BuildSecureUrl("~/CRM/CRMSurvey.aspx", string.Empty, UrlConstants.OVERVIEW_SURVEY_MASTER_ID, ent.SurveyMasterID.ToString()).ToString(); hypSurveyMasterReport.NavigateUrl = UrlHelper.BuildSecureUrl("~/Reports/ReportViewer.aspx", string.Empty, "do", "SurveyMasterReport", UrlConstants.OVERVIEW_SURVEY_MASTER_ID, ent.SurveyMasterID.ToString()).ToString(); hypSurveyMasterReport.Target = "_blank"; hypTitle.Target = "_blank"; } }
private CRMSurveyMasterEntity BuildCRMSurveyMasterEntity() { CRMSurveyMasterEntity cRMSurveyMasterEntity = CurrentCRMSurveyMasterEntity; cRMSurveyMasterEntity.Title = txtTitle.Text.Trim(); if (txtStartDate.Text.Trim().IsNotNullOrEmpty()) { cRMSurveyMasterEntity.StartDate = MiscUtil.ParseToDateTime(txtStartDate.Text); } if (txtEndDate.Text.Trim().IsNotNullOrEmpty()) { cRMSurveyMasterEntity.EndDate = MiscUtil.ParseToDateTime(txtEndDate.Text); } cRMSurveyMasterEntity.CreateDate = System.DateTime.Now; cRMSurveyMasterEntity.CreateByEmployeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember); return(cRMSurveyMasterEntity); }
protected void btnAddNew_Click(object sender, EventArgs e) { _SurveyMasterID = 0; _CRMSurveyMasterEntity = new CRMSurveyMasterEntity(); PrepareInitialView(); }
Int64 ICRMSurveyMasterFacade.Delete(CRMSurveyMasterEntity cRMSurveyMasterEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCRMSurveyMasterDataAccess().Delete(cRMSurveyMasterEntity, filterExpression, option, reqTran)); }
Int64 ICRMSurveyMasterFacade.Add(CRMSurveyMasterEntity cRMSurveyMasterEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCRMSurveyMasterDataAccess().Add(cRMSurveyMasterEntity, option, reqTran)); }