Int64 ICMBillFloorDetailDataAccess.Add(CMBillFloorDetailEntity cMBillFloorDetailEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(cMBillFloorDetailEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(cMBillFloorDetailEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private Int64 UpdateTran(CMBillFloorDetailEntity cMBillFloorDetailEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMBillFloorDetail_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, "@BillFloorDetailID", DbType.Int64, cMBillFloorDetailEntity.BillFloorDetailID); db.AddInParameter(cmd, "@BillID", DbType.Int64, cMBillFloorDetailEntity.BillID); db.AddInParameter(cmd, "@BillFloorDetailCategoryID", DbType.Int64, cMBillFloorDetailEntity.BillFloorDetailCategoryID); db.AddInParameter(cmd, "@ProjectFloorID", DbType.Int64, cMBillFloorDetailEntity.ProjectFloorID); db.AddInParameter(cmd, "@ProjectFloorUnitID", DbType.Int64, cMBillFloorDetailEntity.ProjectFloorUnitID); db.AddInParameter(cmd, "@FloorBillAmount", DbType.Decimal, cMBillFloorDetailEntity.FloorBillAmount); db.AddInParameter(cmd, "@Remarks", DbType.String, cMBillFloorDetailEntity.Remarks); db.AddInParameter(cmd, "@EntryDate", DbType.DateTime, cMBillFloorDetailEntity.EntryDate); db.AddInParameter(cmd, "@Extra1", DbType.String, cMBillFloorDetailEntity.Extra1); db.AddInParameter(cmd, "@Extra2", DbType.String, cMBillFloorDetailEntity.Extra2); 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 SaveCMBillFloorDetailEntity() { if (IsValid) { try { CMBillFloorDetailEntity cMBillFloorDetailEntity = BuildCMBillFloorDetailEntity(); Int64 result = -1; if (cMBillFloorDetailEntity.IsNew) { result = FCCCMBillFloorDetail.GetFacadeCreate().Add(cMBillFloorDetailEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CMBillFloorDetailEntity.FLD_NAME_BillFloorDetailID, cMBillFloorDetailEntity.BillFloorDetailID.ToString(), SQLMatchType.Equal); result = FCCCMBillFloorDetail.GetFacadeCreate().Update(cMBillFloorDetailEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _BillFloorDetailID = 0; _CMBillFloorDetailEntity = new CMBillFloorDetailEntity(); PrepareInitialView(); BindCMBillFloorDetailList(); if (cMBillFloorDetailEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "C MBill Floor Detail Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "C MBill Floor Detail Information has been updated successfully.", false); } } else { if (cMBillFloorDetailEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add C MBill Floor Detail Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update C MBill Floor Detail Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvCMBillFloorDetail_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 BillFloorDetailID; Int64.TryParse(e.CommandArgument.ToString(), out BillFloorDetailID); if (BillFloorDetailID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _BillFloorDetailID = BillFloorDetailID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(CMBillFloorDetailEntity.FLD_NAME_BillFloorDetailID, BillFloorDetailID.ToString(), SQLMatchType.Equal); CMBillFloorDetailEntity cMBillFloorDetailEntity = new CMBillFloorDetailEntity(); result = FCCCMBillFloorDetail.GetFacadeCreate().Delete(cMBillFloorDetailEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _BillFloorDetailID = 0; _CMBillFloorDetailEntity = new CMBillFloorDetailEntity(); PrepareInitialView(); BindCMBillFloorDetailList(); MiscUtil.ShowMessage(lblMessage, "C MBill Floor Detail has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete C MBill Floor Detail.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(CMBillFloorDetailEntity cMBillFloorDetailEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMBillFloorDetail_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 Update(CMBillFloorDetailEntity cMBillFloorDetailEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMBillFloorDetail_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@BillFloorDetailID", DbType.Int64, cMBillFloorDetailEntity.BillFloorDetailID); Database.AddInParameter(cmd, "@BillID", DbType.Int64, cMBillFloorDetailEntity.BillID); Database.AddInParameter(cmd, "@BillFloorDetailCategoryID", DbType.Int64, cMBillFloorDetailEntity.BillFloorDetailCategoryID); Database.AddInParameter(cmd, "@ProjectFloorID", DbType.Int64, cMBillFloorDetailEntity.ProjectFloorID); Database.AddInParameter(cmd, "@ProjectFloorUnitID", DbType.Int64, cMBillFloorDetailEntity.ProjectFloorUnitID); Database.AddInParameter(cmd, "@FloorBillAmount", DbType.Decimal, cMBillFloorDetailEntity.FloorBillAmount); Database.AddInParameter(cmd, "@Remarks", DbType.String, cMBillFloorDetailEntity.Remarks); Database.AddInParameter(cmd, "@EntryDate", DbType.DateTime, cMBillFloorDetailEntity.EntryDate); Database.AddInParameter(cmd, "@Extra1", DbType.String, cMBillFloorDetailEntity.Extra1); Database.AddInParameter(cmd, "@Extra2", DbType.String, cMBillFloorDetailEntity.Extra2); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("CMBillFloorDetailEntity already exists. Please specify another CMBillFloorDetailEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CMBillFloorDetailEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CMBillFloorDetailEntity already exists. Please specify another CMBillFloorDetailEntity."); } } } } return(returnCode); }
private Int64 Delete(CMBillFloorDetailEntity cMBillFloorDetailEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMBillFloorDetail_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("CMBillFloorDetailEntity already exists. Please specify another CMBillFloorDetailEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CMBillFloorDetailEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CMBillFloorDetailEntity already exists. Please specify another CMBillFloorDetailEntity."); } } } } return(returnCode); }
private void PrepareEditView() { CMBillFloorDetailEntity cMBillFloorDetailEntity = CurrentCMBillFloorDetailEntity; if (!cMBillFloorDetailEntity.IsNew) { if (ddlBillID.Items.Count > 0 && cMBillFloorDetailEntity.BillID != null) { ddlBillID.SelectedValue = cMBillFloorDetailEntity.BillID.ToString(); } if (ddlBillFloorDetailCategoryID.Items.Count > 0 && cMBillFloorDetailEntity.BillFloorDetailCategoryID != null) { ddlBillFloorDetailCategoryID.SelectedValue = cMBillFloorDetailEntity.BillFloorDetailCategoryID.ToString(); } if (ddlProjectFloorID.Items.Count > 0 && cMBillFloorDetailEntity.ProjectFloorID != null) { ddlProjectFloorID.SelectedValue = cMBillFloorDetailEntity.ProjectFloorID.ToString(); } if (ddlProjectFloorUnitID.Items.Count > 0 && cMBillFloorDetailEntity.ProjectFloorUnitID != null) { ddlProjectFloorUnitID.SelectedValue = cMBillFloorDetailEntity.ProjectFloorUnitID.ToString(); } txtFloorBillAmount.Text = cMBillFloorDetailEntity.FloorBillAmount.ToString(); txtRemarks.Text = cMBillFloorDetailEntity.Remarks.ToString(); txtEntryDate.Text = cMBillFloorDetailEntity.EntryDate.ToStringDefault(); txtExtra1.Text = cMBillFloorDetailEntity.Extra1.ToString(); txtExtra2.Text = cMBillFloorDetailEntity.Extra2.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
Int64 ICMBillFloorDetailFacade.Delete(CMBillFloorDetailEntity cMBillFloorDetailEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCMBillFloorDetailDataAccess().Delete(cMBillFloorDetailEntity, filterExpression, option, reqTran)); }
Int64 ICMBillFloorDetailFacade.Add(CMBillFloorDetailEntity cMBillFloorDetailEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCMBillFloorDetailDataAccess().Add(cMBillFloorDetailEntity, option, reqTran)); }
protected void btnAddNew_Click(object sender, EventArgs e) { _BillFloorDetailID = 0; _CMBillFloorDetailEntity = new CMBillFloorDetailEntity(); PrepareInitialView(); }
private CMBillFloorDetailEntity BuildCMBillFloorDetailEntity() { CMBillFloorDetailEntity cMBillFloorDetailEntity = CurrentCMBillFloorDetailEntity; if (ddlBillID.Items.Count > 0) { if (ddlBillID.SelectedValue == "0") { } else { cMBillFloorDetailEntity.BillID = Int64.Parse(ddlBillID.SelectedValue); } } if (ddlBillFloorDetailCategoryID.Items.Count > 0) { if (ddlBillFloorDetailCategoryID.SelectedValue == "0") { } else { cMBillFloorDetailEntity.BillFloorDetailCategoryID = Int64.Parse(ddlBillFloorDetailCategoryID.SelectedValue); } } if (ddlProjectFloorID.Items.Count > 0) { if (ddlProjectFloorID.SelectedValue == "0") { } else { cMBillFloorDetailEntity.ProjectFloorID = Int64.Parse(ddlProjectFloorID.SelectedValue); } } if (ddlProjectFloorUnitID.Items.Count > 0) { if (ddlProjectFloorUnitID.SelectedValue == "0") { cMBillFloorDetailEntity.ProjectFloorUnitID = null; } else { cMBillFloorDetailEntity.ProjectFloorUnitID = Int64.Parse(ddlProjectFloorUnitID.SelectedValue); } } if (!txtFloorBillAmount.Text.Trim().IsNullOrEmpty()) { cMBillFloorDetailEntity.FloorBillAmount = Decimal.Parse(txtFloorBillAmount.Text.Trim()); } else { cMBillFloorDetailEntity.FloorBillAmount = null; } cMBillFloorDetailEntity.Remarks = txtRemarks.Text.Trim(); if (txtEntryDate.Text.Trim().IsNotNullOrEmpty()) { cMBillFloorDetailEntity.EntryDate = MiscUtil.ParseToDateTime(txtEntryDate.Text); } cMBillFloorDetailEntity.Extra1 = txtExtra1.Text.Trim(); cMBillFloorDetailEntity.Extra2 = txtExtra2.Text.Trim(); return(cMBillFloorDetailEntity); }