Example #1
0
        public IList <MDItemDefaultEntity> GetPagedData(Int32 startRowIndex, Int32 pageSize, String sortExpression)
        {
            IList <MDItemDefaultEntity> mDItemDefaultEntityList = new List <MDItemDefaultEntity>();

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

                if (String.IsNullOrEmpty(sortExpression))
                {
                    sortExpression = MDItemDefaultEntity.FLD_NAME_ItemDefaultID + " " + SQLConstants.SORT_ORDER_DESCENDING;
                }

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

                mDItemDefaultEntityList = FCCMDItemDefault.GetFacadeCreate().GetIL(startRowIndex, pageSize, sortExpression, null, DatabaseOperationType.LoadPagedWithSortExpression);

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

            return(mDItemDefaultEntityList ?? new List <MDItemDefaultEntity>());
        }
        private void SaveMDItemDefaultEntity()
        {
            if (IsValid)
            {
                try
                {
                    MDItemDefaultEntity mDItemDefaultEntity = BuildMDItemDefaultEntity();

                    Int64 result = -1;

                    if (mDItemDefaultEntity.IsNew)
                    {
                        result = FCCMDItemDefault.GetFacadeCreate().Add(mDItemDefaultEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDItemDefaultEntity.FLD_NAME_ItemDefaultID, mDItemDefaultEntity.ItemDefaultID.ToString(), SQLMatchType.Equal);
                        result = FCCMDItemDefault.GetFacadeCreate().Update(mDItemDefaultEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _ItemDefaultID       = 0;
                        _MDItemDefaultEntity = new MDItemDefaultEntity();
                        PrepareInitialView();
                        BindMDItemDefaultList();

                        if (mDItemDefaultEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Item Default Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Item Default Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (mDItemDefaultEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Item Default Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Item Default Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
        protected void lvMDItemDefault_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 ItemDefaultID;

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

            if (ItemDefaultID > 0)
            {
                if (string.Equals(e.CommandName, "EditItem"))
                {
                    _ItemDefaultID = ItemDefaultID;

                    PrepareEditView();

                    cpeEditor.Collapsed   = false;
                    cpeEditor.ClientState = "false";
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(MDItemDefaultEntity.FLD_NAME_ItemDefaultID, ItemDefaultID.ToString(), SQLMatchType.Equal);

                        MDItemDefaultEntity mDItemDefaultEntity = new MDItemDefaultEntity();


                        result = FCCMDItemDefault.GetFacadeCreate().Delete(mDItemDefaultEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _ItemDefaultID       = 0;
                            _MDItemDefaultEntity = new MDItemDefaultEntity();
                            PrepareInitialView();
                            BindMDItemDefaultList();

                            MiscUtil.ShowMessage(lblMessage, "Item Default has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Item Default.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
Example #4
0
        public IList <MDItemDefaultEntity> GetData()
        {
            IList <MDItemDefaultEntity> mDItemDefaultEntityList = new List <MDItemDefaultEntity>();

            try
            {
                mDItemDefaultEntityList = FCCMDItemDefault.GetFacadeCreate().GetIL(null, null, null, null, DatabaseOperationType.Load);

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

            return(mDItemDefaultEntityList ?? new List <MDItemDefaultEntity>());
        }
Example #5
0
        private void DeleteItem()
        {
            Int64 ItemID;

            Int64.TryParse(treeItem.SelectedValue, out ItemID);

            if (ItemID > 0)
            {
                try
                {
                    Int64 result = -1;

                    String fe = SqlExpressionBuilder.PrepareFilterExpression(MDItemEntity.FLD_NAME_ItemID, ItemID.ToString(), SQLMatchType.Equal);

                    MDItemEntity mDItemEntity = new MDItemEntity();

                    #region Item Brand Map

                    String fe1 = SqlExpressionBuilder.PrepareFilterExpression(PRMItemBrandMapEntity.FLD_NAME_ItemID, ItemID.ToString(), SQLMatchType.Equal);
                    PRMItemBrandMapEntity prmItemBrandMap = new PRMItemBrandMapEntity();
                    FCCPRMItemBrandMap.GetFacadeCreate().Delete(prmItemBrandMap, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                    #endregion

                    #region Item Default

                    String fe2 = SqlExpressionBuilder.PrepareFilterExpression(MDItemDefaultEntity.FLD_NAME_ItemID, ItemID.ToString(), SQLMatchType.Equal);
                    MDItemDefaultEntity mDItemDefaultEntity = new MDItemDefaultEntity();
                    FCCMDItemDefault.GetFacadeCreate().Delete(mDItemDefaultEntity, fe2, DatabaseOperationType.Delete, TransactionRequired.No);

                    #endregion

                    #region Item Thumb Rule

                    String fe3 = SqlExpressionBuilder.PrepareFilterExpression(MDItemThumbRuleEntity.FLD_NAME_ItemID, ItemID.ToString(), SQLMatchType.Equal);
                    MDItemThumbRuleEntity mDItemThumbRuleEntity = new MDItemThumbRuleEntity();
                    result = FCCMDItemThumbRule.GetFacadeCreate().Delete(mDItemThumbRuleEntity, fe3, DatabaseOperationType.Delete, TransactionRequired.No);

                    #endregion

                    result = FCCMDItem.GetFacadeCreate().Delete(mDItemEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                    if (result == 0)
                    {
                        _ItemID       = 0;
                        _MDItemEntity = new MDItemEntity();

                        // clearing cache
                        FCCMDItem.GetFacadeCreate().RemoveCache();

                        PrepareInitialView();

                        LoadTreeView();

                        MiscUtil.ShowMessage(lblMessage, "Item has been successfully deleted.", true);
                    }
                    else
                    {
                        MiscUtil.ShowMessage(lblMessage, "Failed to delete Item.", true);
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Example #6
0
        private void SaveMDItemEntity()
        {
            if (IsValid)
            {
                try
                {
                    Boolean addInputValidation = true;

                    MDItemEntity mDItemEntity = BuildMDItemEntity();

                    Int64 result = -1;

                    if (mDItemEntity.IsNew)
                    {
                        if (ValidateInput())
                        {
                            if (treeItem.SelectedNode != null)
                            {
                                mDItemEntity.ItemCategoryID = Int64.Parse(treeItem.SelectedValue);
                            }

                            result = FCCMDItem.GetFacadeCreate().Add(mDItemEntity, DatabaseOperationType.Add, TransactionRequired.No);
                        }
                        else
                        {
                            addInputValidation = false;
                        }
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDItemEntity.FLD_NAME_ItemID, mDItemEntity.ItemID.ToString(), SQLMatchType.Equal);
                        result = FCCMDItem.GetFacadeCreate().Update(mDItemEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (addInputValidation == true)
                    {
                        if (result > 0)
                        {
                            #region Item Brand Map

                            ViewState["LastUpdatedItemID"] = result;

                            try
                            {
                                IList <PRMItemBrandMapEntity> newMappedItems = new List <PRMItemBrandMapEntity>();

                                foreach (ListItem chbxItem in chbxItemBrand.Items)
                                {
                                    if (chbxItem.Selected)
                                    {
                                        PRMItemBrandMapEntity mDItemBrandMapEntity = new PRMItemBrandMapEntity();
                                        mDItemBrandMapEntity.ItemID  = result;
                                        mDItemBrandMapEntity.BrandID = Int64.Parse(chbxItem.Value.ToString());
                                        newMappedItems.Add(mDItemBrandMapEntity);
                                    }
                                }

                                IList <PRMItemBrandMapEntity> deleteList = _CurrentItemBrandMapList.Except(newMappedItems, new CustomerComparer()).ToList();
                                IList <PRMItemBrandMapEntity> addNewList = newMappedItems.Except(_CurrentItemBrandMapList, new CustomerComparer()).ToList();

                                if (deleteList != null && deleteList.Count > 0)
                                {
                                    foreach (PRMItemBrandMapEntity ent in deleteList)
                                    {
                                        String fe1 = SqlExpressionBuilder.PrepareFilterExpression(PRMItemBrandMapEntity.FLD_NAME_ItemID, ent.ItemID.ToString(), SQLMatchType.Equal);
                                        String fe2 = SqlExpressionBuilder.PrepareFilterExpression(PRMItemBrandMapEntity.FLD_NAME_BrandID, ent.BrandID.ToString(), SQLMatchType.Equal);
                                        String fe  = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2);

                                        FCCPRMItemBrandMap.GetFacadeCreate().Delete(ent, fe, DatabaseOperationType.Delete, TransactionRequired.No);
                                    }
                                }

                                if (addNewList != null && addNewList.Count > 0)
                                {
                                    foreach (PRMItemBrandMapEntity ent in addNewList)
                                    {
                                        FCCPRMItemBrandMap.GetFacadeCreate().Add(ent, DatabaseOperationType.Add, TransactionRequired.No);
                                    }
                                }

                                String feCurrent = SqlExpressionBuilder.PrepareFilterExpression(PRMItemBrandMapEntity.FLD_NAME_ItemID, result.ToString(), SQLMatchType.Equal);
                                IList <PRMItemBrandMapEntity> ItemBrandList = FCCPRMItemBrandMap.GetFacadeCreate().GetIL(null, null, String.Empty, feCurrent, DatabaseOperationType.LoadWithFilterExpression);
                                _CurrentItemBrandMapList = ItemBrandList;

                                if (ddlBrandID.Items.Count > 0 && ddlBrandID.SelectedValue != MasterDataConstants.ItemDefaults.DEFAULT_BRAD.ToString())
                                {
                                    Boolean isNeedToInsert = false;

                                    if (ItemBrandList != null && ItemBrandList.Count > 0)
                                    {
                                        PRMItemBrandMapEntity itemBrandInfo = (from s in ItemBrandList
                                                                               where s.BrandID.ToString() == ddlBrandID.SelectedValue
                                                                               select s).FirstOrDefault();
                                        if (itemBrandInfo == null)
                                        {
                                            isNeedToInsert = true;
                                        }
                                    }
                                    else
                                    {
                                        isNeedToInsert = true;
                                    }

                                    if (isNeedToInsert)
                                    {
                                        PRMItemBrandMapEntity pRMItemBrandMapEntity = new PRMItemBrandMapEntity();
                                        pRMItemBrandMapEntity.BrandID = Int64.Parse(ddlBrandID.SelectedValue);
                                        pRMItemBrandMapEntity.ItemID  = result;

                                        FCCPRMItemBrandMap.GetFacadeCreate().Add(pRMItemBrandMapEntity, DatabaseOperationType.Add, TransactionRequired.No);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                            }


                            #endregion

                            #region Item Defaults

                            MDItemDefaultEntity mDItemDefaultEntity = BuildMDItemDefaultEntity();

                            mDItemDefaultEntity.ItemID = result;

                            if (mDItemDefaultEntity.IsNew)
                            {
                                FCCMDItemDefault.GetFacadeCreate().Add(mDItemDefaultEntity, DatabaseOperationType.Add, TransactionRequired.No);
                            }
                            else
                            {
                                String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDItemDefaultEntity.FLD_NAME_ItemDefaultID, mDItemDefaultEntity.ItemDefaultID.ToString(), SQLMatchType.Equal);
                                FCCMDItemDefault.GetFacadeCreate().Update(mDItemDefaultEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                            }

                            #endregion

                            //#region Item Thumb Rule

                            //MDItemThumbRuleEntity mDItemThumbRuleEntity = BuildMDItemThumbRuleEntity();

                            //mDItemThumbRuleEntity.ItemID = result;

                            //if (mDItemThumbRuleEntity.IsNew)
                            //{
                            //    result = FCCMDItemThumbRule.GetFacadeCreate().Add(mDItemThumbRuleEntity, DatabaseOperationType.Add, TransactionRequired.No);
                            //}
                            //else
                            //{
                            //    String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDItemThumbRuleEntity.FLD_NAME_MDItemThumbRuleID, mDItemThumbRuleEntity.MDItemThumbRuleID.ToString(), SQLMatchType.Equal);
                            //    result = FCCMDItemThumbRule.GetFacadeCreate().Update(mDItemThumbRuleEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                            //}

                            //#endregion

                            //if (mDItemEntity.IsNew)
                            //{
                            //    if (Roles.IsUserInRole(this.Page.User.Identity.Name, "Admin") == true || Roles.IsUserInRole(this.Page.User.Identity.Name, "Engineer") || Roles.IsUserInRole(this.Page.User.Identity.Name, "MIS") == true)
                            //    {
                            //        lblItemName.Text = mDItemEntity.ItemName.ToString();
                            //        this.Panel2_ModalPopupExtender.Show();
                            //    }
                            //}

                            _ItemID       = 0;
                            _MDItemEntity = new MDItemEntity();

                            // clearing cache
                            FCCMDItem.GetFacadeCreate().RemoveCache();

                            PrepareInitialView();

                            LoadTreeView();

                            if (mDItemEntity.IsNew)
                            {
                                MiscUtil.ShowMessage(lblMessage, "Item Information has been added successfully.", false);
                            }
                            else
                            {
                                MiscUtil.ShowMessage(lblMessage, "Item Information has been updated successfully.", false);
                            }
                        }
                        else
                        {
                            if (mDItemEntity.IsNew)
                            {
                                MiscUtil.ShowMessage(lblMessage, "Failed to add Item Information.", false);
                            }
                            else
                            {
                                MiscUtil.ShowMessage(lblMessage, "Failed to update Item Information.", false);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Example #7
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;
                        }
                    }
                }
            }
        }
Example #8
0
        private void SavePreBOQDetailInfo()
        {
            try
            {
                #region Getting the checked items from tree

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

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

                    checkedItemsFromTree.Add(ent);
                }

                #endregion

                Int64 preBOQID = 0;

                if (isNewEntry == true)
                {
                    preBOQID = FCCPRMPreBOQ.GetFacadeCreate().Add(BuildPRMPreBOQEntity(), DatabaseOperationType.Add, TransactionRequired.No);
                }
                else
                {
                    preBOQID = currentPreBOQ.PreBOQID;

                    String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQDetailEntity.FLD_NAME_PreBOQID, preBOQID.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 <PRMPreBOQDetailEntity> addListOfNotPopulatedItems = currentlyCheckedItems.Except(populatedItems, new CustomerComparer()).ToList();

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

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

                IList <PRMPreBOQDetailEntity> finalAddList    = completeAddList.Except(mappedItemsFromDB, new CustomerComparer()).ToList();
                IList <PRMPreBOQDetailEntity> 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 (PRMPreBOQDetailEntity ent in finalAddList)
                    {
                        #region SET Item Rate and Qty OLD

                        #region Get and Assign Item Price
                        ////Collect Item Actual Price with Default Brand, Vendor, Region, Country ID.
                        //Decimal ActualPrice=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;

                        //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

                        #region Thumb Rules
                        ////Collect Total Qty From Thumb Rules
                        //Decimal totalQty = 0;

                        //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

                        #region SET Item Rate and Qty

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

                        Decimal actualPrice = 0;
                        Decimal totalQty    = 0;

                        Boolean importPriceFlag = false, importQtyFlag = false;

                        foreach (ListItem chbxItem in chbxImportInfoList.Items)
                        {
                            if (chbxItem.Selected == true && chbxItem.Text == CommonConstants.IMPORT_RATE_INFO)
                            {
                                importPriceFlag = true;
                            }

                            if (chbxItem.Selected == true && chbxItem.Text == CommonConstants.IMPORT_QTY_INFO)
                            {
                                importQtyFlag = true;
                            }
                        }
                        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 <PRMPreBOQDetailEntity> _pRMPreBOQDeatilEntity = (from s in mappedItemsFromDB
                                                                                where s.ItemID == ent.ItemID
                                                                                select s).ToList();
                        if (importPriceFlag)
                        {
                            if (_pRMPreBOQDeatilEntity != null && _pRMPreBOQDeatilEntity.Count > 0 && _pRMPreBOQDeatilEntity[0].Rate > 0)
                            {
                                Int64.TryParse(_pRMPreBOQDeatilEntity[0].BrandID.ToString(), out BrandID);
                                Int64.TryParse(_pRMPreBOQDeatilEntity[0].SupplierID.ToString(), out SupplierID);
                                Int64.TryParse(_pRMPreBOQDeatilEntity[0].RegionID.ToString(), out RegionID);
                                Int64.TryParse(_pRMPreBOQDeatilEntity[0].CountryID.ToString(), out CountryID);
                                Decimal.TryParse(_pRMPreBOQDeatilEntity[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 (importQtyFlag)
                        {
                            if (_pRMPreBOQDeatilEntity != null && _pRMPreBOQDeatilEntity.Count > 0 && _pRMPreBOQDeatilEntity[0].TotalQty > 0)
                            {
                                Decimal.TryParse(_pRMPreBOQDeatilEntity[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>" + preBOQID + "</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.PreBOQDetailTableInfo);
                }
                #endregion New

                #region DeleteFromDB New

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

                #endregion DeleteFromDB New


                #region Backup

                //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
                //}

                #endregion

                treeItem.ReBuildTree();
                PrepareFormView();

                MiscUtil.ShowMessage(lblMessage, "BOQ Setup Updated Successfully.", false);
            }
            catch (Exception ex)
            {
                MiscUtil.ShowMessage(lblMessage, "An Error Occoured.", true);
            }
        }