Int64 IBDProjectAssignedPersonDataAccess.Add(BDProjectAssignedPersonEntity bDProjectAssignedPersonEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(bDProjectAssignedPersonEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(bDProjectAssignedPersonEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void PrepareEditView() { BDProjectAssignedPersonEntity bDProjectAssignedPersonEntity = CurrentBDProjectAssignedPersonEntity; if (!bDProjectAssignedPersonEntity.IsNew) { if (OverviewProjectID <= 0) { if (ddlProjectID.Items.Count > 0 && bDProjectAssignedPersonEntity.ProjectID != null) { ddlProjectID.SelectedValue = bDProjectAssignedPersonEntity.ProjectID.ToString(); } } if (ddlEmployeeID.Items.Count > 0 && bDProjectAssignedPersonEntity.EmployeeID != null) { ddlEmployeeID.SelectedValue = bDProjectAssignedPersonEntity.EmployeeID.ToString(); } if (ddlProjectAssignedPersonTeamRoleID.Items.Count > 0 && bDProjectAssignedPersonEntity.ProjectAssignedPersonTeamRoleID != null) { ddlProjectAssignedPersonTeamRoleID.SelectedValue = bDProjectAssignedPersonEntity.ProjectAssignedPersonTeamRoleID.ToString(); } txtDescription.Text = bDProjectAssignedPersonEntity.Description.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private Int64 UpdateTran(BDProjectAssignedPersonEntity bDProjectAssignedPersonEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.BDProjectAssignedPerson_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, "@ProjectAssignedPersonID", DbType.Int64, bDProjectAssignedPersonEntity.ProjectAssignedPersonID); db.AddInParameter(cmd, "@ProjectID", DbType.Int64, bDProjectAssignedPersonEntity.ProjectID); db.AddInParameter(cmd, "@EmployeeID", DbType.Int64, bDProjectAssignedPersonEntity.EmployeeID); db.AddInParameter(cmd, "@ProjectAssignedPersonTeamRoleID", DbType.Int64, bDProjectAssignedPersonEntity.ProjectAssignedPersonTeamRoleID); db.AddInParameter(cmd, "@Description", DbType.String, bDProjectAssignedPersonEntity.Description); 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 SaveBDProjectAssignedPersonEntity() { if (IsValid) { try { BDProjectAssignedPersonEntity bDProjectAssignedPersonEntity = BuildBDProjectAssignedPersonEntity(); Int64 result = -1; if (bDProjectAssignedPersonEntity.IsNew) { result = FCCBDProjectAssignedPerson.GetFacadeCreate().Add(bDProjectAssignedPersonEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(BDProjectAssignedPersonEntity.FLD_NAME_ProjectAssignedPersonID, bDProjectAssignedPersonEntity.ProjectAssignedPersonID.ToString(), SQLMatchType.Equal); result = FCCBDProjectAssignedPerson.GetFacadeCreate().Update(bDProjectAssignedPersonEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _ProjectAssignedPersonID = 0; _BDProjectAssignedPersonEntity = new BDProjectAssignedPersonEntity(); PrepareInitialView(); BindBDProjectAssignedPersonList(); if (bDProjectAssignedPersonEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Project Assigned Person Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Project Assigned Person Information has been updated successfully.", false); } } else { if (bDProjectAssignedPersonEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Project Assigned Person Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Project Assigned Person Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvBDProjectAssignedPerson_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 ProjectAssignedPersonID; Int64.TryParse(e.CommandArgument.ToString(), out ProjectAssignedPersonID); if (ProjectAssignedPersonID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _ProjectAssignedPersonID = ProjectAssignedPersonID; PrepareEditView(); } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(BDProjectAssignedPersonEntity.FLD_NAME_ProjectAssignedPersonID, ProjectAssignedPersonID.ToString(), SQLMatchType.Equal); BDProjectAssignedPersonEntity bDProjectAssignedPersonEntity = new BDProjectAssignedPersonEntity(); result = FCCBDProjectAssignedPerson.GetFacadeCreate().Delete(bDProjectAssignedPersonEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _ProjectAssignedPersonID = 0; _BDProjectAssignedPersonEntity = new BDProjectAssignedPersonEntity(); PrepareInitialView(); BindBDProjectAssignedPersonList(); MiscUtil.ShowMessage(lblMessage, "Project Assigned Person has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Project Assigned Person.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 Update(BDProjectAssignedPersonEntity bDProjectAssignedPersonEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.BDProjectAssignedPerson_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@ProjectAssignedPersonID", DbType.Int64, bDProjectAssignedPersonEntity.ProjectAssignedPersonID); Database.AddInParameter(cmd, "@ProjectID", DbType.Int64, bDProjectAssignedPersonEntity.ProjectID); Database.AddInParameter(cmd, "@EmployeeID", DbType.Int64, bDProjectAssignedPersonEntity.EmployeeID); Database.AddInParameter(cmd, "@ProjectAssignedPersonTeamRoleID", DbType.Int64, bDProjectAssignedPersonEntity.ProjectAssignedPersonTeamRoleID); Database.AddInParameter(cmd, "@Description", DbType.String, bDProjectAssignedPersonEntity.Description); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("BDProjectAssignedPersonEntity already exists. Please specify another BDProjectAssignedPersonEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("BDProjectAssignedPersonEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("BDProjectAssignedPersonEntity already exists. Please specify another BDProjectAssignedPersonEntity."); } } } } return(returnCode); }
private BDProjectAssignedPersonEntity BuildBDProjectAssignedPersonEntity() { BDProjectAssignedPersonEntity bDProjectAssignedPersonEntity = CurrentBDProjectAssignedPersonEntity; if (OverviewProjectID > 0) { bDProjectAssignedPersonEntity.ProjectID = this.OverviewProjectID; } else { bDProjectAssignedPersonEntity.ProjectID = Int64.Parse(ddlProjectID.SelectedValue); } if (ddlEmployeeID.Items.Count > 0) { if (ddlEmployeeID.SelectedValue == "0") { } else { bDProjectAssignedPersonEntity.EmployeeID = Int64.Parse(ddlEmployeeID.SelectedValue); } } if (ddlProjectAssignedPersonTeamRoleID.Items.Count > 0) { if (ddlProjectAssignedPersonTeamRoleID.SelectedValue == "0") { } else { bDProjectAssignedPersonEntity.ProjectAssignedPersonTeamRoleID = Int64.Parse(ddlProjectAssignedPersonTeamRoleID.SelectedValue); } } bDProjectAssignedPersonEntity.Description = txtDescription.Text.Trim(); return(bDProjectAssignedPersonEntity); }
Int64 IBDProjectAssignedPersonFacade.Delete(BDProjectAssignedPersonEntity bDProjectAssignedPersonEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateBDProjectAssignedPersonDataAccess().Delete(bDProjectAssignedPersonEntity, filterExpression, option, reqTran)); }
Int64 IBDProjectAssignedPersonFacade.Add(BDProjectAssignedPersonEntity bDProjectAssignedPersonEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateBDProjectAssignedPersonDataAccess().Add(bDProjectAssignedPersonEntity, option, reqTran)); }
protected void btnAddNew_Click(object sender, EventArgs e) { _ProjectAssignedPersonID = 0; _BDProjectAssignedPersonEntity = new BDProjectAssignedPersonEntity(); PrepareInitialView(); }