Int64 IMDReferenceLibraryCategoryDataAccess.Add(MDReferenceLibraryCategoryEntity mDReferenceLibraryCategoryEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(mDReferenceLibraryCategoryEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(mDReferenceLibraryCategoryEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void SaveMDReferenceLibraryCategoryEntity() { if (IsValid) { try { MDReferenceLibraryCategoryEntity mDReferenceLibraryCategoryEntity = BuildMDReferenceLibraryCategoryEntity(); Int64 result = -1; if (mDReferenceLibraryCategoryEntity.IsNew) { result = FCCMDReferenceLibraryCategory.GetFacadeCreate().Add(mDReferenceLibraryCategoryEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDReferenceLibraryCategoryEntity.FLD_NAME_ReferenceLibraryCategoryID, mDReferenceLibraryCategoryEntity.ReferenceLibraryCategoryID.ToString(), SQLMatchType.Equal); result = FCCMDReferenceLibraryCategory.GetFacadeCreate().Update(mDReferenceLibraryCategoryEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _ReferenceLibraryCategoryID = 0; _MDReferenceLibraryCategoryEntity = new MDReferenceLibraryCategoryEntity(); PrepareInitialView(); BindMDReferenceLibraryCategoryList(); if (mDReferenceLibraryCategoryEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Reference Library Category Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Reference Library Category Information has been updated successfully.", false); } } else { if (mDReferenceLibraryCategoryEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Reference Library Category Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Reference Library Category Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private MDReferenceLibraryCategoryEntity BuildMDReferenceLibraryCategoryEntity() { MDReferenceLibraryCategoryEntity mDReferenceLibraryCategoryEntity = CurrentMDReferenceLibraryCategoryEntity; mDReferenceLibraryCategoryEntity.Name = txtName.Text.Trim(); mDReferenceLibraryCategoryEntity.Description = txtDescription.Text.Trim(); mDReferenceLibraryCategoryEntity.IsRemoved = chkIsRemoved.Checked; return mDReferenceLibraryCategoryEntity; }
private Int64 UpdateTran(MDReferenceLibraryCategoryEntity mDReferenceLibraryCategoryEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.MDReferenceLibraryCategory_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, "@ReferenceLibraryCategoryID", DbType.Int64, mDReferenceLibraryCategoryEntity.ReferenceLibraryCategoryID); db.AddInParameter(cmd, "@Name", DbType.String, mDReferenceLibraryCategoryEntity.Name); db.AddInParameter(cmd, "@Description", DbType.String, mDReferenceLibraryCategoryEntity.Description); db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, mDReferenceLibraryCategoryEntity.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); }
protected void lvMDReferenceLibraryCategory_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 ReferenceLibraryCategoryID; Int64.TryParse(e.CommandArgument.ToString(), out ReferenceLibraryCategoryID); if (ReferenceLibraryCategoryID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _ReferenceLibraryCategoryID = ReferenceLibraryCategoryID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(MDReferenceLibraryCategoryEntity.FLD_NAME_ReferenceLibraryCategoryID, ReferenceLibraryCategoryID.ToString(), SQLMatchType.Equal); MDReferenceLibraryCategoryEntity mDReferenceLibraryCategoryEntity = new MDReferenceLibraryCategoryEntity(); result = FCCMDReferenceLibraryCategory.GetFacadeCreate().Delete(mDReferenceLibraryCategoryEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _ReferenceLibraryCategoryID = 0; _MDReferenceLibraryCategoryEntity = new MDReferenceLibraryCategoryEntity(); PrepareInitialView(); BindMDReferenceLibraryCategoryList(); MiscUtil.ShowMessage(lblMessage, "Reference Library Category has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Reference Library Category.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private void PrepareEditView() { MDReferenceLibraryCategoryEntity mDReferenceLibraryCategoryEntity = CurrentMDReferenceLibraryCategoryEntity; if (!mDReferenceLibraryCategoryEntity.IsNew) { txtName.Text = mDReferenceLibraryCategoryEntity.Name.ToString(); txtDescription.Text = mDReferenceLibraryCategoryEntity.Description.ToString(); chkIsRemoved.Checked = mDReferenceLibraryCategoryEntity.IsRemoved; btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private Int64 Update(MDReferenceLibraryCategoryEntity mDReferenceLibraryCategoryEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.MDReferenceLibraryCategory_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@ReferenceLibraryCategoryID", DbType.Int64, mDReferenceLibraryCategoryEntity.ReferenceLibraryCategoryID); Database.AddInParameter(cmd, "@Name", DbType.String, mDReferenceLibraryCategoryEntity.Name); Database.AddInParameter(cmd, "@Description", DbType.String, mDReferenceLibraryCategoryEntity.Description); Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, mDReferenceLibraryCategoryEntity.IsRemoved); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("MDReferenceLibraryCategoryEntity already exists. Please specify another MDReferenceLibraryCategoryEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("MDReferenceLibraryCategoryEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("MDReferenceLibraryCategoryEntity already exists. Please specify another MDReferenceLibraryCategoryEntity."); } } } } return(returnCode); }
protected void btnAddNew_Click(object sender, EventArgs e) { _ReferenceLibraryCategoryID = 0; _MDReferenceLibraryCategoryEntity = new MDReferenceLibraryCategoryEntity(); PrepareInitialView(); }
Int64 IMDReferenceLibraryCategoryFacade.Delete(MDReferenceLibraryCategoryEntity mDReferenceLibraryCategoryEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateMDReferenceLibraryCategoryDataAccess().Delete(mDReferenceLibraryCategoryEntity, filterExpression, option, reqTran)); }
Int64 IMDReferenceLibraryCategoryFacade.Add(MDReferenceLibraryCategoryEntity mDReferenceLibraryCategoryEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateMDReferenceLibraryCategoryDataAccess().Add(mDReferenceLibraryCategoryEntity, option, reqTran)); }