private void PrepareEditView() { PRMPreBOQFloorDetailEntity pRMPreBOQFloorDetailEntity = CurrentPRMPreBOQFloorDetailEntity; if (!pRMPreBOQFloorDetailEntity.IsNew) { if (ddlPreBOQDetailID.Items.Count > 0 && pRMPreBOQFloorDetailEntity.PreBOQDetailID != null) { ddlPreBOQDetailID.SelectedValue = pRMPreBOQFloorDetailEntity.PreBOQDetailID.ToString(); } if (ddlProjectFloorID.Items.Count > 0 && pRMPreBOQFloorDetailEntity.ProjectFloorID != null) { ddlProjectFloorID.SelectedValue = pRMPreBOQFloorDetailEntity.ProjectFloorID.ToString(); } txtQty.Text = pRMPreBOQFloorDetailEntity.Qty.ToString(); txtRate.Text = pRMPreBOQFloorDetailEntity.Rate.ToString(); txtRemarks.Text = pRMPreBOQFloorDetailEntity.Remarks.ToString(); txtEntryDate.Text = pRMPreBOQFloorDetailEntity.EntryDate.ToStringDefault(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
Int64 IPRMPreBOQFloorDetailDataAccess.Add(PRMPreBOQFloorDetailEntity pRMPreBOQFloorDetailEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(pRMPreBOQFloorDetailEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(pRMPreBOQFloorDetailEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private Int64 UpdateTran(PRMPreBOQFloorDetailEntity pRMPreBOQFloorDetailEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.PRMPreBOQFloorDetail_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, "@PreBOQFloorDetailID", DbType.Int64, pRMPreBOQFloorDetailEntity.PreBOQFloorDetailID); db.AddInParameter(cmd, "@PreBOQDetailID", DbType.Int64, pRMPreBOQFloorDetailEntity.PreBOQDetailID); db.AddInParameter(cmd, "@ProjectFloorID", DbType.Int64, pRMPreBOQFloorDetailEntity.ProjectFloorID); db.AddInParameter(cmd, "@Qty", DbType.Decimal, pRMPreBOQFloorDetailEntity.Qty); db.AddInParameter(cmd, "@Rate", DbType.Decimal, pRMPreBOQFloorDetailEntity.Rate); db.AddInParameter(cmd, "@Remarks", DbType.String, pRMPreBOQFloorDetailEntity.Remarks); db.AddInParameter(cmd, "@EntryDate", DbType.DateTime, pRMPreBOQFloorDetailEntity.EntryDate); 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 SavePRMPreBOQFloorDetailEntity() { if (IsValid) { try { PRMPreBOQFloorDetailEntity pRMPreBOQFloorDetailEntity = BuildPRMPreBOQFloorDetailEntity(); Int64 result = -1; if (pRMPreBOQFloorDetailEntity.IsNew) { result = FCCPRMPreBOQFloorDetail.GetFacadeCreate().Add(pRMPreBOQFloorDetailEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQFloorDetailEntity.FLD_NAME_PreBOQFloorDetailID, pRMPreBOQFloorDetailEntity.PreBOQFloorDetailID.ToString(), SQLMatchType.Equal); result = FCCPRMPreBOQFloorDetail.GetFacadeCreate().Update(pRMPreBOQFloorDetailEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _PreBOQFloorDetailID = 0; _PRMPreBOQFloorDetailEntity = new PRMPreBOQFloorDetailEntity(); PrepareInitialView(); BindPRMPreBOQFloorDetailList(); if (pRMPreBOQFloorDetailEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Pre BOQFloor Detail Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Pre BOQFloor Detail Information has been updated successfully.", false); } } else { if (pRMPreBOQFloorDetailEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Pre BOQFloor Detail Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Pre BOQFloor Detail Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private PRMPreBOQFloorDetailEntity BuildPRMPreBOQFloorDetailEntity() { PRMPreBOQFloorDetailEntity pRMPreBOQFloorDetailEntity = CurrentPRMPreBOQFloorDetailEntity; if (ddlPreBOQDetailID.Items.Count > 0) { if (ddlPreBOQDetailID.SelectedValue == "0") { } else { pRMPreBOQFloorDetailEntity.PreBOQDetailID = Int64.Parse(ddlPreBOQDetailID.SelectedValue); } } if (ddlProjectFloorID.Items.Count > 0) { if (ddlProjectFloorID.SelectedValue == "0") { } else { pRMPreBOQFloorDetailEntity.ProjectFloorID = Int64.Parse(ddlProjectFloorID.SelectedValue); } } if (!txtQty.Text.Trim().IsNullOrEmpty()) { pRMPreBOQFloorDetailEntity.Qty = Decimal.Parse(txtQty.Text.Trim()); } else { pRMPreBOQFloorDetailEntity.Qty = null; } if (!txtRate.Text.Trim().IsNullOrEmpty()) { pRMPreBOQFloorDetailEntity.Rate = Decimal.Parse(txtRate.Text.Trim()); } else { pRMPreBOQFloorDetailEntity.Rate = null; } pRMPreBOQFloorDetailEntity.Remarks = txtRemarks.Text.Trim(); if (txtEntryDate.Text.Trim().IsNotNullOrEmpty()) { pRMPreBOQFloorDetailEntity.EntryDate = MiscUtil.ParseToDateTime(txtEntryDate.Text); } return(pRMPreBOQFloorDetailEntity); }
protected void lvPRMPreBOQFloorDetail_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 PreBOQFloorDetailID; Int64.TryParse(e.CommandArgument.ToString(), out PreBOQFloorDetailID); if (PreBOQFloorDetailID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _PreBOQFloorDetailID = PreBOQFloorDetailID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQFloorDetailEntity.FLD_NAME_PreBOQFloorDetailID, PreBOQFloorDetailID.ToString(), SQLMatchType.Equal); PRMPreBOQFloorDetailEntity pRMPreBOQFloorDetailEntity = new PRMPreBOQFloorDetailEntity(); result = FCCPRMPreBOQFloorDetail.GetFacadeCreate().Delete(pRMPreBOQFloorDetailEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _PreBOQFloorDetailID = 0; _PRMPreBOQFloorDetailEntity = new PRMPreBOQFloorDetailEntity(); PrepareInitialView(); BindPRMPreBOQFloorDetailList(); MiscUtil.ShowMessage(lblMessage, "Pre BOQFloor Detail has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Pre BOQFloor Detail.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 Update(PRMPreBOQFloorDetailEntity pRMPreBOQFloorDetailEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.PRMPreBOQFloorDetail_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@PreBOQFloorDetailID", DbType.Int64, pRMPreBOQFloorDetailEntity.PreBOQFloorDetailID); Database.AddInParameter(cmd, "@PreBOQDetailID", DbType.Int64, pRMPreBOQFloorDetailEntity.PreBOQDetailID); Database.AddInParameter(cmd, "@ProjectFloorID", DbType.Int64, pRMPreBOQFloorDetailEntity.ProjectFloorID); Database.AddInParameter(cmd, "@Qty", DbType.Decimal, pRMPreBOQFloorDetailEntity.Qty); Database.AddInParameter(cmd, "@Rate", DbType.Decimal, pRMPreBOQFloorDetailEntity.Rate); Database.AddInParameter(cmd, "@Remarks", DbType.String, pRMPreBOQFloorDetailEntity.Remarks); Database.AddInParameter(cmd, "@EntryDate", DbType.DateTime, pRMPreBOQFloorDetailEntity.EntryDate); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("PRMPreBOQFloorDetailEntity already exists. Please specify another PRMPreBOQFloorDetailEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("PRMPreBOQFloorDetailEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("PRMPreBOQFloorDetailEntity already exists. Please specify another PRMPreBOQFloorDetailEntity."); } } } } return(returnCode); }
protected void btnAddNew_Click(object sender, EventArgs e) { _PreBOQFloorDetailID = 0; _PRMPreBOQFloorDetailEntity = new PRMPreBOQFloorDetailEntity(); PrepareInitialView(); }
protected void lvPRMPreBOQDetail_ItemCommand(object sender, ListViewCommandEventArgs e) { #region Modify Qty if (e.CommandName == "ModifyQty") { Int64 ItemID; Int64.TryParse(e.CommandArgument.ToString(), out ItemID); Label lblPreBOQDetailIDLV = (Label)e.Item.FindControl("lblPreBOQDetailIDLV"); TextBox txtRateLV = (TextBox)e.Item.FindControl("txtRateLV"); Int64 preBOQDetailID = Int64.Parse(lblPreBOQDetailIDLV.Text); _CurrentPreBOQDetailIDPopup = preBOQDetailID; if (ItemID > 0) { _CurrentItemID = ItemID; this.lblItemName.Text = ((Label)e.Item.FindControl("lblItemNameLV")).Text; PRMPreBOQDetailEntity bOQDetailEntity = FCCPRMPreBOQDetail.GetFacadeCreate().GetByID(preBOQDetailID); if (bOQDetailEntity != null && bOQDetailEntity.PreBOQDetailID > 0) { String fe3 = SqlExpressionBuilder.PrepareFilterExpression(BDProjectFloorEntity.FLD_NAME_ProjectID, this.OverviewProjectID.ToString(), SQLMatchType.Equal); IList <BDProjectFloorEntity> bDProjectFloorList = FCCBDProjectFloor.GetFacadeCreate().GetIL(null, null, String.Empty, fe3, DatabaseOperationType.LoadWithFilterExpression); if (bDProjectFloorList != null && bDProjectFloorList.Count > 0) { foreach (BDProjectFloorEntity bdProjectfloorent in bDProjectFloorList) { String fe4 = String.Empty; String feFloorDetail1 = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQFloorDetailEntity.FLD_NAME_ProjectFloorID, bdProjectfloorent.ProjectFloorID.ToString(), SQLMatchType.Equal); String feFloorDetail2 = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQFloorDetailEntity.FLD_NAME_PreBOQDetailID, preBOQDetailID.ToString(), SQLMatchType.Equal); fe4 = SqlExpressionBuilder.PrepareFilterExpression(feFloorDetail1, SQLJoinType.AND, feFloorDetail2); IList <PRMPreBOQFloorDetailEntity> list = FCCPRMPreBOQFloorDetail.GetFacadeCreate().GetIL(null, null, String.Empty, fe4, DatabaseOperationType.LoadWithFilterExpression); if (list == null || list.Count <= 0) { PRMPreBOQFloorDetailEntity ent = new PRMPreBOQFloorDetailEntity(); ent.PreBOQDetailID = Int64.Parse(preBOQDetailID.ToString()); ent.ProjectFloorID = Int64.Parse(bdProjectfloorent.ProjectFloorID.ToString()); Decimal dividedQty; Decimal RateLV; Decimal.TryParse(txtRateLV.Text, out RateLV); Decimal.TryParse((bOQDetailEntity.TotalQty / (this.OverviewProject.NoOfBasement + this.OverviewProject.NoOfStoried)).ToString(), out dividedQty); switch (bdProjectfloorent.FloorCategoryID) { case MasterDataConstants.FloorCategory.BASEMENT: dividedQty = dividedQty / 4; //Assumuation break; case MasterDataConstants.FloorCategory.FLOOR: dividedQty = dividedQty * 1; //Assumuation break; case MasterDataConstants.FloorCategory.PENTHOUSE: dividedQty = dividedQty * 2; //Assumuation break; case MasterDataConstants.FloorCategory.HEAD_ROOM: dividedQty = dividedQty * 3; //Assumuation break; default: dividedQty = 0; break; } ent.Rate = RateLV; ent.Qty = dividedQty; ent.Remarks = String.Empty; ent.EntryDate = System.DateTime.Now; FCCPRMPreBOQFloorDetail.GetFacadeCreate().Add(ent, DatabaseOperationType.Add, TransactionRequired.No); } } BindPRMPreBOQFloorDetailList(); this.ModalPopupExtender2.Show(); } else { MiscUtil.ShowMessage(lblMessage, "No Floor Available.", true); } } } } #endregion #region Modify Price if (e.CommandName == "ModifyPrice") { Int64 ItemID; Int64.TryParse(e.CommandArgument.ToString(), out ItemID); if (ItemID > 0) { MiscUtil.PopulateMDBrandByItemID(ddlBrandID, false, Int64.Parse(ItemID.ToString())); this.lblItemName.Text = ((Label)e.Item.FindControl("lblItemNameLV")).Text; if (ddlBrandID != null && ddlBrandID.Items.Count > 0) { this.ddlBrandID.SelectedValue = ((Label)e.Item.FindControl("lblBrandID")).Text; } BuildSupplierByBrand(); if (ddlSupplierID != null && ddlSupplierID.Items.Count > 0) { this.ddlSupplierID.SelectedValue = ((Label)e.Item.FindControl("lblSupplierID")).Text; } _CurrentItemID = ItemID; if (ddlOriginRegionID != null && ddlOriginRegionID.Items.Count > 0) { this.ddlOriginRegionID.SelectedValue = ((Label)e.Item.FindControl("lblRegionID")).Text; } BuildCountryDropdownByRegion(); if (ddlOriginCountryID != null && ddlOriginCountryID.Items.Count > 0) { this.ddlOriginCountryID.SelectedValue = ((Label)e.Item.FindControl("lblCountryID")).Text; } GetCurrentPrice(); } this.Panel1_ModalPopupExtender.Show(); } if (e.CommandName == "AdditionalQty") { Int64 preBoqDetailID; Int64.TryParse(e.CommandArgument.ToString(), out preBoqDetailID); if (preBoqDetailID > 0) { _CurrentPreBOQDetailIDPopup = preBoqDetailID; this.ModalPopupExtender1.Show(); } } #endregion }
private void UpdatePreBOQFloorDetail() { try { IList <ListViewDataItem> listPRMPreFloorDetail = lvPRMPreBOQFloorDetail.Items; if (listPRMPreFloorDetail != null && listPRMPreFloorDetail.Count > 0) { Decimal Totalqty = 0, totalRate = 0, avgRate, avgTotalQty, count = 0; foreach (ListViewDataItem lvdi in listPRMPreFloorDetail) { Int64 floorDetailID; Decimal newQty, floorRate; TextBox txtTotalQtyLV = (TextBox)lvdi.FindControl("txtQtyLV"); TextBox txtRateLV = (TextBox)lvdi.FindControl("txtRateLV"); TextBox txtRemarksLV = (TextBox)lvdi.FindControl("txtRemarksLV"); Label floorDetailIDLV = (Label)lvdi.FindControl("lblPreBOQFloorDetailIDLV"); Decimal.TryParse(txtTotalQtyLV.Text.Trim(), out newQty); Decimal.TryParse(txtRateLV.Text.Trim(), out floorRate); Int64.TryParse(floorDetailIDLV.Text.Trim(), out floorDetailID); PRMPreBOQFloorDetailEntity pRMPreBOQFloorDetailEntity = FCCPRMPreBOQFloorDetail.GetFacadeCreate().GetByID(floorDetailID); pRMPreBOQFloorDetailEntity.Qty = newQty; pRMPreBOQFloorDetailEntity.Rate = floorRate; pRMPreBOQFloorDetailEntity.Remarks = txtRemarksLV.Text; pRMPreBOQFloorDetailEntity.EntryDate = System.DateTime.Now; String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQFloorDetailEntity.FLD_NAME_PreBOQFloorDetailID, floorDetailID.ToString(), SQLMatchType.Equal); FCCPRMPreBOQFloorDetail.GetFacadeCreate().Update(pRMPreBOQFloorDetailEntity, fe, DatabaseOperationType.Update, TransactionRequired.No); Totalqty += newQty; totalRate += floorRate; count++; } avgRate = totalRate / count; avgTotalQty = Totalqty / count; #region Update Project Cost Qty String fe_BOQDetail = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQDetailEntity.FLD_NAME_PreBOQDetailID, _CurrentPreBOQDetailIDPopup.ToString(), SQLMatchType.Equal); PRMPreBOQDetailEntity prmBOQDetailEntity = FCCPRMPreBOQDetail.GetFacadeCreate().GetByID(_CurrentPreBOQDetailIDPopup); prmBOQDetailEntity.TotalQty = Totalqty; FCCPRMPreBOQDetail.GetFacadeCreate().Update(prmBOQDetailEntity, fe_BOQDetail, DatabaseOperationType.Update, TransactionRequired.No); IList <ListViewDataItem> listPRMBOQDetail = lvPRMPreBOQDetail.Items; if (listPRMBOQDetail != null && listPRMBOQDetail.Count > 0) { Int32 tempDataItemIndex = 0; foreach (ListViewDataItem lvdi in listPRMBOQDetail) { DataKey currentDataKey = lvPRMPreBOQDetail.DataKeys[tempDataItemIndex++]; Int64 intPreBOQDetailID = (Int64)currentDataKey["PreBOQDetailID"]; if (_CurrentPreBOQDetailIDPopup == intPreBOQDetailID) { TextBox txtRateLV = (TextBox)lvdi.FindControl("txtRateLV"); TextBox txtTotalQtyLV = (TextBox)lvdi.FindControl("txtTotalQtyLV"); txtTotalQtyLV.Text = Totalqty.ToString(); txtRateLV.Text = avgRate.ToString(); break; } } } BindList(); #endregion MiscUtil.ShowMessage(lblMessage, "Project Cost Information has been saved successfully.", false); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, "Failed to Save Project Cost Information.", true); } }
Int64 IPRMPreBOQFloorDetailFacade.Delete(PRMPreBOQFloorDetailEntity pRMPreBOQFloorDetailEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreatePRMPreBOQFloorDetailDataAccess().Delete(pRMPreBOQFloorDetailEntity, filterExpression, option, reqTran)); }
Int64 IPRMPreBOQFloorDetailFacade.Add(PRMPreBOQFloorDetailEntity pRMPreBOQFloorDetailEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreatePRMPreBOQFloorDetailDataAccess().Add(pRMPreBOQFloorDetailEntity, option, reqTran)); }