Int64 IBDProjectCollectedDocumentCategoryInfoDataAccess.Add(BDProjectCollectedDocumentCategoryInfoEntity bDProjectCollectedDocumentCategoryInfoEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(bDProjectCollectedDocumentCategoryInfoEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(bDProjectCollectedDocumentCategoryInfoEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void PrepareEditView() { BDProjectCollectedDocumentCategoryInfoEntity bDProjectCollectedDocumentCategoryInfoEntity = CurrentBDProjectCollectedDocumentCategoryInfoEntity; if (!bDProjectCollectedDocumentCategoryInfoEntity.IsNew) { if (ddlProjectID.Items.Count > 0 && bDProjectCollectedDocumentCategoryInfoEntity.ProjectID != null) { ddlProjectID.SelectedValue = bDProjectCollectedDocumentCategoryInfoEntity.ProjectID.ToString(); } if (ddlProjectDocumentCategoryID.Items.Count > 0 && bDProjectCollectedDocumentCategoryInfoEntity.ProjectDocumentCategoryID != null) { ddlProjectDocumentCategoryID.SelectedValue = bDProjectCollectedDocumentCategoryInfoEntity.ProjectDocumentCategoryID.ToString(); } txtStartDate.Text = bDProjectCollectedDocumentCategoryInfoEntity.StartDate.ToStringDefault(); txtRequiredTime.Text = bDProjectCollectedDocumentCategoryInfoEntity.RequiredTime.ToString(); txtReminder.Text = bDProjectCollectedDocumentCategoryInfoEntity.Reminder.ToString(); if (ddlProjectCollectedDocumentStatusID.Items.Count > 0 && bDProjectCollectedDocumentCategoryInfoEntity.ProjectCollectedDocumentStatusID != null) { ddlProjectCollectedDocumentStatusID.SelectedValue = bDProjectCollectedDocumentCategoryInfoEntity.ProjectCollectedDocumentStatusID.ToString(); } txtRemarks.Text = bDProjectCollectedDocumentCategoryInfoEntity.Remarks.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private Int64 UpdateTran(BDProjectCollectedDocumentCategoryInfoEntity bDProjectCollectedDocumentCategoryInfoEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.BDProjectCollectedDocumentCategoryInfo_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, "@ProjectCollectedDocumentCategoryInfoID", DbType.Int64, bDProjectCollectedDocumentCategoryInfoEntity.ProjectCollectedDocumentCategoryInfoID); db.AddInParameter(cmd, "@ProjectID", DbType.Int64, bDProjectCollectedDocumentCategoryInfoEntity.ProjectID); db.AddInParameter(cmd, "@ProjectDocumentCategoryID", DbType.Int64, bDProjectCollectedDocumentCategoryInfoEntity.ProjectDocumentCategoryID); db.AddInParameter(cmd, "@StartDate", DbType.DateTime, bDProjectCollectedDocumentCategoryInfoEntity.StartDate); db.AddInParameter(cmd, "@RequiredTime", DbType.Int32, bDProjectCollectedDocumentCategoryInfoEntity.RequiredTime); db.AddInParameter(cmd, "@Reminder", DbType.Int32, bDProjectCollectedDocumentCategoryInfoEntity.Reminder); db.AddInParameter(cmd, "@ProjectCollectedDocumentStatusID", DbType.Int64, bDProjectCollectedDocumentCategoryInfoEntity.ProjectCollectedDocumentStatusID); db.AddInParameter(cmd, "@Remarks", DbType.String, bDProjectCollectedDocumentCategoryInfoEntity.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 SaveBDProjectCollectedDocumentCategoryInfoEntity() { if (IsValid) { try { BDProjectCollectedDocumentCategoryInfoEntity bDProjectCollectedDocumentCategoryInfoEntity = BuildBDProjectCollectedDocumentCategoryInfoEntity(); Int64 result = -1; if (bDProjectCollectedDocumentCategoryInfoEntity.IsNew) { result = FCCBDProjectCollectedDocumentCategoryInfo.GetFacadeCreate().Add(bDProjectCollectedDocumentCategoryInfoEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(BDProjectCollectedDocumentCategoryInfoEntity.FLD_NAME_ProjectCollectedDocumentCategoryInfoID, bDProjectCollectedDocumentCategoryInfoEntity.ProjectCollectedDocumentCategoryInfoID.ToString(), SQLMatchType.Equal); result = FCCBDProjectCollectedDocumentCategoryInfo.GetFacadeCreate().Update(bDProjectCollectedDocumentCategoryInfoEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _ProjectCollectedDocumentCategoryInfoID = 0; _BDProjectCollectedDocumentCategoryInfoEntity = new BDProjectCollectedDocumentCategoryInfoEntity(); PrepareInitialView(); BindBDProjectCollectedDocumentCategoryInfoList(); if (bDProjectCollectedDocumentCategoryInfoEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Project Collected Document Category Info Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Project Collected Document Category Info Information has been updated successfully.", false); } } else { if (bDProjectCollectedDocumentCategoryInfoEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Project Collected Document Category Info Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Project Collected Document Category Info Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvBDProjectCollectedDocumentCategoryInfo_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 ProjectCollectedDocumentCategoryInfoID; Int64.TryParse(e.CommandArgument.ToString(), out ProjectCollectedDocumentCategoryInfoID); if (ProjectCollectedDocumentCategoryInfoID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _ProjectCollectedDocumentCategoryInfoID = ProjectCollectedDocumentCategoryInfoID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(BDProjectCollectedDocumentCategoryInfoEntity.FLD_NAME_ProjectCollectedDocumentCategoryInfoID, ProjectCollectedDocumentCategoryInfoID.ToString(), SQLMatchType.Equal); BDProjectCollectedDocumentCategoryInfoEntity bDProjectCollectedDocumentCategoryInfoEntity = new BDProjectCollectedDocumentCategoryInfoEntity(); result = FCCBDProjectCollectedDocumentCategoryInfo.GetFacadeCreate().Delete(bDProjectCollectedDocumentCategoryInfoEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _ProjectCollectedDocumentCategoryInfoID = 0; _BDProjectCollectedDocumentCategoryInfoEntity = new BDProjectCollectedDocumentCategoryInfoEntity(); PrepareInitialView(); BindBDProjectCollectedDocumentCategoryInfoList(); MiscUtil.ShowMessage(lblMessage, "Project Collected Document Category Info has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Project Collected Document Category Info.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 Update(BDProjectCollectedDocumentCategoryInfoEntity bDProjectCollectedDocumentCategoryInfoEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.BDProjectCollectedDocumentCategoryInfo_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@ProjectCollectedDocumentCategoryInfoID", DbType.Int64, bDProjectCollectedDocumentCategoryInfoEntity.ProjectCollectedDocumentCategoryInfoID); Database.AddInParameter(cmd, "@ProjectID", DbType.Int64, bDProjectCollectedDocumentCategoryInfoEntity.ProjectID); Database.AddInParameter(cmd, "@ProjectDocumentCategoryID", DbType.Int64, bDProjectCollectedDocumentCategoryInfoEntity.ProjectDocumentCategoryID); Database.AddInParameter(cmd, "@StartDate", DbType.DateTime, bDProjectCollectedDocumentCategoryInfoEntity.StartDate); Database.AddInParameter(cmd, "@RequiredTime", DbType.Int32, bDProjectCollectedDocumentCategoryInfoEntity.RequiredTime); Database.AddInParameter(cmd, "@Reminder", DbType.Int32, bDProjectCollectedDocumentCategoryInfoEntity.Reminder); Database.AddInParameter(cmd, "@ProjectCollectedDocumentStatusID", DbType.Int64, bDProjectCollectedDocumentCategoryInfoEntity.ProjectCollectedDocumentStatusID); Database.AddInParameter(cmd, "@Remarks", DbType.String, bDProjectCollectedDocumentCategoryInfoEntity.Remarks); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("BDProjectCollectedDocumentCategoryInfoEntity already exists. Please specify another BDProjectCollectedDocumentCategoryInfoEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("BDProjectCollectedDocumentCategoryInfoEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("BDProjectCollectedDocumentCategoryInfoEntity already exists. Please specify another BDProjectCollectedDocumentCategoryInfoEntity."); } } } } return(returnCode); }
Int64 IBDProjectCollectedDocumentCategoryInfoFacade.Delete(BDProjectCollectedDocumentCategoryInfoEntity bDProjectCollectedDocumentCategoryInfoEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateBDProjectCollectedDocumentCategoryInfoDataAccess().Delete(bDProjectCollectedDocumentCategoryInfoEntity, filterExpression, option, reqTran)); }
Int64 IBDProjectCollectedDocumentCategoryInfoFacade.Add(BDProjectCollectedDocumentCategoryInfoEntity bDProjectCollectedDocumentCategoryInfoEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateBDProjectCollectedDocumentCategoryInfoDataAccess().Add(bDProjectCollectedDocumentCategoryInfoEntity, option, reqTran)); }
protected void btnAddNew_Click(object sender, EventArgs e) { _ProjectCollectedDocumentCategoryInfoID = 0; _BDProjectCollectedDocumentCategoryInfoEntity = new BDProjectCollectedDocumentCategoryInfoEntity(); PrepareInitialView(); }
private BDProjectCollectedDocumentCategoryInfoEntity BuildBDProjectCollectedDocumentCategoryInfoEntity() { BDProjectCollectedDocumentCategoryInfoEntity bDProjectCollectedDocumentCategoryInfoEntity = CurrentBDProjectCollectedDocumentCategoryInfoEntity; if (ddlProjectID.Items.Count > 0) { if (ddlProjectID.SelectedValue == "0") { } else { bDProjectCollectedDocumentCategoryInfoEntity.ProjectID = Int64.Parse(ddlProjectID.SelectedValue); } } if (ddlProjectDocumentCategoryID.Items.Count > 0) { if (ddlProjectDocumentCategoryID.SelectedValue == "0") { } else { bDProjectCollectedDocumentCategoryInfoEntity.ProjectDocumentCategoryID = Int64.Parse(ddlProjectDocumentCategoryID.SelectedValue); } } if (txtStartDate.Text.Trim().IsNotNullOrEmpty()) { bDProjectCollectedDocumentCategoryInfoEntity.StartDate = MiscUtil.ParseToDateTime(txtStartDate.Text); } else { bDProjectCollectedDocumentCategoryInfoEntity.StartDate = null; } if (!txtRequiredTime.Text.Trim().IsNullOrEmpty()) { bDProjectCollectedDocumentCategoryInfoEntity.RequiredTime = Int32.Parse(txtRequiredTime.Text.Trim()); } else { bDProjectCollectedDocumentCategoryInfoEntity.RequiredTime = null; } if (!txtReminder.Text.Trim().IsNullOrEmpty()) { bDProjectCollectedDocumentCategoryInfoEntity.Reminder = Int32.Parse(txtReminder.Text.Trim()); } else { bDProjectCollectedDocumentCategoryInfoEntity.Reminder = null; } if (ddlProjectCollectedDocumentStatusID.Items.Count > 0) { if (ddlProjectCollectedDocumentStatusID.SelectedValue == "0") { bDProjectCollectedDocumentCategoryInfoEntity.ProjectCollectedDocumentStatusID = null; } else { bDProjectCollectedDocumentCategoryInfoEntity.ProjectCollectedDocumentStatusID = Int64.Parse(ddlProjectCollectedDocumentStatusID.SelectedValue); } } bDProjectCollectedDocumentCategoryInfoEntity.Remarks = txtRemarks.Text.Trim(); return(bDProjectCollectedDocumentCategoryInfoEntity); }