Int64 IMDFloorDataAccess.Add(MDFloorEntity mDFloorEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(mDFloorEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(mDFloorEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
Int64 IMDFloorDataAccess.Delete(MDFloorEntity mDFloorEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Delete(mDFloorEntity, filterExpression, option); break; } case TransactionRequired.Yes: { retValues = DeleteTran(mDFloorEntity, filterExpression, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void SaveMDFloorEntity() { if (IsValid) { try { MDFloorEntity mDFloorEntity = BuildMDFloorEntity(); Int64 result = -1; if (mDFloorEntity.IsNew) { result = FCCMDFloor.GetFacadeCreate().Add(mDFloorEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDFloorEntity.FLD_NAME_FloorID, mDFloorEntity.FloorID.ToString(), SQLMatchType.Equal); result = FCCMDFloor.GetFacadeCreate().Update(mDFloorEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _FloorID = 0; _MDFloorEntity = new MDFloorEntity(); PrepareInitialView(); BindMDFloorList(); if (mDFloorEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Floor Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Floor Information has been updated successfully.", false); } } else { if (mDFloorEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Floor Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Floor Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private Int64 UpdateTran(MDFloorEntity mDFloorEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.MDFloor_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, "@FloorID", DbType.Int64, mDFloorEntity.FloorID); db.AddInParameter(cmd, "@FloorCategoryID", DbType.Int64, mDFloorEntity.FloorCategoryID); db.AddInParameter(cmd, "@Name", DbType.String, mDFloorEntity.Name); db.AddInParameter(cmd, "@Description", DbType.String, mDFloorEntity.Description); db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, mDFloorEntity.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 lvMDFloor_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 FloorID; Int64.TryParse(e.CommandArgument.ToString(), out FloorID); if (FloorID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _FloorID = FloorID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(MDFloorEntity.FLD_NAME_FloorID, FloorID.ToString(), SQLMatchType.Equal); MDFloorEntity mDFloorEntity = new MDFloorEntity(); result = FCCMDFloor.GetFacadeCreate().Delete(mDFloorEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _FloorID = 0; _MDFloorEntity = new MDFloorEntity(); PrepareInitialView(); BindMDFloorList(); MiscUtil.ShowMessage(lblMessage, "Floor has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Floor.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private BDProjectFloorEntity BuildBDProjectFloorEntity() { BDProjectFloorEntity bDProjectFloorEntity = CurrentBDProjectFloorEntity; bDProjectFloorEntity.ProjectID = this.OverviewProjectID; if (ddlFloorCategoryID.Items.Count > 0) { if (ddlFloorCategoryID.SelectedValue == "0") { } else { bDProjectFloorEntity.FloorCategoryID = Int64.Parse(ddlFloorCategoryID.SelectedValue); } } if (ddlFloorID.Items.Count > 0) { if (ddlFloorID.SelectedValue == "0") { } else { bDProjectFloorEntity.FloorID = Int64.Parse(ddlFloorID.SelectedValue); } } IList <MDFloorEntity> lst = FCCMDFloor.GetFacadeCreate().GetIL(null, null, null, null, DatabaseOperationType.Load); MDFloorEntity mDFloorEntity = lst.Where(x => x.FloorID == bDProjectFloorEntity.FloorID).Single(); bDProjectFloorEntity.Name = mDFloorEntity.Name; if (!txtSize.Text.Trim().IsNullOrEmpty()) { bDProjectFloorEntity.Size = Int32.Parse(txtSize.Text.Trim()); } bDProjectFloorEntity.Description = txtDescription.Text.Trim(); bDProjectFloorEntity.IsRemoved = chkIsRemoved.Checked; return(bDProjectFloorEntity); }
private Int64 Update(MDFloorEntity mDFloorEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.MDFloor_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@FloorID", DbType.Int64, mDFloorEntity.FloorID); Database.AddInParameter(cmd, "@FloorCategoryID", DbType.Int64, mDFloorEntity.FloorCategoryID); Database.AddInParameter(cmd, "@Name", DbType.String, mDFloorEntity.Name); Database.AddInParameter(cmd, "@Description", DbType.String, mDFloorEntity.Description); Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, mDFloorEntity.IsRemoved); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("MDFloorEntity already exists. Please specify another MDFloorEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("MDFloorEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("MDFloorEntity already exists. Please specify another MDFloorEntity."); } } } } return(returnCode); }
private void PrepareEditView() { MDFloorEntity mDFloorEntity = CurrentMDFloorEntity; if (!mDFloorEntity.IsNew) { if (ddlFloorCategoryID.Items.Count > 0 && mDFloorEntity.FloorCategoryID != null) { ddlFloorCategoryID.SelectedValue = mDFloorEntity.FloorCategoryID.ToString(); } txtName.Text = mDFloorEntity.Name.ToString(); txtDescription.Text = mDFloorEntity.Description.ToString(); chkIsRemoved.Checked = mDFloorEntity.IsRemoved; btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private MDFloorEntity BuildMDFloorEntity() { MDFloorEntity mDFloorEntity = CurrentMDFloorEntity; if (ddlFloorCategoryID.Items.Count > 0) { if (ddlFloorCategoryID.SelectedValue == "0") { } else { mDFloorEntity.FloorCategoryID = Int64.Parse(ddlFloorCategoryID.SelectedValue); } } mDFloorEntity.Name = txtName.Text.Trim(); mDFloorEntity.Description = txtDescription.Text.Trim(); mDFloorEntity.IsRemoved = chkIsRemoved.Checked; return(mDFloorEntity); }
Int64 IMDFloorFacade.Delete(MDFloorEntity mDFloorEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateMDFloorDataAccess().Delete(mDFloorEntity, filterExpression, option, reqTran)); }
Int64 IMDFloorFacade.Add(MDFloorEntity mDFloorEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateMDFloorDataAccess().Add(mDFloorEntity, option, reqTran)); }
protected void btnAddNew_Click(object sender, EventArgs e) { _FloorID = 0; _MDFloorEntity = new MDFloorEntity(); PrepareInitialView(); }