private void PrepareEditView() { CMConsultantAssignedWorkAreaEntity cMConsultantAssignedWorkAreaEntity = CurrentCMConsultantAssignedWorkAreaEntity; if (!cMConsultantAssignedWorkAreaEntity.IsNew) { if (ddlProjectID.Items.Count > 0 && cMConsultantAssignedWorkAreaEntity.ProjectID != null) { ddlProjectID.SelectedValue = cMConsultantAssignedWorkAreaEntity.ProjectID.ToString(); } if (ddlConsultantWorkAreaID.Items.Count > 0 && cMConsultantAssignedWorkAreaEntity.ConsultantWorkAreaID != null) { ddlConsultantWorkAreaID.SelectedValue = cMConsultantAssignedWorkAreaEntity.ConsultantWorkAreaID.ToString(); } if (ddlWorkAreaStatusID.Items.Count > 0 && cMConsultantAssignedWorkAreaEntity.WorkAreaStatusID != null) { ddlWorkAreaStatusID.SelectedValue = cMConsultantAssignedWorkAreaEntity.WorkAreaStatusID.ToString(); } txtStartDate.Text = cMConsultantAssignedWorkAreaEntity.StartDate.ToStringDefault(); txtEndDate.Text = cMConsultantAssignedWorkAreaEntity.EndDate.ToStringDefault(); txtActualStartDate.Text = cMConsultantAssignedWorkAreaEntity.ActualStartDate.ToStringDefault(); txtActualEndDate.Text = cMConsultantAssignedWorkAreaEntity.ActualEndDate.ToStringDefault(); txtRemarks.Text = cMConsultantAssignedWorkAreaEntity.Remarks.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
Int64 ICMConsultantAssignedWorkAreaDataAccess.Add(CMConsultantAssignedWorkAreaEntity cMConsultantAssignedWorkAreaEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(cMConsultantAssignedWorkAreaEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(cMConsultantAssignedWorkAreaEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private Int64 UpdateTran(CMConsultantAssignedWorkAreaEntity cMConsultantAssignedWorkAreaEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMConsultantAssignedWorkArea_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, "@ConsultantAssignedWorkAreaID", DbType.Int64, cMConsultantAssignedWorkAreaEntity.ConsultantAssignedWorkAreaID); db.AddInParameter(cmd, "@ConsultantID", DbType.Int64, cMConsultantAssignedWorkAreaEntity.ConsultantID); db.AddInParameter(cmd, "@ProjectID", DbType.Int64, cMConsultantAssignedWorkAreaEntity.ProjectID); db.AddInParameter(cmd, "@ConsultantWorkAreaID", DbType.Int64, cMConsultantAssignedWorkAreaEntity.ConsultantWorkAreaID); db.AddInParameter(cmd, "@WorkAreaStatusID", DbType.Int64, cMConsultantAssignedWorkAreaEntity.WorkAreaStatusID); db.AddInParameter(cmd, "@StartDate", DbType.DateTime, cMConsultantAssignedWorkAreaEntity.StartDate); db.AddInParameter(cmd, "@EndDate", DbType.DateTime, cMConsultantAssignedWorkAreaEntity.EndDate); db.AddInParameter(cmd, "@ActualStartDate", DbType.DateTime, cMConsultantAssignedWorkAreaEntity.ActualStartDate); db.AddInParameter(cmd, "@ActualEndDate", DbType.DateTime, cMConsultantAssignedWorkAreaEntity.ActualEndDate); db.AddInParameter(cmd, "@Remarks", DbType.String, cMConsultantAssignedWorkAreaEntity.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 SaveCMConsultantAssignedWorkAreaEntity() { if (IsValid) { try { CMConsultantAssignedWorkAreaEntity cMConsultantAssignedWorkAreaEntity = BuildCMConsultantAssignedWorkAreaEntity(); Int64 result = -1; if (cMConsultantAssignedWorkAreaEntity.IsNew) { result = FCCCMConsultantAssignedWorkArea.GetFacadeCreate().Add(cMConsultantAssignedWorkAreaEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CMConsultantAssignedWorkAreaEntity.FLD_NAME_ConsultantAssignedWorkAreaID, cMConsultantAssignedWorkAreaEntity.ConsultantAssignedWorkAreaID.ToString(), SQLMatchType.Equal); result = FCCCMConsultantAssignedWorkArea.GetFacadeCreate().Update(cMConsultantAssignedWorkAreaEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _ConsultantAssignedWorkAreaID = 0; _CMConsultantAssignedWorkAreaEntity = new CMConsultantAssignedWorkAreaEntity(); PrepareInitialView(); BindCMConsultantAssignedWorkAreaList(); if (cMConsultantAssignedWorkAreaEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "C MConsultant Assigned Work Area Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "C MConsultant Assigned Work Area Information has been updated successfully.", false); } } else { if (cMConsultantAssignedWorkAreaEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add C MConsultant Assigned Work Area Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update C MConsultant Assigned Work Area Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvCMConsultantAssignedWorkArea_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 ConsultantAssignedWorkAreaID; Int64.TryParse(e.CommandArgument.ToString(), out ConsultantAssignedWorkAreaID); if (ConsultantAssignedWorkAreaID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _ConsultantAssignedWorkAreaID = ConsultantAssignedWorkAreaID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(CMConsultantAssignedWorkAreaEntity.FLD_NAME_ConsultantAssignedWorkAreaID, ConsultantAssignedWorkAreaID.ToString(), SQLMatchType.Equal); CMConsultantAssignedWorkAreaEntity cMConsultantAssignedWorkAreaEntity = new CMConsultantAssignedWorkAreaEntity(); result = FCCCMConsultantAssignedWorkArea.GetFacadeCreate().Delete(cMConsultantAssignedWorkAreaEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _ConsultantAssignedWorkAreaID = 0; _CMConsultantAssignedWorkAreaEntity = new CMConsultantAssignedWorkAreaEntity(); PrepareInitialView(); BindCMConsultantAssignedWorkAreaList(); MiscUtil.ShowMessage(lblMessage, "C MConsultant Assigned Work Area has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete C MConsultant Assigned Work Area.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(CMConsultantAssignedWorkAreaEntity cMConsultantAssignedWorkAreaEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMConsultantAssignedWorkArea_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(CMConsultantAssignedWorkAreaEntity cMConsultantAssignedWorkAreaEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMConsultantAssignedWorkArea_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@ConsultantAssignedWorkAreaID", DbType.Int64, cMConsultantAssignedWorkAreaEntity.ConsultantAssignedWorkAreaID); Database.AddInParameter(cmd, "@ConsultantID", DbType.Int64, cMConsultantAssignedWorkAreaEntity.ConsultantID); Database.AddInParameter(cmd, "@ProjectID", DbType.Int64, cMConsultantAssignedWorkAreaEntity.ProjectID); Database.AddInParameter(cmd, "@ConsultantWorkAreaID", DbType.Int64, cMConsultantAssignedWorkAreaEntity.ConsultantWorkAreaID); Database.AddInParameter(cmd, "@WorkAreaStatusID", DbType.Int64, cMConsultantAssignedWorkAreaEntity.WorkAreaStatusID); Database.AddInParameter(cmd, "@StartDate", DbType.DateTime, cMConsultantAssignedWorkAreaEntity.StartDate); Database.AddInParameter(cmd, "@EndDate", DbType.DateTime, cMConsultantAssignedWorkAreaEntity.EndDate); Database.AddInParameter(cmd, "@ActualStartDate", DbType.DateTime, cMConsultantAssignedWorkAreaEntity.ActualStartDate); Database.AddInParameter(cmd, "@ActualEndDate", DbType.DateTime, cMConsultantAssignedWorkAreaEntity.ActualEndDate); Database.AddInParameter(cmd, "@Remarks", DbType.String, cMConsultantAssignedWorkAreaEntity.Remarks); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("CMConsultantAssignedWorkAreaEntity already exists. Please specify another CMConsultantAssignedWorkAreaEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CMConsultantAssignedWorkAreaEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CMConsultantAssignedWorkAreaEntity already exists. Please specify another CMConsultantAssignedWorkAreaEntity."); } } } } return(returnCode); }
private Int64 Delete(CMConsultantAssignedWorkAreaEntity cMConsultantAssignedWorkAreaEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMConsultantAssignedWorkArea_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("CMConsultantAssignedWorkAreaEntity already exists. Please specify another CMConsultantAssignedWorkAreaEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CMConsultantAssignedWorkAreaEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CMConsultantAssignedWorkAreaEntity already exists. Please specify another CMConsultantAssignedWorkAreaEntity."); } } } } return(returnCode); }
protected void btnAddNew_Click(object sender, EventArgs e) { _ConsultantAssignedWorkAreaID = 0; _CMConsultantAssignedWorkAreaEntity = new CMConsultantAssignedWorkAreaEntity(); PrepareInitialView(); }
private CMConsultantAssignedWorkAreaEntity BuildCMConsultantAssignedWorkAreaEntity() { CMConsultantAssignedWorkAreaEntity cMConsultantAssignedWorkAreaEntity = CurrentCMConsultantAssignedWorkAreaEntity; if (ddlConsultantID.Items.Count > 0) { if (ddlConsultantID.SelectedValue == "0") { } else { cMConsultantAssignedWorkAreaEntity.ConsultantID = Int64.Parse(ddlConsultantID.SelectedValue); } } if (ddlProjectID.Items.Count > 0) { if (ddlProjectID.SelectedValue == "0") { } else { cMConsultantAssignedWorkAreaEntity.ProjectID = Int64.Parse(ddlProjectID.SelectedValue); } } if (ddlConsultantWorkAreaID.Items.Count > 0) { if (ddlConsultantWorkAreaID.SelectedValue == "0") { } else { cMConsultantAssignedWorkAreaEntity.ConsultantWorkAreaID = Int64.Parse(ddlConsultantWorkAreaID.SelectedValue); } } if (ddlWorkAreaStatusID.Items.Count > 0) { if (ddlWorkAreaStatusID.SelectedValue == "0") { } else { cMConsultantAssignedWorkAreaEntity.WorkAreaStatusID = Int64.Parse(ddlWorkAreaStatusID.SelectedValue); } } if (txtStartDate.Text.Trim().IsNotNullOrEmpty()) { cMConsultantAssignedWorkAreaEntity.StartDate = MiscUtil.ParseToDateTime(txtStartDate.Text); } else { cMConsultantAssignedWorkAreaEntity.StartDate = null; } if (txtEndDate.Text.Trim().IsNotNullOrEmpty()) { cMConsultantAssignedWorkAreaEntity.EndDate = MiscUtil.ParseToDateTime(txtEndDate.Text); } else { cMConsultantAssignedWorkAreaEntity.EndDate = null; } if (txtActualStartDate.Text.Trim().IsNotNullOrEmpty()) { cMConsultantAssignedWorkAreaEntity.ActualStartDate = MiscUtil.ParseToDateTime(txtActualStartDate.Text); } else { cMConsultantAssignedWorkAreaEntity.ActualStartDate = null; } if (txtActualEndDate.Text.Trim().IsNotNullOrEmpty()) { cMConsultantAssignedWorkAreaEntity.ActualEndDate = MiscUtil.ParseToDateTime(txtActualEndDate.Text); } else { cMConsultantAssignedWorkAreaEntity.ActualEndDate = null; } cMConsultantAssignedWorkAreaEntity.Remarks = txtRemarks.Text.Trim(); return(cMConsultantAssignedWorkAreaEntity); }
Int64 ICMConsultantAssignedWorkAreaFacade.Delete(CMConsultantAssignedWorkAreaEntity cMConsultantAssignedWorkAreaEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCMConsultantAssignedWorkAreaDataAccess().Delete(cMConsultantAssignedWorkAreaEntity, filterExpression, option, reqTran)); }
Int64 ICMConsultantAssignedWorkAreaFacade.Add(CMConsultantAssignedWorkAreaEntity cMConsultantAssignedWorkAreaEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCMConsultantAssignedWorkAreaDataAccess().Add(cMConsultantAssignedWorkAreaEntity, option, reqTran)); }