Int64 IMDFamilyRelationTypeDataAccess.Delete(MDFamilyRelationTypeEntity mDFamilyRelationTypeEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Delete(mDFamilyRelationTypeEntity, filterExpression, option); break; } case TransactionRequired.Yes: { retValues = DeleteTran(mDFamilyRelationTypeEntity, filterExpression, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
Int64 IMDFamilyRelationTypeDataAccess.Add(MDFamilyRelationTypeEntity mDFamilyRelationTypeEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(mDFamilyRelationTypeEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(mDFamilyRelationTypeEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private MDFamilyRelationTypeEntity BuildMDFamilyRelationTypeEntity() { MDFamilyRelationTypeEntity mDFamilyRelationTypeEntity = CurrentMDFamilyRelationTypeEntity; mDFamilyRelationTypeEntity.Name = txtName.Text.Trim(); mDFamilyRelationTypeEntity.Description = txtDescription.Text.Trim(); return(mDFamilyRelationTypeEntity); }
private void SaveMDFamilyRelationTypeEntity() { if (IsValid) { try { MDFamilyRelationTypeEntity mDFamilyRelationTypeEntity = BuildMDFamilyRelationTypeEntity(); Int64 result = -1; if (mDFamilyRelationTypeEntity.IsNew) { result = FCCMDFamilyRelationType.GetFacadeCreate().Add(mDFamilyRelationTypeEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDFamilyRelationTypeEntity.FLD_NAME_FamilyRelationTypeID, mDFamilyRelationTypeEntity.FamilyRelationTypeID.ToString(), SQLMatchType.Equal); result = FCCMDFamilyRelationType.GetFacadeCreate().Update(mDFamilyRelationTypeEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _FamilyRelationTypeID = 0; _MDFamilyRelationTypeEntity = new MDFamilyRelationTypeEntity(); PrepareInitialView(); BindMDFamilyRelationTypeList(); if (mDFamilyRelationTypeEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Family Relation Type Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Family Relation Type Information has been updated successfully.", false); } } else { if (mDFamilyRelationTypeEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Family Relation Type Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Family Relation Type Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private Int64 UpdateTran(MDFamilyRelationTypeEntity mDFamilyRelationTypeEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.MDFamilyRelationType_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, "@FamilyRelationTypeID", DbType.Int64, mDFamilyRelationTypeEntity.FamilyRelationTypeID); db.AddInParameter(cmd, "@Name", DbType.String, mDFamilyRelationTypeEntity.Name); db.AddInParameter(cmd, "@Description", DbType.String, mDFamilyRelationTypeEntity.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); }
protected void lvMDFamilyRelationType_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 FamilyRelationTypeID; Int64.TryParse(e.CommandArgument.ToString(), out FamilyRelationTypeID); if (FamilyRelationTypeID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _FamilyRelationTypeID = FamilyRelationTypeID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(MDFamilyRelationTypeEntity.FLD_NAME_FamilyRelationTypeID, FamilyRelationTypeID.ToString(), SQLMatchType.Equal); MDFamilyRelationTypeEntity mDFamilyRelationTypeEntity = new MDFamilyRelationTypeEntity(); result = FCCMDFamilyRelationType.GetFacadeCreate().Delete(mDFamilyRelationTypeEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _FamilyRelationTypeID = 0; _MDFamilyRelationTypeEntity = new MDFamilyRelationTypeEntity(); PrepareInitialView(); BindMDFamilyRelationTypeList(); MiscUtil.ShowMessage(lblMessage, "Family Relation Type has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Family Relation Type.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private void PrepareEditView() { MDFamilyRelationTypeEntity mDFamilyRelationTypeEntity = CurrentMDFamilyRelationTypeEntity; if (!mDFamilyRelationTypeEntity.IsNew) { txtName.Text = mDFamilyRelationTypeEntity.Name.ToString(); txtDescription.Text = mDFamilyRelationTypeEntity.Description.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private Int64 Update(MDFamilyRelationTypeEntity mDFamilyRelationTypeEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.MDFamilyRelationType_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@FamilyRelationTypeID", DbType.Int64, mDFamilyRelationTypeEntity.FamilyRelationTypeID); Database.AddInParameter(cmd, "@Name", DbType.String, mDFamilyRelationTypeEntity.Name); Database.AddInParameter(cmd, "@Description", DbType.String, mDFamilyRelationTypeEntity.Description); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("MDFamilyRelationTypeEntity already exists. Please specify another MDFamilyRelationTypeEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("MDFamilyRelationTypeEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("MDFamilyRelationTypeEntity already exists. Please specify another MDFamilyRelationTypeEntity."); } } } } return(returnCode); }
Int64 IMDFamilyRelationTypeFacade.Delete(MDFamilyRelationTypeEntity mDFamilyRelationTypeEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateMDFamilyRelationTypeDataAccess().Delete(mDFamilyRelationTypeEntity, filterExpression, option, reqTran)); }
Int64 IMDFamilyRelationTypeFacade.Add(MDFamilyRelationTypeEntity mDFamilyRelationTypeEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateMDFamilyRelationTypeDataAccess().Add(mDFamilyRelationTypeEntity, option, reqTran)); }
protected void btnAddNew_Click(object sender, EventArgs e) { _FamilyRelationTypeID = 0; _MDFamilyRelationTypeEntity = new MDFamilyRelationTypeEntity(); PrepareInitialView(); }