Int64 IBDProjectParkingDataAccess.Add(BDProjectParkingEntity bDProjectParkingEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(bDProjectParkingEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(bDProjectParkingEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void SaveBDProjectParkingEntity() { if (IsValid) { try { BDProjectParkingEntity bDProjectParkingEntity = BuildBDProjectParkingEntity(); Int64 result = -1; if (bDProjectParkingEntity.IsNew) { result = FCCBDProjectParking.GetFacadeCreate().Add(bDProjectParkingEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(BDProjectParkingEntity.FLD_NAME_ProjectParkingID, bDProjectParkingEntity.ProjectParkingID.ToString(), SQLMatchType.Equal); result = FCCBDProjectParking.GetFacadeCreate().Update(bDProjectParkingEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _ProjectParkingID = 0; _BDProjectParkingEntity = new BDProjectParkingEntity(); PrepareInitialView(); PrepareEditView(); BindBDProjectParkingList(); if (bDProjectParkingEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Project Parking Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Project Parking Information has been updated successfully.", false); } } else { if (bDProjectParkingEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Project Parking Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Project Parking Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private Int64 Update(BDProjectParkingEntity bDProjectParkingEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.BDProjectParking_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@ProjectParkingID", DbType.Int64, bDProjectParkingEntity.ProjectParkingID); Database.AddInParameter(cmd, "@ProjectID", DbType.Int64, bDProjectParkingEntity.ProjectID); Database.AddInParameter(cmd, "@Ground", DbType.Decimal, bDProjectParkingEntity.Ground); Database.AddInParameter(cmd, "@LowerGround", DbType.Decimal, bDProjectParkingEntity.LowerGround); Database.AddInParameter(cmd, "@Basement1", DbType.Decimal, bDProjectParkingEntity.Basement1); Database.AddInParameter(cmd, "@Basement2", DbType.Decimal, bDProjectParkingEntity.Basement2); Database.AddInParameter(cmd, "@Basement3", DbType.Decimal, bDProjectParkingEntity.Basement3); Database.AddInParameter(cmd, "@Basement4", DbType.Decimal, bDProjectParkingEntity.Basement4); Database.AddInParameter(cmd, "@Basement5", DbType.Decimal, bDProjectParkingEntity.Basement5); Database.AddInParameter(cmd, "@Basement6", DbType.Decimal, bDProjectParkingEntity.Basement6); Database.AddInParameter(cmd, "@Outdoor", DbType.Decimal, bDProjectParkingEntity.Outdoor); Database.AddInParameter(cmd, "@Total", DbType.Decimal, bDProjectParkingEntity.Total); Database.AddInParameter(cmd, "@GuestParking", DbType.Decimal, bDProjectParkingEntity.GuestParking); Database.AddInParameter(cmd, "@DisableParking", DbType.Decimal, bDProjectParkingEntity.DisableParking); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("BDProjectParkingEntity already exists. Please specify another BDProjectParkingEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("BDProjectParkingEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("BDProjectParkingEntity already exists. Please specify another BDProjectParkingEntity."); } } } } return(returnCode); }
private Int64 DeleteTran(BDProjectParkingEntity bDProjectParkingEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.BDProjectParking_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 Int64 Delete(BDProjectParkingEntity bDProjectParkingEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.BDProjectParking_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("BDProjectParkingEntity already exists. Please specify another BDProjectParkingEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("BDProjectParkingEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("BDProjectParkingEntity already exists. Please specify another BDProjectParkingEntity."); } } } } return(returnCode); }
private void PrepareEditView() { BDProjectParkingEntity bDProjectParkingEntity = CurrentBDProjectParkingEntity; if (!bDProjectParkingEntity.IsNew) { txtGround.Text = bDProjectParkingEntity.Ground.ToString(); txtLowerGround.Text = bDProjectParkingEntity.LowerGround.ToString(); txtBasement1.Text = bDProjectParkingEntity.Basement1.ToString(); txtBasement2.Text = bDProjectParkingEntity.Basement2.ToString(); txtBasement3.Text = bDProjectParkingEntity.Basement3.ToString(); txtBasement4.Text = bDProjectParkingEntity.Basement4.ToString(); txtBasement5.Text = bDProjectParkingEntity.Basement5.ToString(); txtBasement6.Text = bDProjectParkingEntity.Basement6.ToString(); txtOutdoor.Text = bDProjectParkingEntity.Outdoor.ToString(); txtTotal.Text = bDProjectParkingEntity.Total.ToString(); txtGuestParking.Text = bDProjectParkingEntity.GuestParking.ToString(); txtDisableParking.Text = bDProjectParkingEntity.DisableParking.ToString(); btnSubmit.Text = "Update"; } }
Int64 IBDProjectParkingFacade.Delete(BDProjectParkingEntity bDProjectParkingEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateBDProjectParkingDataAccess().Delete(bDProjectParkingEntity, filterExpression, option, reqTran)); }
Int64 IBDProjectParkingFacade.Add(BDProjectParkingEntity bDProjectParkingEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateBDProjectParkingDataAccess().Add(bDProjectParkingEntity, option, reqTran)); }
protected void btnAddNew_Click(object sender, EventArgs e) { _ProjectParkingID = 0; _BDProjectParkingEntity = new BDProjectParkingEntity(); PrepareInitialView(); }
private BDProjectParkingEntity BuildBDProjectParkingEntity() { BDProjectParkingEntity bDProjectParkingEntity = CurrentBDProjectParkingEntity; bDProjectParkingEntity.ProjectID = OverviewProjectID; if (!txtGround.Text.Trim().IsNullOrEmpty()) { bDProjectParkingEntity.Ground = Decimal.Parse(txtGround.Text.Trim()); } if (!txtLowerGround.Text.Trim().IsNullOrEmpty()) { bDProjectParkingEntity.LowerGround = Decimal.Parse(txtLowerGround.Text.Trim()); } else { bDProjectParkingEntity.LowerGround = null; } if (!txtBasement1.Text.Trim().IsNullOrEmpty()) { bDProjectParkingEntity.Basement1 = Decimal.Parse(txtBasement1.Text.Trim()); } else { bDProjectParkingEntity.Basement1 = null; } if (!txtBasement2.Text.Trim().IsNullOrEmpty()) { bDProjectParkingEntity.Basement2 = Decimal.Parse(txtBasement2.Text.Trim()); } else { bDProjectParkingEntity.Basement2 = null; } if (!txtBasement3.Text.Trim().IsNullOrEmpty()) { bDProjectParkingEntity.Basement3 = Decimal.Parse(txtBasement3.Text.Trim()); } else { bDProjectParkingEntity.Basement3 = null; } if (!txtBasement4.Text.Trim().IsNullOrEmpty()) { bDProjectParkingEntity.Basement4 = Decimal.Parse(txtBasement4.Text.Trim()); } else { bDProjectParkingEntity.Basement4 = null; } if (!txtBasement5.Text.Trim().IsNullOrEmpty()) { bDProjectParkingEntity.Basement5 = Decimal.Parse(txtBasement5.Text.Trim()); } else { bDProjectParkingEntity.Basement5 = null; } if (!txtBasement6.Text.Trim().IsNullOrEmpty()) { bDProjectParkingEntity.Basement6 = Decimal.Parse(txtBasement6.Text.Trim()); } else { bDProjectParkingEntity.Basement6 = null; } if (!txtOutdoor.Text.Trim().IsNullOrEmpty()) { bDProjectParkingEntity.Outdoor = Decimal.Parse(txtOutdoor.Text.Trim()); } else { bDProjectParkingEntity.Outdoor = null; } if (!txtTotal.Text.Trim().IsNullOrEmpty()) { bDProjectParkingEntity.Total = Decimal.Parse(txtTotal.Text.Trim()); } if (!txtGuestParking.Text.Trim().IsNullOrEmpty()) { bDProjectParkingEntity.GuestParking = Decimal.Parse(txtGuestParking.Text.Trim()); } if (!txtDisableParking.Text.Trim().IsNullOrEmpty()) { bDProjectParkingEntity.DisableParking = Decimal.Parse(txtDisableParking.Text.Trim()); } else { bDProjectParkingEntity.DisableParking = null; } return(bDProjectParkingEntity); }
private Int64 UpdateTran(BDProjectParkingEntity bDProjectParkingEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.BDProjectParking_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, "@ProjectParkingID", DbType.Int64, bDProjectParkingEntity.ProjectParkingID); db.AddInParameter(cmd, "@ProjectID", DbType.Int64, bDProjectParkingEntity.ProjectID); db.AddInParameter(cmd, "@Ground", DbType.Decimal, bDProjectParkingEntity.Ground); db.AddInParameter(cmd, "@LowerGround", DbType.Decimal, bDProjectParkingEntity.LowerGround); db.AddInParameter(cmd, "@Basement1", DbType.Decimal, bDProjectParkingEntity.Basement1); db.AddInParameter(cmd, "@Basement2", DbType.Decimal, bDProjectParkingEntity.Basement2); db.AddInParameter(cmd, "@Basement3", DbType.Decimal, bDProjectParkingEntity.Basement3); db.AddInParameter(cmd, "@Basement4", DbType.Decimal, bDProjectParkingEntity.Basement4); db.AddInParameter(cmd, "@Basement5", DbType.Decimal, bDProjectParkingEntity.Basement5); db.AddInParameter(cmd, "@Basement6", DbType.Decimal, bDProjectParkingEntity.Basement6); db.AddInParameter(cmd, "@Outdoor", DbType.Decimal, bDProjectParkingEntity.Outdoor); db.AddInParameter(cmd, "@Total", DbType.Decimal, bDProjectParkingEntity.Total); db.AddInParameter(cmd, "@GuestParking", DbType.Decimal, bDProjectParkingEntity.GuestParking); db.AddInParameter(cmd, "@DisableParking", DbType.Decimal, bDProjectParkingEntity.DisableParking); 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); }