private void PrepareEditView() { CRMSurveyOwnerEntity cRMSurveyOwnerEntity = CurrentCRMSurveyOwnerEntity; if (!cRMSurveyOwnerEntity.IsNew) { if (ddlSurveyOwnerTypeID.Items.Count > 0 && cRMSurveyOwnerEntity.SurveyOwnerTypeID != null) { ddlSurveyOwnerTypeID.SelectedValue = cRMSurveyOwnerEntity.SurveyOwnerTypeID.ToString(); } txtName.Text = cRMSurveyOwnerEntity.Name.ToString(); txtAddressLine1.Text = cRMSurveyOwnerEntity.AddressLine1.ToString(); txtAddressLine2.Text = cRMSurveyOwnerEntity.AddressLine2.ToString(); txtContactNo1.Text = cRMSurveyOwnerEntity.ContactNo1.ToString(); txtContactNo2.Text = cRMSurveyOwnerEntity.ContactNo2.ToString(); txtEmail.Text = cRMSurveyOwnerEntity.Email.ToString(); txtWebLink.Text = cRMSurveyOwnerEntity.WebLink.ToString(); txtRemarks.Text = cRMSurveyOwnerEntity.Remarks.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private CRMSurveyOwnerEntity BuildCRMSurveyOwnerEntity() { CRMSurveyOwnerEntity cRMSurveyOwnerEntity = CurrentCRMSurveyOwnerEntity; if (ddlSurveyOwnerTypeID.Items.Count > 0) { if (ddlSurveyOwnerTypeID.SelectedValue == "0") { } else { cRMSurveyOwnerEntity.SurveyOwnerTypeID = Int64.Parse(ddlSurveyOwnerTypeID.SelectedValue); } } cRMSurveyOwnerEntity.Name = txtName.Text.Trim(); cRMSurveyOwnerEntity.AddressLine1 = txtAddressLine1.Text.Trim(); cRMSurveyOwnerEntity.AddressLine2 = txtAddressLine2.Text.Trim(); cRMSurveyOwnerEntity.ContactNo1 = txtContactNo1.Text.Trim(); cRMSurveyOwnerEntity.ContactNo2 = txtContactNo2.Text.Trim(); cRMSurveyOwnerEntity.Email = txtEmail.Text.Trim(); cRMSurveyOwnerEntity.WebLink = txtWebLink.Text.Trim(); cRMSurveyOwnerEntity.Remarks = txtRemarks.Text.Trim(); return(cRMSurveyOwnerEntity); }
Int64 ICRMSurveyOwnerDataAccess.Add(CRMSurveyOwnerEntity cRMSurveyOwnerEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(cRMSurveyOwnerEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(cRMSurveyOwnerEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private Int64 UpdateTran(CRMSurveyOwnerEntity cRMSurveyOwnerEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CRMSurveyOwner_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, "@SurveyOwnerID", DbType.Int64, cRMSurveyOwnerEntity.SurveyOwnerID); db.AddInParameter(cmd, "@SurveyOwnerTypeID", DbType.Int64, cRMSurveyOwnerEntity.SurveyOwnerTypeID); db.AddInParameter(cmd, "@Name", DbType.String, cRMSurveyOwnerEntity.Name); db.AddInParameter(cmd, "@AddressLine1", DbType.String, cRMSurveyOwnerEntity.AddressLine1); db.AddInParameter(cmd, "@AddressLine2", DbType.String, cRMSurveyOwnerEntity.AddressLine2); db.AddInParameter(cmd, "@ContactNo1", DbType.String, cRMSurveyOwnerEntity.ContactNo1); db.AddInParameter(cmd, "@ContactNo2", DbType.String, cRMSurveyOwnerEntity.ContactNo2); db.AddInParameter(cmd, "@Email", DbType.String, cRMSurveyOwnerEntity.Email); db.AddInParameter(cmd, "@WebLink", DbType.String, cRMSurveyOwnerEntity.WebLink); db.AddInParameter(cmd, "@Remarks", DbType.String, cRMSurveyOwnerEntity.Remarks); 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 void SaveCRMSurveyOwnerEntity() { if (IsValid) { try { CRMSurveyOwnerEntity cRMSurveyOwnerEntity = BuildCRMSurveyOwnerEntity(); Int64 result = -1; if (cRMSurveyOwnerEntity.IsNew) { result = FCCCRMSurveyOwner.GetFacadeCreate().Add(cRMSurveyOwnerEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CRMSurveyOwnerEntity.FLD_NAME_SurveyOwnerID, cRMSurveyOwnerEntity.SurveyOwnerID.ToString(), SQLMatchType.Equal); result = FCCCRMSurveyOwner.GetFacadeCreate().Update(cRMSurveyOwnerEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _SurveyOwnerID = 0; _CRMSurveyOwnerEntity = new CRMSurveyOwnerEntity(); PrepareInitialView(); BindCRMSurveyOwnerList(); if (cRMSurveyOwnerEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "C RMSurvey Owner Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "C RMSurvey Owner Information has been updated successfully.", false); } } else { if (cRMSurveyOwnerEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add C RMSurvey Owner Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update C RMSurvey Owner Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvCRMSurveyOwner_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 SurveyOwnerID; Int64.TryParse(e.CommandArgument.ToString(), out SurveyOwnerID); if (SurveyOwnerID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _SurveyOwnerID = SurveyOwnerID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(CRMSurveyOwnerEntity.FLD_NAME_SurveyOwnerID, SurveyOwnerID.ToString(), SQLMatchType.Equal); CRMSurveyOwnerEntity cRMSurveyOwnerEntity = new CRMSurveyOwnerEntity(); result = FCCCRMSurveyOwner.GetFacadeCreate().Delete(cRMSurveyOwnerEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _SurveyOwnerID = 0; _CRMSurveyOwnerEntity = new CRMSurveyOwnerEntity(); PrepareInitialView(); BindCRMSurveyOwnerList(); MiscUtil.ShowMessage(lblMessage, "C RMSurvey Owner has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete C RMSurvey Owner.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(CRMSurveyOwnerEntity cRMSurveyOwnerEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CRMSurveyOwner_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 Update(CRMSurveyOwnerEntity cRMSurveyOwnerEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CRMSurveyOwner_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@SurveyOwnerID", DbType.Int64, cRMSurveyOwnerEntity.SurveyOwnerID); Database.AddInParameter(cmd, "@SurveyOwnerTypeID", DbType.Int64, cRMSurveyOwnerEntity.SurveyOwnerTypeID); Database.AddInParameter(cmd, "@Name", DbType.String, cRMSurveyOwnerEntity.Name); Database.AddInParameter(cmd, "@AddressLine1", DbType.String, cRMSurveyOwnerEntity.AddressLine1); Database.AddInParameter(cmd, "@AddressLine2", DbType.String, cRMSurveyOwnerEntity.AddressLine2); Database.AddInParameter(cmd, "@ContactNo1", DbType.String, cRMSurveyOwnerEntity.ContactNo1); Database.AddInParameter(cmd, "@ContactNo2", DbType.String, cRMSurveyOwnerEntity.ContactNo2); Database.AddInParameter(cmd, "@Email", DbType.String, cRMSurveyOwnerEntity.Email); Database.AddInParameter(cmd, "@WebLink", DbType.String, cRMSurveyOwnerEntity.WebLink); Database.AddInParameter(cmd, "@Remarks", DbType.String, cRMSurveyOwnerEntity.Remarks); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("CRMSurveyOwnerEntity already exists. Please specify another CRMSurveyOwnerEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CRMSurveyOwnerEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CRMSurveyOwnerEntity already exists. Please specify another CRMSurveyOwnerEntity."); } } } } return(returnCode); }
private Int64 Delete(CRMSurveyOwnerEntity cRMSurveyOwnerEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CRMSurveyOwner_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("CRMSurveyOwnerEntity already exists. Please specify another CRMSurveyOwnerEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CRMSurveyOwnerEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CRMSurveyOwnerEntity already exists. Please specify another CRMSurveyOwnerEntity."); } } } } return(returnCode); }
protected void btnAddNew_Click(object sender, EventArgs e) { _SurveyOwnerID = 0; _CRMSurveyOwnerEntity = new CRMSurveyOwnerEntity(); PrepareInitialView(); }
Int64 ICRMSurveyOwnerFacade.Delete(CRMSurveyOwnerEntity cRMSurveyOwnerEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCRMSurveyOwnerDataAccess().Delete(cRMSurveyOwnerEntity, filterExpression, option, reqTran)); }
Int64 ICRMSurveyOwnerFacade.Add(CRMSurveyOwnerEntity cRMSurveyOwnerEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCRMSurveyOwnerDataAccess().Add(cRMSurveyOwnerEntity, option, reqTran)); }