private MDProjectDocumentCategoryEntity BuildMDProjectDocumentCategoryEntity() { MDProjectDocumentCategoryEntity mDProjectDocumentCategoryEntity = CurrentMDProjectDocumentCategoryEntity; mDProjectDocumentCategoryEntity.Name = txtName.Text.Trim(); if (!txtRequiredStandardTime.Text.Trim().IsNullOrEmpty()) { mDProjectDocumentCategoryEntity.RequiredStandardTime = Int32.Parse(txtRequiredStandardTime.Text.Trim()); } else { mDProjectDocumentCategoryEntity.RequiredStandardTime = null; } if (!txtReminderTime.Text.Trim().IsNullOrEmpty()) { mDProjectDocumentCategoryEntity.ReminderTime = Int32.Parse(txtReminderTime.Text.Trim()); } else { mDProjectDocumentCategoryEntity.ReminderTime = null; } mDProjectDocumentCategoryEntity.IsRemoved = chkIsRemoved.Checked; return(mDProjectDocumentCategoryEntity); }
Int64 IMDProjectDocumentCategoryDataAccess.Add(MDProjectDocumentCategoryEntity mDProjectDocumentCategoryEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(mDProjectDocumentCategoryEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(mDProjectDocumentCategoryEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private Int64 UpdateTran(MDProjectDocumentCategoryEntity mDProjectDocumentCategoryEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.MDProjectDocumentCategory_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, "@ProjectDocumentCategoryID", DbType.Int64, mDProjectDocumentCategoryEntity.ProjectDocumentCategoryID); db.AddInParameter(cmd, "@ParentProjectDocumentCategoryID", DbType.Int64, mDProjectDocumentCategoryEntity.ParentProjectDocumentCategoryID); db.AddInParameter(cmd, "@Name", DbType.String, mDProjectDocumentCategoryEntity.Name); db.AddInParameter(cmd, "@RequiredStandardTime", DbType.Int32, mDProjectDocumentCategoryEntity.RequiredStandardTime); db.AddInParameter(cmd, "@ReminderTime", DbType.Int32, mDProjectDocumentCategoryEntity.ReminderTime); db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, mDProjectDocumentCategoryEntity.IsRemoved); 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 DeleteTran(MDProjectDocumentCategoryEntity mDProjectDocumentCategoryEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.MDProjectDocumentCategory_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 void PrepareEditView() { MDProjectDocumentCategoryEntity mDProjectDocumentCategoryEntity = CurrentMDProjectDocumentCategoryEntity; if (!mDProjectDocumentCategoryEntity.IsNew) { txtName.Text = mDProjectDocumentCategoryEntity.Name.ToString(); txtRequiredStandardTime.Text = mDProjectDocumentCategoryEntity.RequiredStandardTime.ToString(); txtReminderTime.Text = mDProjectDocumentCategoryEntity.ReminderTime.ToString(); chkIsRemoved.Checked = mDProjectDocumentCategoryEntity.IsRemoved; btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private Int64 Update(MDProjectDocumentCategoryEntity mDProjectDocumentCategoryEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.MDProjectDocumentCategory_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@ProjectDocumentCategoryID", DbType.Int64, mDProjectDocumentCategoryEntity.ProjectDocumentCategoryID); Database.AddInParameter(cmd, "@ParentProjectDocumentCategoryID", DbType.Int64, mDProjectDocumentCategoryEntity.ParentProjectDocumentCategoryID); Database.AddInParameter(cmd, "@Name", DbType.String, mDProjectDocumentCategoryEntity.Name); Database.AddInParameter(cmd, "@RequiredStandardTime", DbType.Int32, mDProjectDocumentCategoryEntity.RequiredStandardTime); Database.AddInParameter(cmd, "@ReminderTime", DbType.Int32, mDProjectDocumentCategoryEntity.ReminderTime); Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, mDProjectDocumentCategoryEntity.IsRemoved); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("MDProjectDocumentCategoryEntity already exists. Please specify another MDProjectDocumentCategoryEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("MDProjectDocumentCategoryEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("MDProjectDocumentCategoryEntity already exists. Please specify another MDProjectDocumentCategoryEntity."); } } } } return(returnCode); }
private void DeleteDocumentCategory() { Int64 ProjectDocumentCategoryID; Int64.TryParse(treeProjectDocumentCategory.SelectedValue, out ProjectDocumentCategoryID); if (ProjectDocumentCategoryID > 0) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(MDProjectDocumentCategoryEntity.FLD_NAME_ProjectDocumentCategoryID, ProjectDocumentCategoryID.ToString(), SQLMatchType.Equal); MDProjectDocumentCategoryEntity mDProjectDocumentCategoryEntity = new MDProjectDocumentCategoryEntity(); result = FCCMDProjectDocumentCategory.GetFacadeCreate().Delete(mDProjectDocumentCategoryEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _ProjectDocumentCategoryID = 0; _MDProjectDocumentCategoryEntity = new MDProjectDocumentCategoryEntity(); PrepareInitialView(); LoadTreeView(); MiscUtil.ShowMessage(lblMessage, "Project Document Category has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Project Document Category.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
Int64 IMDProjectDocumentCategoryFacade.Delete(MDProjectDocumentCategoryEntity mDProjectDocumentCategoryEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateMDProjectDocumentCategoryDataAccess().Delete(mDProjectDocumentCategoryEntity, filterExpression, option, reqTran)); }
Int64 IMDProjectDocumentCategoryFacade.Add(MDProjectDocumentCategoryEntity mDProjectDocumentCategoryEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateMDProjectDocumentCategoryDataAccess().Add(mDProjectDocumentCategoryEntity, option, reqTran)); }
protected void btnAddNew_Click(object sender, EventArgs e) { _ProjectDocumentCategoryID = 0; _MDProjectDocumentCategoryEntity = new MDProjectDocumentCategoryEntity(); PrepareInitialView(); }
private void SaveMDProjectDocumentCategoryEntity() { if (IsValid) { try { MDProjectDocumentCategoryEntity mDProjectDocumentCategoryEntity = BuildMDProjectDocumentCategoryEntity(); Int64 result = -1; if (mDProjectDocumentCategoryEntity.IsNew) { if (treeProjectDocumentCategory.SelectedNode != null) { if (treeProjectDocumentCategory.SelectedValue == "0") { mDProjectDocumentCategoryEntity.ParentProjectDocumentCategoryID = null; } else { mDProjectDocumentCategoryEntity.ParentProjectDocumentCategoryID = Int64.Parse(treeProjectDocumentCategory.SelectedValue); } } result = FCCMDProjectDocumentCategory.GetFacadeCreate().Add(mDProjectDocumentCategoryEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDProjectDocumentCategoryEntity.FLD_NAME_ProjectDocumentCategoryID, mDProjectDocumentCategoryEntity.ProjectDocumentCategoryID.ToString(), SQLMatchType.Equal); result = FCCMDProjectDocumentCategory.GetFacadeCreate().Update(mDProjectDocumentCategoryEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _ProjectDocumentCategoryID = 0; _MDProjectDocumentCategoryEntity = new MDProjectDocumentCategoryEntity(); PrepareInitialView(); if (mDProjectDocumentCategoryEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Project Document Category Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Project Document Category Information has been updated successfully.", false); } LoadTreeView(); } else { if (mDProjectDocumentCategoryEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Project Document Category Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Project Document Category Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }