Exemplo n.º 1
0
        private void FormLock()
        {
            Boolean isLocked = true;

            String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQEntity.FLD_NAME_ProjectID, this.OverviewProjectID.ToString(), SQLMatchType.Equal);
            IList <PRMBOQEntity> lstPRMBOQ = FCCPRMBOQ.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression);

            if (lstPRMBOQ != null && lstPRMBOQ.Count > 0)
            {
                isLocked = false;
            }

            #region Form Lock

            if (isLocked == true)
            {
                btnSubmit.Enabled   = false;
                btnClear.Enabled    = false;
                lblFormLock.Visible = true;
            }
            else
            {
                btnSubmit.Enabled   = true;
                btnClear.Enabled    = true;
                lblFormLock.Visible = false;
            }

            #endregion Form Lock
        }
Exemplo n.º 2
0
        public IList <PRMBOQEntity> GetPagedData(Int32 startRowIndex, Int32 pageSize, String sortExpression)
        {
            IList <PRMBOQEntity> pRMBOQEntityList = new List <PRMBOQEntity>();

            try
            {
                if (pageSize == -1)
                {
                    pageSize = 1000000000;
                }

                if (String.IsNullOrEmpty(sortExpression))
                {
                    sortExpression = PRMBOQEntity.FLD_NAME_BOQID + " " + SQLConstants.SORT_ORDER_DESCENDING;
                }

                startRowIndex = Convert.ToInt32(startRowIndex / pageSize) + 1;

                pRMBOQEntityList = FCCPRMBOQ.GetFacadeCreate().GetIL(startRowIndex, pageSize, sortExpression, null, DatabaseOperationType.LoadPagedWithSortExpression);

                if (pRMBOQEntityList != null && pRMBOQEntityList.Count > 0)
                {
                    totalRowCount = pRMBOQEntityList[0].TotalRowCount;
                }
            }
            catch (Exception ex)
            {
            }

            return(pRMBOQEntityList ?? new List <PRMBOQEntity>());
        }
Exemplo n.º 3
0
        private void SavePRMBOQEntity()
        {
            if (IsValid)
            {
                try
                {
                    PRMBOQEntity pRMBOQEntity = BuildPRMBOQEntity();

                    Int64 result = -1;

                    if (pRMBOQEntity.IsNew)
                    {
                        result = FCCPRMBOQ.GetFacadeCreate().Add(pRMBOQEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQEntity.FLD_NAME_BOQID, pRMBOQEntity.BOQID.ToString(), SQLMatchType.Equal);
                        result = FCCPRMBOQ.GetFacadeCreate().Update(pRMBOQEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _PRMBOQEntity = new PRMBOQEntity();
                        PrepareInitialView();
                        PrepareEditView();

                        if (pRMBOQEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Project Cost Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Project Cost Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (pRMBOQEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Project Cost Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update BOQ Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Exemplo n.º 4
0
        public IList <PRMBOQEntity> GetData()
        {
            IList <PRMBOQEntity> pRMBOQEntityList = new List <PRMBOQEntity>();

            try
            {
                pRMBOQEntityList = FCCPRMBOQ.GetFacadeCreate().GetIL(null, null, null, null, DatabaseOperationType.Load);

                if (pRMBOQEntityList != null && pRMBOQEntityList.Count > 0)
                {
                    totalRowCount = pRMBOQEntityList[0].TotalRowCount;
                }
            }
            catch (Exception ex)
            {
            }

            return(pRMBOQEntityList ?? new List <PRMBOQEntity>());
        }
Exemplo n.º 5
0
        protected void btnPnlSaveAdditionalQty_Click(object sender, EventArgs e)
        {
            PRMBOQDetailEntity pRMBOQDetailEntity = FCCPRMBOQDetail.GetFacadeCreate().GetByID(_CurrentBOQDetailIDPopup);

            if (pRMBOQDetailEntity != null && pRMBOQDetailEntity.BOQDetailID > 0)
            {
                Decimal additionalQty = 0;
                Decimal.TryParse(txtQty.Text.Trim().ToString(), out additionalQty);

                PRMAvailableBOQQtyForRequisitionEntity pRMAvailableBOQQtyForRequisitionEntity = new PRMAvailableBOQQtyForRequisitionEntity();

                pRMAvailableBOQQtyForRequisitionEntity.IsBOQ = true;
                pRMAvailableBOQQtyForRequisitionEntity.PreBOQOrBOQDetailID = _CurrentBOQDetailIDPopup;
                pRMAvailableBOQQtyForRequisitionEntity.ItemID              = pRMBOQDetailEntity.ItemID;
                pRMAvailableBOQQtyForRequisitionEntity.Qty                 = additionalQty;
                pRMAvailableBOQQtyForRequisitionEntity.CreateDate          = DateTime.Now;
                pRMAvailableBOQQtyForRequisitionEntity.CreatedByEmployeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember);
                PRMBOQEntity pRMBOQEntity = FCCPRMBOQ.GetFacadeCreate().GetByID(pRMBOQDetailEntity.BOQID);
                pRMAvailableBOQQtyForRequisitionEntity.ProjectID = pRMBOQEntity.ProjectID;

                Int64 result = -1;
                result = FCCPRMAvailableBOQQtyForRequisition.GetFacadeCreate().Add(pRMAvailableBOQQtyForRequisitionEntity, DatabaseOperationType.Add, TransactionRequired.No);

                if (result > 0)
                {
                    String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQDetailEntity.FLD_NAME_BOQDetailID, _CurrentBOQDetailIDPopup.ToString(), SQLMatchType.Equal);

                    pRMBOQDetailEntity.TotalQty = pRMBOQDetailEntity.TotalQty + additionalQty;

                    FCCPRMBOQDetail.GetFacadeCreate().Update(pRMBOQDetailEntity, fe, DatabaseOperationType.Update, TransactionRequired.No);

                    IList <ListViewDataItem> list = lvPRMBOQDetail.Items;

                    if (list != null && list.Count > 0)
                    {
                        Int32 tempDataItemIndex = 0;

                        foreach (ListViewDataItem lvdi in list)
                        {
                            DataKey currentDataKey = lvPRMBOQDetail.DataKeys[tempDataItemIndex++];
                            Int64   intBOQDetailID = (Int64)currentDataKey["BOQDetailID"];

                            if (_CurrentBOQDetailIDPopup == intBOQDetailID)
                            {
                                TextBox txtTotalQtyLV = (TextBox)lvdi.FindControl("txtTotalQtyLV");
                                txtTotalQtyLV.Text = pRMBOQDetailEntity.TotalQty.ToString();
                            }
                        }
                    }

                    BindPRMBOQDetailList();

                    #region BOQ Floor Detail

                    String fe_projectFloor = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQFloorDetailEntity.FLD_NAME_BOQDetailID, _CurrentBOQDetailIDPopup.ToString(), SQLMatchType.Equal);
                    IList <PRMBOQFloorDetailEntity> lstPRMBOQFloorDetail = FCCPRMBOQFloorDetail.GetFacadeCreate().GetIL(null, null, String.Empty, fe_projectFloor, DatabaseOperationType.LoadWithFilterExpression);

                    if (lstPRMBOQFloorDetail != null && lstPRMBOQFloorDetail.Count > 0)
                    {
                        Int64   totalfloorCount = lstPRMBOQFloorDetail.Count;
                        Decimal avgQty          = pRMBOQDetailEntity.TotalQty / totalfloorCount;

                        foreach (PRMBOQFloorDetailEntity ent in lstPRMBOQFloorDetail)
                        {
                            String fe1 = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQFloorDetailEntity.FLD_NAME_BOQFloorDetailID, ent.BOQFloorDetailID.ToString(), SQLMatchType.Equal);
                            ent.Qty = avgQty;
                            FCCPRMBOQFloorDetail.GetFacadeCreate().Update(ent, fe1, DatabaseOperationType.Update, TransactionRequired.No);
                        }
                    }

                    #endregion

                    this.ModalPopupExtender1.Hide();
                }
            }
        }
Exemplo n.º 6
0
        protected void btnAddToProject_Click(object sender, EventArgs e)
        {
            if (ddlProjectID.Items.Count > 0 && ddlProjectID.SelectedValue != "0")
            {
                Int64 itemID = 0;
                if (ViewState["LastUpdatedItemID"] != null)
                {
                    itemID = (Int64)ViewState["LastUpdatedItemID"];
                }

                if (itemID > 0)
                {
                    String fe_itemDefault = SqlExpressionBuilder.PrepareFilterExpression(MDItemDefaultEntity.FLD_NAME_ItemID, itemID.ToString(), SQLMatchType.Equal);
                    IList <MDItemDefaultEntity> lstmDItemDefaultEntity = FCCMDItemDefault.GetFacadeCreate().GetIL(null, null, String.Empty, fe_itemDefault, DatabaseOperationType.LoadWithFilterExpression);

                    String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQEntity.FLD_NAME_ProjectID, ddlProjectID.SelectedValue.ToString(), SQLMatchType.Equal);
                    IList <PRMPreBOQEntity> preBOQList = FCCPRMPreBOQ.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression);

                    if (preBOQList != null && preBOQList.Count > 0)
                    {
                        Int64   preBOQID = preBOQList[0].PreBOQID;
                        Decimal totalQty = 0;
                        Decimal.TryParse(txtQty.Text.Trim().ToString(), out totalQty);
                        Decimal currentPrice = MiscUtil.GetCurrentPrice(itemID, lstmDItemDefaultEntity[0].BrandID, lstmDItemDefaultEntity[0].SupplierID, lstmDItemDefaultEntity[0].RegionID, lstmDItemDefaultEntity[0].CountryID);

                        switch (preBOQList[0].IsLocked)
                        {
                        case true:
                            #region Add Item to BOQ

                            try
                            {
                                String fe_boq = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQEntity.FLD_NAME_ProjectID, ddlProjectID.SelectedValue.ToString(), SQLMatchType.Equal);
                                IList <PRMBOQEntity> lstPRMBOQ = FCCPRMBOQ.GetFacadeCreate().GetIL(null, null, String.Empty, fe_boq, DatabaseOperationType.LoadWithFilterExpression);

                                if (lstPRMBOQ != null && lstPRMBOQ.Count > 0)
                                {
                                    PRMBOQDetailEntity pRMBOQDeatEntity = new PRMBOQDetailEntity();
                                    pRMBOQDeatEntity.BOQID      = lstPRMBOQ[0].BOQID;
                                    pRMBOQDeatEntity.ItemID     = itemID;
                                    pRMBOQDeatEntity.BrandID    = lstmDItemDefaultEntity[0].BrandID;
                                    pRMBOQDeatEntity.RegionID   = lstmDItemDefaultEntity[0].RegionID;
                                    pRMBOQDeatEntity.CountryID  = lstmDItemDefaultEntity[0].CountryID;
                                    pRMBOQDeatEntity.SupplierID = lstmDItemDefaultEntity[0].SupplierID;
                                    pRMBOQDeatEntity.Remarks    = "Directly Added From Item";
                                    pRMBOQDeatEntity.IsRemoved  = false;
                                    pRMBOQDeatEntity.Rate       = currentPrice;
                                    pRMBOQDeatEntity.EntryDate  = System.DateTime.Now;
                                    pRMBOQDeatEntity.TotalQty   = totalQty;

                                    Int64 result_boq = -1;

                                    result_boq = FCCPRMBOQDetail.GetFacadeCreate().Add(pRMBOQDeatEntity, DatabaseOperationType.Add, TransactionRequired.No);

                                    if (result_boq > 0)
                                    {
                                        PRMAvailableBOQQtyForRequisitionEntity pRMAvailableBOQQtyForRequisitionEntity = new PRMAvailableBOQQtyForRequisitionEntity();

                                        pRMAvailableBOQQtyForRequisitionEntity.IsBOQ = true;
                                        pRMAvailableBOQQtyForRequisitionEntity.PreBOQOrBOQDetailID = result_boq;
                                        pRMAvailableBOQQtyForRequisitionEntity.ItemID              = itemID;
                                        pRMAvailableBOQQtyForRequisitionEntity.Qty                 = totalQty;
                                        pRMAvailableBOQQtyForRequisitionEntity.CreateDate          = DateTime.Now;
                                        pRMAvailableBOQQtyForRequisitionEntity.CreatedByEmployeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember);
                                        pRMAvailableBOQQtyForRequisitionEntity.ProjectID           = Int64.Parse(ddlProjectID.SelectedValue);


                                        Int64 result_available = -1;
                                        result_available = FCCPRMAvailableBOQQtyForRequisition.GetFacadeCreate().Add(pRMAvailableBOQQtyForRequisitionEntity, DatabaseOperationType.Add, TransactionRequired.No);

                                        MiscUtil.ShowMessage(lblMessage, "Qty Added Successfully to Project Cost.", false);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                MiscUtil.ShowMessage(lblMessage, "Some Error Occured.", true);
                            }

                            #endregion

                            break;

                        case false:

                            #region Add Item to Pre-BOQ

                            try
                            {
                                String fe_preBOQ = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQEntity.FLD_NAME_ProjectID, ddlProjectID.SelectedValue.ToString(), SQLMatchType.Equal);
                                IList <PRMPreBOQEntity> lstPRMPreBOQ = FCCPRMPreBOQ.GetFacadeCreate().GetIL(null, null, String.Empty, fe_preBOQ, DatabaseOperationType.LoadWithFilterExpression);

                                if (lstPRMPreBOQ != null && lstPRMPreBOQ.Count > 0)
                                {
                                    PRMPreBOQDetailEntity pRMPreBOQDeatEntity = new PRMPreBOQDetailEntity();
                                    pRMPreBOQDeatEntity.PreBOQID   = lstPRMPreBOQ[0].PreBOQID;
                                    pRMPreBOQDeatEntity.ItemID     = itemID;
                                    pRMPreBOQDeatEntity.BrandID    = lstmDItemDefaultEntity[0].BrandID;
                                    pRMPreBOQDeatEntity.RegionID   = lstmDItemDefaultEntity[0].RegionID;
                                    pRMPreBOQDeatEntity.CountryID  = lstmDItemDefaultEntity[0].CountryID;
                                    pRMPreBOQDeatEntity.SupplierID = lstmDItemDefaultEntity[0].SupplierID;
                                    pRMPreBOQDeatEntity.TotalQty   = totalQty;
                                    pRMPreBOQDeatEntity.Remarks    = "Directly Added From Item";
                                    pRMPreBOQDeatEntity.IsRemoved  = false;
                                    pRMPreBOQDeatEntity.Rate       = currentPrice;
                                    pRMPreBOQDeatEntity.EntryDate  = System.DateTime.Now;

                                    Int64 result_preboq = -1;

                                    result_preboq = FCCPRMPreBOQDetail.GetFacadeCreate().Add(pRMPreBOQDeatEntity, DatabaseOperationType.Add, TransactionRequired.No);

                                    if (result_preboq > 0)
                                    {
                                        PRMAvailableBOQQtyForRequisitionEntity pRMAvailableBOQQtyForRequisitionEntity = new PRMAvailableBOQQtyForRequisitionEntity();

                                        pRMAvailableBOQQtyForRequisitionEntity.IsBOQ = false;
                                        pRMAvailableBOQQtyForRequisitionEntity.PreBOQOrBOQDetailID = result_preboq;
                                        pRMAvailableBOQQtyForRequisitionEntity.ItemID              = itemID;
                                        pRMAvailableBOQQtyForRequisitionEntity.Qty                 = totalQty;
                                        pRMAvailableBOQQtyForRequisitionEntity.CreateDate          = DateTime.Now;
                                        pRMAvailableBOQQtyForRequisitionEntity.CreatedByEmployeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember);
                                        pRMAvailableBOQQtyForRequisitionEntity.ProjectID           = Int64.Parse(ddlProjectID.SelectedValue);

                                        Int64 result_available = -1;
                                        result_available = FCCPRMAvailableBOQQtyForRequisition.GetFacadeCreate().Add(pRMAvailableBOQQtyForRequisitionEntity, DatabaseOperationType.Add, TransactionRequired.No);

                                        MiscUtil.ShowMessage(lblMessage, "Qty Added Successfully to BOQ.", false);
                                    }
                                }
                            }
                            catch (Exception)
                            {
                                MiscUtil.ShowMessage(lblMessage, "Some Error Occured.", true);
                            }

                            #endregion

                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }
        protected void lvPRMMaterialReceive_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 WorkOrderItemMapID;

            Int64.TryParse(e.CommandArgument.ToString(), out WorkOrderItemMapID);

            if (WorkOrderItemMapID > 0)
            {
                if (e.CommandName == "FloorWiseRateAndQty")
                {
                    CurrentWorkOrderItemIDPopup = WorkOrderItemMapID;

                    Label lblItemLV               = (Label)e.Item.FindControl("lblItemLV");
                    Label lblRequisitionIDLV      = (Label)e.Item.FindControl("lblRequisitionIDLV");
                    Label lblRequisitionItemIDLV  = (Label)e.Item.FindControl("lblRequisitionItemIDLV");
                    Label lblWorkOrderItemMapIDLV = (Label)e.Item.FindControl("lblWorkOrderItemMapIDLV");

                    Label lblProjectIDLV   = (Label)e.Item.FindControl("lblProjectIDLV");
                    Label lblWorkOrderIDLV = (Label)e.Item.FindControl("lblWorkOrderIDLV");

                    Int64 itemID;
                    Int64.TryParse(lblItemLV.Text.Trim(), out itemID);

                    String fe_floor = SqlExpressionBuilder.PrepareFilterExpression(BDProjectFloorEntity.FLD_NAME_ProjectID, lblProjectIDLV.Text.ToString(), SQLMatchType.Equal);
                    IList <BDProjectFloorEntity> lstBDProjectFloor = FCCBDProjectFloor.GetFacadeCreate().GetIL(null, null, String.Empty, fe_floor, DatabaseOperationType.LoadWithFilterExpression);

                    if (lstBDProjectFloor != null && lstBDProjectFloor.Count > 0)
                    {
                        String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQEntity.FLD_NAME_ProjectID, lblProjectIDLV.Text.ToString(), SQLMatchType.Equal);
                        IList <PRMPreBOQEntity> preBOQList = FCCPRMPreBOQ.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression);

                        if (preBOQList != null && preBOQList.Count > 0)
                        {
                            Int64 preBOQID = preBOQList[0].PreBOQID;

                            switch (preBOQList[0].IsLocked)
                            {
                            case true:

                                #region GET Item From BOQ

                                String fe_boq = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQEntity.FLD_NAME_PreBOQID, preBOQID.ToString(), SQLMatchType.Equal);
                                IList <PRMBOQEntity> lstPRMBOQ = FCCPRMBOQ.GetFacadeCreate().GetIL(null, null, String.Empty, fe_boq, DatabaseOperationType.LoadWithFilterExpression);

                                if (lstPRMBOQ != null && lstPRMBOQ.Count > 0)
                                {
                                    String fe_BOQDetail1 = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQDetailEntity.FLD_NAME_BOQID, lstPRMBOQ[0].BOQID.ToString(), SQLMatchType.Equal);
                                    String fe_BOQDetail2 = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQDetailEntity.FLD_NAME_ItemID, itemID.ToString(), SQLMatchType.Equal);

                                    String fe_BOQDetail = SqlExpressionBuilder.PrepareFilterExpression(fe_BOQDetail1, SQLJoinType.AND, fe_BOQDetail2);

                                    IList <PRMBOQDetailEntity> lstPRMBOQDetail = FCCPRMBOQDetail.GetFacadeCreate().GetIL(null, null, String.Empty, fe_BOQDetail, DatabaseOperationType.LoadWithFilterExpression);

                                    if (lstPRMBOQDetail != null && lstPRMBOQDetail.Count > 0)
                                    {
                                        String fe_floorDetail = SqlExpressionBuilder.PrepareFilterExpression("PRMBOQFloorDetail." + PRMBOQFloorDetailEntity.FLD_NAME_BOQDetailID, lstPRMBOQDetail[0].BOQDetailID.ToString(), SQLMatchType.Equal);
                                        IList <PRMBOQFloorDetail_DetailedEntity> lstPRMPreBOQFloorDetail = FCCPRMBOQFloorDetail_Detailed.GetFacadeCreate().GetIL(100000, 1, String.Empty, fe_floorDetail);

                                        lvREQRequisitionItemFloorDetail.DataSource = lstPRMPreBOQFloorDetail;
                                        lvREQRequisitionItemFloorDetail.DataBind();
                                    }
                                }

                                #endregion

                                break;

                            case false:

                                #region Get Item From Pre-BOQ

                                String fe_preBOQDetail1 = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQDetailEntity.FLD_NAME_PreBOQID, preBOQID.ToString(), SQLMatchType.Equal);
                                String fe_preBOQDetail2 = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQDetailEntity.FLD_NAME_ItemID, itemID.ToString(), SQLMatchType.Equal);

                                String fe_preBOQDetail = SqlExpressionBuilder.PrepareFilterExpression(fe_preBOQDetail1, SQLJoinType.AND, fe_preBOQDetail2);

                                IList <PRMPreBOQDetailEntity> lstPRMPreBOQDetail = FCCPRMPreBOQDetail.GetFacadeCreate().GetIL(null, null, String.Empty, fe_preBOQDetail, DatabaseOperationType.LoadWithFilterExpression);

                                if (lstPRMPreBOQDetail != null && lstPRMPreBOQDetail.Count > 0)
                                {
                                    String fe_floorDetail = SqlExpressionBuilder.PrepareFilterExpression("PRMPreBOQFloorDetail." + PRMPreBOQFloorDetailEntity.FLD_NAME_PreBOQDetailID, lstPRMPreBOQDetail[0].PreBOQDetailID.ToString(), SQLMatchType.Equal);
                                    IList <PRMPreBOQFloorDetail_DetailedEntity> lstPRMPreBOQFloorDetail = FCCPRMPreBOQFloorDetail_Detailed.GetFacadeCreate().GetIL(10000, 1, String.Empty, fe_floorDetail);

                                    lvREQRequisitionItemFloorDetail.DataSource = lstPRMPreBOQFloorDetail;
                                    lvREQRequisitionItemFloorDetail.DataBind();
                                }

                                #endregion

                                break;

                            default:
                                break;
                            }
                        }
                    }

                    Label lblItemNameLV = (Label)e.Item.FindControl("lblItemNameLV");

                    //BindREQRequisitionFloorDetailList();
                    //lblFloorWiseItemName.Text = lblItemNameLV.Text.ToString();
                    this.ModalPopupExtender2.Show();

                    if (lvREQRequisitionItemFloorDetail.DataSource != null)
                    {
                        btnFloorPopupSave.Enabled = true;
                    }
                    else
                    {
                        btnFloorPopupSave.Enabled = false;
                    }

                    if (CurrentPRMWorkOrderEntity.WorkOrderStatusID != MasterDataConstants.WorkOrderStatus.APPROVED)
                    {
                        lblLockMessage.Visible = false;
                    }

                    else if (CurrentPRMWorkOrderEntity.WorkOrderStatusID == MasterDataConstants.WorkOrderStatus.APPROVED)
                    {
                        btnFloorPopupSave.Enabled = false;
                        lblLockMessage.Visible    = true;
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void SaveBOQDetailInfo()
        {
            try
            {
                #region Getting the checked items from tree

                IList <PRMBOQDetailEntity> checkedItemsFromTree = new List <PRMBOQDetailEntity>();

                foreach (TreeNode tn in treeItem.CheckedNodes)
                {
                    PRMBOQDetailEntity ent = new PRMBOQDetailEntity();
                    ent.ItemID = Int64.Parse(tn.Value.ToString());

                    checkedItemsFromTree.Add(ent);
                }

                #endregion

                Int64 bOQID = 0;

                if (isNewEntry == true)
                {
                    bOQID = FCCPRMBOQ.GetFacadeCreate().Add(BuildPRMBOQEntity(), DatabaseOperationType.Add, TransactionRequired.No);
                }
                else
                {
                    bOQID = currentBOQ.BOQID;

                    String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQDetailEntity.FLD_NAME_BOQID, bOQID.ToString(), SQLMatchType.Equal);

                    //  FCCPRMPreBOQDetail.GetFacadeCreate().Delete(new PRMPreBOQDetailEntity(), fe, DatabaseOperationType.Delete, TransactionRequired.No);
                }


                #region Adding OLD

                //IList<PRMPreBOQDetailEntity> addListOfNotPopulatedItems = currentlyCheckedItems.Except(populatedItems, new CustomerComparer()).ToList();

                //StringBuilder xmlStr = new StringBuilder();
                //String subXmlStr = String.Empty;

                //xmlStr.Append("<m>");

                //foreach (PRMPreBOQDetailEntity ent in addListOfNotPopulatedItems)
                //{
                //    subXmlStr = subXmlStr + "<i><a>" + preBOQID + "</a><b>" + ent.ItemID + "</b></i>";
                //}

                //foreach (PRMPreBOQDetailEntity ent in checkedItemsFromTree)
                //{
                //    subXmlStr = subXmlStr + "<i><a>" + preBOQID + "</a><b>" + ent.ItemID + "</b></i>";
                //}

                //xmlStr.Append(subXmlStr.ToString());
                //xmlStr.Append("</m>");


                //FCCBulkInsertXML.GetFacadeCreate().GetIL(xmlStr.ToString(), CommonConstants.PreBOQDetailTableInfo);

                #endregion OLD

                #region Adding New

                IList <PRMBOQDetailEntity> addListOfNotPopulatedItems = currentlyCheckedItems.Except(populatedItems, new CustomerComparer()).ToList();

                IList <PRMBOQDetailEntity> completeAddList = new List <PRMBOQDetailEntity>();
                completeAddList = addListOfNotPopulatedItems;

                foreach (PRMBOQDetailEntity ent in checkedItemsFromTree)
                {
                    completeAddList.Add(ent);
                }

                IList <PRMBOQDetailEntity> finalAddList    = completeAddList.Except(mappedItemsFromDB, new CustomerComparer()).ToList();
                IList <PRMBOQDetailEntity> finalDeleteList = mappedItemsFromDB.Except(completeAddList, new CustomerComparer()).ToList();

                if (finalAddList != null && finalAddList.Count > 0)
                {
                    StringBuilder xmlStr    = new StringBuilder();
                    String        subXmlStr = String.Empty;
                    xmlStr.Append("<m>");

                    foreach (PRMBOQDetailEntity ent in finalAddList)
                    {
                        #region SET Item Rate and Qty

                        //GET Item Actual Price From Pre-BOQ or Set Zero

                        Decimal actualPrice = 0;
                        Decimal totalQty    = 0;
                        Int64   BrandID     = MasterDataConstants.ItemDefaults.DEFAULT_BRAD;
                        Int64   SupplierID  = MasterDataConstants.ItemDefaults.DEFAULT_SUPPLIER;
                        Int64   RegionID    = MasterDataConstants.ItemDefaults.DEFAULT_REGION;
                        Int64   CountryID   = MasterDataConstants.ItemDefaults.DEFAULT_COUNTRY;

                        IList <PRMBOQDetailEntity> _pRMBOQDeatilEntity = (from s in mappedItemsFromDB
                                                                          where s.ItemID == ent.ItemID
                                                                          select s).ToList();

                        if (_pRMBOQDeatilEntity != null && _pRMBOQDeatilEntity.Count > 0 && _pRMBOQDeatilEntity[0].TotalQty > 0)
                        {
                            Int64.TryParse(_pRMBOQDeatilEntity[0].BrandID.ToString(), out BrandID);
                            Int64.TryParse(_pRMBOQDeatilEntity[0].SupplierID.ToString(), out SupplierID);
                            Int64.TryParse(_pRMBOQDeatilEntity[0].RegionID.ToString(), out RegionID);
                            Int64.TryParse(_pRMBOQDeatilEntity[0].CountryID.ToString(), out CountryID);
                            Decimal.TryParse(_pRMBOQDeatilEntity[0].Rate.ToString(), out actualPrice);
                        }

                        else
                        {
                            #region SET Rate From Price Database

                            String fe = SqlExpressionBuilder.PrepareFilterExpression(MDItemDefaultEntity.FLD_NAME_ItemID, ent.ItemID.ToString(), SQLMatchType.Equal);
                            IList <MDItemDefaultEntity> itemDefaultList = FCCMDItemDefault.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression);

                            if (itemDefaultList != null && itemDefaultList.Count > 0)
                            {
                                Int64.TryParse(itemDefaultList[0].BrandID.ToString(), out BrandID);
                                Int64.TryParse(itemDefaultList[0].SupplierID.ToString(), out SupplierID);
                                Int64.TryParse(itemDefaultList[0].RegionID.ToString(), out RegionID);
                                Int64.TryParse(itemDefaultList[0].CountryID.ToString(), out CountryID);
                            }

                            var supplierItemMap = (from s in supplierItemMapList
                                                   where s.ItemID == ent.ItemID &&
                                                   s.BrandID == BrandID &&
                                                   s.SupplierID == SupplierID &&
                                                   s.OriginRegionID == RegionID &&
                                                   s.OriginCountryID == CountryID
                                                   select s).ToList();

                            if (supplierItemMap != null && supplierItemMap.Count > 0)
                            {
                                Decimal.TryParse(supplierItemMap[0].Price.ToString(), out actualPrice);
                            }

                            #endregion
                        }

                        if (_pRMBOQDeatilEntity != null && _pRMBOQDeatilEntity.Count > 0 && _pRMBOQDeatilEntity[0].Rate > 0)
                        {
                            Decimal.TryParse(_pRMBOQDeatilEntity[0].TotalQty.ToString(), out totalQty);
                        }

                        else
                        {
                            #region GET Qty From ThumbRule

                            String feThumbRule = SqlExpressionBuilder.PrepareFilterExpression(MDItemThumbRuleEntity.FLD_NAME_ItemID, ent.ItemID.ToString(), SQLMatchType.Equal);
                            IList <MDItemThumbRuleEntity> itemThumbRuleList = FCCMDItemThumbRule.GetFacadeCreate().GetIL(null, null, String.Empty, feThumbRule, DatabaseOperationType.LoadWithFilterExpression);

                            if (itemThumbRuleList != null && itemThumbRuleList.Count > 0)
                            {
                                totalQty += itemThumbRuleList[0].FloorQuantity * itemThumbRuleList[0].FloorRuleVariable * this.OverviewProject.LandAreaSft.Value * this.OverviewProject.NoOfStoried.Value;
                                totalQty += itemThumbRuleList[0].BasementQuantity * itemThumbRuleList[0].BasementRuleVariable * this.OverviewProject.LandAreaSft.Value * this.OverviewProject.NoOfBasement.Value;
                                totalQty += itemThumbRuleList[0].OverallQuantity * itemThumbRuleList[0].OverallRuleVariable * this.OverviewProject.LandAreaSft.Value;
                            }

                            #endregion
                        }


                        #endregion

                        subXmlStr = subXmlStr + "<i><a>" + bOQID + "</a><b>" + ent.ItemID + "</b><c>" + actualPrice + "</c><d>" + totalQty + "</d><e>" + String.Empty + "</e><f>" + MiscUtil.ParseToDateTime(DateTime.Now.ToStringDefault()) + "</f><g>" + BrandID + "</g><j>" + SupplierID + "</j><k>" + RegionID + "</k><l>" + CountryID + "</l></i>";
                    }
                    xmlStr.Append(subXmlStr.ToString());
                    xmlStr.Append("</m>");

                    FCCBulkInsertXML.GetFacadeCreate().GetIL(xmlStr.ToString(), CommonConstants.BOQDetailTableInfo);
                }
                #endregion New

                #region DeleteFromDB New

                if (finalDeleteList != null && finalDeleteList.Count > 0)
                {
                    foreach (PRMBOQDetailEntity ent in finalDeleteList)
                    {
                        String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQDetailEntity.FLD_NAME_BOQDetailID, ent.BOQDetailID.ToString(), SQLMatchType.Equal);
                        FCCPRMBOQDetail.GetFacadeCreate().Delete(new PRMBOQDetailEntity(), fe, DatabaseOperationType.Delete, TransactionRequired.No);
                    }
                }

                #endregion DeleteFromDB New



                //else
                //{


                //    IList<PRMPreBOQDetailEntity> temp_currentlyCheckedItems = currentlyCheckedItems.Except(populatedItems, new CustomerComparer()).ToList();
                //    IList<PRMPreBOQDetailEntity> temp_mappedItemsFromDB = mappedItemsFromDB.Except(populatedItems, new CustomerComparer()).ToList();

                //    IList<PRMPreBOQDetailEntity> al = temp_currentlyCheckedItems.Except(temp_mappedItemsFromDB, new CustomerComparer()).ToList();
                //    IList<PRMPreBOQDetailEntity> dl = temp_mappedItemsFromDB.Except(temp_currentlyCheckedItems, new CustomerComparer()).ToList();


                //    IList<PRMPreBOQDetailEntity> new_al = checkedItemsFromTree.Except(populatedCheckedItems, new CustomerComparer()).ToList();
                //    IList<PRMPreBOQDetailEntity> new_dl = populatedCheckedItems.Except(checkedItemsFromTree, new CustomerComparer()).ToList();

                //    #region Deleting

                //    foreach (PRMPreBOQDetailEntity ent in new_dl)
                //    {
                //        String fe1 = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQDetailEntity.FLD_NAME_PreBOQID, preBOQID.ToString(), SQLMatchType.Equal);
                //        String fe2 = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQDetailEntity.FLD_NAME_ItemID, ent.ItemID.ToString(), SQLMatchType.Equal);
                //        String fe = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2);
                //        FCCPRMPreBOQDetail.GetFacadeCreate().Delete(ent, fe, DatabaseOperationType.Delete, TransactionRequired.No);
                //    }

                //    foreach (PRMPreBOQDetailEntity ent in dl)
                //    {
                //        String fe1 = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQDetailEntity.FLD_NAME_PreBOQID, preBOQID.ToString(), SQLMatchType.Equal);
                //        String fe2 = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQDetailEntity.FLD_NAME_ItemID, ent.ItemID.ToString(), SQLMatchType.Equal);
                //        String fe = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2);
                //        FCCPRMPreBOQDetail.GetFacadeCreate().Delete(ent, fe, DatabaseOperationType.Delete, TransactionRequired.No);
                //    }

                //    #endregion

                //    #region Adding

                //    StringBuilder xmlStr = new StringBuilder();
                //    String subXmlStr = String.Empty;

                //    xmlStr.Append("<m>");

                //    foreach (PRMPreBOQDetailEntity ent in new_al)
                //    {
                //        subXmlStr = subXmlStr + "<i><a>" + preBOQID + "</a><b>" + ent.ItemID + "</b></i>";
                //    }

                //    foreach (PRMPreBOQDetailEntity ent in al)
                //    {
                //        subXmlStr = subXmlStr + "<i><a>" + preBOQID + "</a><b>" + ent.ItemID + "</b></i>";
                //    }

                //    xmlStr.Append(subXmlStr.ToString());
                //    xmlStr.Append("</m>");


                //    FCCBulkInsertXML.GetFacadeCreate().GetIL(xmlStr.ToString(), CommonConstants.PreBOQDetailTableInfo);

                //    #endregion
                //}

                treeItem.ReBuildTree();
                PrepareFormView();

                MiscUtil.ShowMessage(lblMessage, "Project Cost Setup Updated Successfully.", false);
            }
            catch (Exception ex)
            {
                MiscUtil.ShowMessage(lblMessage, "An Error Occoured.", true);
            }
        }
Exemplo n.º 9
0
        private void PrepareFormView()
        {
            populatedItems        = new List <PRMBOQDetailEntity>();
            populatedCheckedItems = new List <PRMBOQDetailEntity>();

            BuildDropDownList();

            #region New or Update mode decission making

            String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQEntity.FLD_NAME_ProjectID, this.OverviewProjectID.ToString(), SQLMatchType.Equal);

            IList <PRMBOQEntity> lst = FCCPRMBOQ.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression);

            if (lst != null && lst.Count > 0)
            {
                isNewEntry = false;
                currentBOQ = lst[0];
            }
            else
            {
                isNewEntry = true;
                currentBOQ = null;
            }

            #endregion

            currentlyCheckedItems = new List <PRMBOQDetailEntity>();
            mappedItemsFromDB     = new List <PRMBOQDetailEntity>();

            #region Determine Current Mapped & Checked Items

            if (isNewEntry == true)
            {
                IList <MDItemEntity> itemList = FCCMDItem.GetFacadeCreate().GetILFC();

                if (itemList != null && itemList.Count > 0)
                {
                    foreach (MDItemEntity item in itemList)
                    {
                        PRMBOQDetailEntity ent = new PRMBOQDetailEntity();

                        ent.ItemID = item.ItemID;

                        currentlyCheckedItems.Add(ent);
                    }
                }
            }
            else
            {
                String fe_PreBOQDetail = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQDetailEntity.FLD_NAME_BOQID, currentBOQ.BOQID.ToString(), SQLMatchType.Equal);

                mappedItemsFromDB = FCCPRMBOQDetail.GetFacadeCreate().GetIL(null, null, String.Empty, fe_PreBOQDetail, DatabaseOperationType.LoadWithFilterExpression);

                if (mappedItemsFromDB == null)
                {
                    mappedItemsFromDB = new List <PRMBOQDetailEntity>();
                }

                currentlyCheckedItems = mappedItemsFromDB;
            }

            #endregion
        }