Exemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                StringBuilder xmlStr = new StringBuilder();

                Int64  employeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember);
                String ip         = MiscUtil.GetLocalIP();

                Int64 projectID = 0;

                if (ddlProjectID != null && ddlProjectID.SelectedValue != "0")
                {
                    projectID = Int64.Parse(ddlProjectID.SelectedValue);
                }

                xmlStr.Append("<m>");

                foreach (TreeNode tn in treeTask.CheckedNodes)
                {
                    String subXmlStr = null;
                    subXmlStr = subXmlStr + "<i><a>" + tn.Text + "</a><b>" + employeeID + "</b><c>" + ddlAssignedToEmployeeID.SelectedValue + "</c><d>" + ip + "</d><e>" + CurrentMember.MemberID + "</e><f>" + projectID + "</f></i>";
                    xmlStr.Append(subXmlStr.ToString());
                }
                xmlStr.Append("</m>");

                FCCBulkInsertXML.GetFacadeCreate().GetIL(xmlStr.ToString(), CommonConstants.TaskTemplateInfo);

                MiscUtil.ShowMessage(lblMessage, "Task Template Item Map Save Successfully.", false);
            }
            catch (Exception ex)
            {
                MiscUtil.ShowMessage(lblMessage, "An Error Occoured.", true);
            }
        }
Exemplo n.º 2
0
        private void SaveREQRequisitionEntity()
        {
            if (IsValid)
            {
                try
                {
                    REQRequisitionEntity rEQRequisitionEntity = BuildREQRequisitionEntity();

                    Int64 result = -1;

                    if (rEQRequisitionEntity.IsNew)
                    {
                        //Prepared By ID Only for Save Operation; not for Update.
                        rEQRequisitionEntity.PreparedByMemberID = this.CurrentMember.MemberID;
                        result = FCCREQRequisition.GetFacadeCreate().Add(rEQRequisitionEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(REQRequisitionEntity.FLD_NAME_RequisitionID, rEQRequisitionEntity.RequisitionID.ToString(), SQLMatchType.Equal);
                        result = FCCREQRequisition.GetFacadeCreate().Update(rEQRequisitionEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }
                    BindRequisitionItemInfo();

                    IList <REQRequisitionItemEntity> deleteList = UpdatedMappedRequisitionItem.Except(REQRequisitionItemList, new CustomerComparer()).ToList();
                    IList <REQRequisitionItemEntity> addNewList = REQRequisitionItemList.Except(UpdatedMappedRequisitionItem, new CustomerComparer()).ToList();

                    foreach (REQRequisitionItemEntity ent in deleteList)
                    {
                        String fe1 = SqlExpressionBuilder.PrepareFilterExpression(REQRequisitionItemEntity.FLD_NAME_RequisitionID, ent.RequisitionID.ToString(), SQLMatchType.Equal);
                        String fe2 = SqlExpressionBuilder.PrepareFilterExpression(REQRequisitionItemEntity.FLD_NAME_ItemID, ent.ItemID.ToString(), SQLMatchType.Equal);
                        String fe  = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2);

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

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

                    xmlStr.Append("<m>");

                    foreach (REQRequisitionItemEntity ent in addNewList)
                    {
                        subXmlStr = subXmlStr + "<i><a>" + result + "</a><b>" + ent.AccountsCode + "</b><c>" + ent.ItemID + "</c><d>" + ent.TotalRequiredQty + "</d><e>" + ent.PurchasedQtyTillToDate + "</e><f>" + ent.PresentRequiredQty + "</f><g>" + ent.RequiredDate + "</g><h>" + ent.Remarks + "</h><j>" + ent.Rate + "</j></i>";
                    }
                    xmlStr.Append(subXmlStr.ToString());
                    xmlStr.Append("</m>");
                    FCCBulkInsertXML.GetFacadeCreate().GetIL(xmlStr.ToString(), CommonConstants.RequisitionItemInfo);

                    if (result > 0)
                    {
                        _RequisitionID        = 0;
                        _REQRequisitionEntity = new REQRequisitionEntity();
                        PrepareInitialView();
                        ClearAllRequisitionItem();

                        if (rEQRequisitionEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Requisition Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Requisition Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (rEQRequisitionEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Requisition Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Requisition Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Exemplo n.º 3
0
        private void SavePRMBOQTemplateItemMapEntity()
        {
            try
            {
                foreach (TreeNode catNode in treeItem.Nodes)
                {
                    PrepareCurrentlyPopulatedMappedItems(catNode);
                }

                foreach (TreeNode tn in treeItem.CheckedNodes)
                {
                    PRMBOQTemplateItemMapEntity ent = new PRMBOQTemplateItemMapEntity();
                    ent.ItemID        = Int64.Parse(tn.Value.ToString());
                    ent.BOQTemplateID = BOQTemplateID;
                    newMappedItems.Add(ent);
                }

                if (currentMappedItems.Count <= 0)
                {
                    IList <PRMBOQTemplateItemMapEntity> unCheckedList    = currentlyPopulatedMappedItems.Except(newMappedItems, new CustomerComparer()).ToList();
                    IList <PRMBOQTemplateItemMapEntity> templateItemList = new List <PRMBOQTemplateItemMapEntity>();
                    foreach (var v in temporaryMappedItems)
                    {
                        PRMBOQTemplateItemMapEntity ent = new PRMBOQTemplateItemMapEntity();
                        ent.ItemID        = v.ItemID;
                        ent.BOQTemplateID = BOQTemplateID;
                        templateItemList.Add(ent);
                    }
                    IList <PRMBOQTemplateItemMapEntity> addCheckedList = templateItemList.Except(unCheckedList, new CustomerComparerAnother()).ToList();
                    Int64 i = 0;

                    StringBuilder xmlStr = new StringBuilder();
                    xmlStr.Append("<m>");
                    String subXmlStr = null;

                    foreach (PRMBOQTemplateItemMapEntity ent in addCheckedList)
                    {
                        i++;
                        subXmlStr = subXmlStr + "<i><a>" + ent.BOQTemplateID + "</a><b>" + ent.ItemID + "</b><c>" + i + "</c></i>";
                    }
                    xmlStr.Append(subXmlStr.ToString());
                    xmlStr.Append("</m>");
                    FCCBulkInsertXML.GetFacadeCreate().GetIL(xmlStr.ToString(), CommonConstants.BOQItemMapTableInfo);
                }

                else if (currentMappedItems.Count > 0)
                {
                    currentlyPopulatedMappedItems = currentlyPopulatedMappedItems.Intersect(currentMappedItems, new CustomerComparer()).ToList();

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

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

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

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

                MiscUtil.ShowMessage(lblMessage, "Template Project Cost Item Map Updated Successfully.", false);
            }
            catch (Exception ex)
            {
                MiscUtil.ShowMessage(lblMessage, "An Error Occoured.", true);
            }
        }
        private void GenerateAll()
        {
            try
            {
                StringBuilder xmlStr             = new StringBuilder();
                Int64         employmentStatusID = 1;
                String        fe = SqlExpressionBuilder.PrepareFilterExpression("(HREmployeeSalaryInfo.SalaryAmount is not null and HREmployeeSalaryInfo.FiscalYearID = (Select FiscalYearID from ACFiscalYear where IsClosed = 0)) and HREmployee." + HREmployee_DetailedEntity.FLD_NAME_EmploymentStatusID, employmentStatusID.ToString(), SQLMatchType.Equal);

                if (ddlDepartmentID.SelectedValue == "1")
                {
                    String fe2 = "( HREmployee.DepartmentID is null or HREmployee.DepartmentID <> 20)";
                    fe = SqlExpressionBuilder.PrepareFilterExpression(fe, SQLJoinType.AND, fe2);
                }
                else
                {
                    String fe3 = "(HREmployee.DepartmentID = 20)";
                    fe = SqlExpressionBuilder.PrepareFilterExpression(fe, SQLJoinType.AND, fe3);
                }

                IList <HREmployee_DetailedEntity> list = FCCHREmployeeMonthlyTimeSheet_Detailed.GetFacadeCreate().GetIL(1000, 1, String.Empty, fe);
                xmlStr.Append("<m>");
                if (list != null && list.Count > 0)
                {
                    foreach (HREmployee_DetailedEntity hREmployee_DetailedEntity in list)
                    {
                        HREmployeeMonthlyTimeSheetSummaryEntity hREmployeeMonthlyTimeSheetSummaryEntity = new HREmployeeMonthlyTimeSheetSummaryEntity();

                        hREmployeeMonthlyTimeSheetSummaryEntity.LCASUAL       = 0;
                        hREmployeeMonthlyTimeSheetSummaryEntity.LMEDICAL      = 0;
                        hREmployeeMonthlyTimeSheetSummaryEntity.EARNLEAVE     = 0;
                        hREmployeeMonthlyTimeSheetSummaryEntity.LWP           = 0;
                        hREmployeeMonthlyTimeSheetSummaryEntity.REMARKS       = String.Empty;
                        hREmployeeMonthlyTimeSheetSummaryEntity.NUMBEROFMEALS = 0;
                        hREmployeeMonthlyTimeSheetSummaryEntity.PROJECTACTUAL = 0;
                        hREmployeeMonthlyTimeSheetSummaryEntity.OTHERLEAVE    = 0;
                        String remarks = String.Empty;

                        IList <HREmployeeDetailsForMonthlyTimeSheetSummary_CustomEntity> entList = FCCHREmployeeDetailsForMonthlyTimeSheetSummary_Custom.GetFacadeCreate().GetIL(Int64.Parse(ddlSalarySessionID.SelectedValue));
                        hREmployeeMonthlyTimeSheetSummaryEntity.OnJob          = entList[0].OnJob;
                        hREmployeeMonthlyTimeSheetSummaryEntity.Holiday        = (entList[0].Holiday - entList[0].LeaveDay);
                        hREmployeeMonthlyTimeSheetSummaryEntity.ACTUALWORKDAYS = ((hREmployeeMonthlyTimeSheetSummaryEntity.OnJob + hREmployeeMonthlyTimeSheetSummaryEntity.Holiday) - hREmployeeMonthlyTimeSheetSummaryEntity.LWP);

                        Int64   employeeID     = hREmployee_DetailedEntity.EmployeeID;
                        Decimal totalLeaveDays = 0;
                        Decimal casual         = 0;
                        Decimal medical        = 0;
                        Decimal earn           = 0;
                        Decimal lwp            = 0;

                        String fe1 = SqlExpressionBuilder.PrepareFilterExpression(" HREmployee." + HREmployee_DetailedEntity.FLD_NAME_EmployeeID, employeeID.ToString(), SQLMatchType.Equal);
                        String fe2 = SqlExpressionBuilder.PrepareFilterExpression(MDSalarySessionEntity.FLD_NAME_SalarySessionID, (Int64.Parse(ddlSalarySessionID.SelectedValue)).ToString(), SQLMatchType.Equal);
                        String fe3 = SqlExpressionBuilder.PrepareFilterExpression("HREmployeeLeaveApplication." + HREmployeeLeaveApplicationEntity.FLD_NAME_LeaveApplicationApplicationStatusID, MasterDataConstants.MDLeaveApplicatoinStatus.APPROVED.ToString(), SQLMatchType.Equal);
                        String f   = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2);
                        f = SqlExpressionBuilder.PrepareFilterExpression(f, SQLJoinType.AND, fe3);

                        IList <HREmployeeLeaveApplication_DetailedEntity> leaveList = FCCHREmployeeLeaveApplication_Detailed.GetFacadeCreate().GetIL(1000, 1, String.Empty, f);
                        if (leaveList != null && leaveList.Count > 0)
                        {
                            foreach (HREmployeeLeaveApplication_DetailedEntity entity in leaveList)
                            {
                                if (entity.LeaveCategoryID == MasterDataConstants.MDLeaveCategory.CASUAL)
                                {
                                    casual += leaveList[0].TotalLeaveDays;
                                }
                                else if (entity.LeaveCategoryID == MasterDataConstants.MDLeaveCategory.MEDICAL)
                                {
                                    medical += leaveList[0].TotalLeaveDays;
                                }
                                else if (entity.LeaveCategoryID == MasterDataConstants.MDLeaveCategory.EARN)
                                {
                                    earn += leaveList[0].TotalLeaveDays;
                                }
                                else if (entity.LeaveCategoryID == MasterDataConstants.MDLeaveCategory.LWP)
                                {
                                    lwp += leaveList[0].TotalLeaveDays;
                                }
                            }
                        }
                        if (lwp > 0)
                        {
                            remarks += lwp + " LWP " + (lwp * 6) + " Late. ";
                        }

                        totalLeaveDays = casual + medical + earn;

                        if (totalLeaveDays > 0)
                        {
                            remarks += totalLeaveDays.ToString().Trim() + " Leave.";
                        }
                        else
                        {
                            remarks += String.Empty;
                        }

                        hREmployeeMonthlyTimeSheetSummaryEntity.LCASUAL         = casual;
                        hREmployeeMonthlyTimeSheetSummaryEntity.LMEDICAL        = medical;
                        hREmployeeMonthlyTimeSheetSummaryEntity.EARNLEAVE       = earn;
                        hREmployeeMonthlyTimeSheetSummaryEntity.LWP             = lwp;
                        hREmployeeMonthlyTimeSheetSummaryEntity.ACTUALWORKDAYS  = (entList[0].ActualWorkingDay - lwp);
                        hREmployeeMonthlyTimeSheetSummaryEntity.REMARKS         = remarks;
                        hREmployeeMonthlyTimeSheetSummaryEntity.SalarySessionID = Int64.Parse(ddlSalarySessionID.SelectedValue);

                        #region Already Has this employee
                        Boolean isTrue = true;

                        String fe4 = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeMonthlyTimeSheetSummaryEntity.FLD_NAME_EmployeeID, employeeID.ToString(), SQLMatchType.Equal);
                        String fe5 = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeMonthlyTimeSheetSummaryEntity.FLD_NAME_SalarySessionID, (Int64.Parse(ddlSalarySessionID.SelectedValue)).ToString(), SQLMatchType.Equal);
                        String fe6 = SqlExpressionBuilder.PrepareFilterExpression(fe4, SQLJoinType.AND, fe5);
                        IList <HREmployeeMonthlyTimeSheetSummaryEntity> hREmployeeMonthlyTimeSheetSummarylist = FCCHREmployeeMonthlyTimeSheetSummary.GetFacadeCreate().GetIL(null, null, String.Empty, fe6, DatabaseOperationType.LoadWithFilterExpression);

                        if (hREmployeeMonthlyTimeSheetSummarylist != null && hREmployeeMonthlyTimeSheetSummarylist.Count > 0)
                        {
                            isTrue = false;
                        }

                        #endregion

                        if (isTrue)
                        {
                            String subXmlStr = null;
                            subXmlStr = subXmlStr + "<i><a>" + hREmployee_DetailedEntity.EmployeeID + "</a><b>" + hREmployee_DetailedEntity.DesignationID + "</b><c>" + hREmployee_DetailedEntity.EmployeeJobTypeID + "</c><d>" + hREmployee_DetailedEntity.SalaryLevel + "</d><e>" + hREmployeeMonthlyTimeSheetSummaryEntity.SalarySessionID + "</e><f>" + hREmployeeMonthlyTimeSheetSummaryEntity.OnJob + "</f><g>" + hREmployeeMonthlyTimeSheetSummaryEntity.Holiday + "</g><h>" + hREmployeeMonthlyTimeSheetSummaryEntity.LCASUAL + "</h><i1>" + hREmployeeMonthlyTimeSheetSummaryEntity.LMEDICAL + "</i1><j>" + hREmployeeMonthlyTimeSheetSummaryEntity.EARNLEAVE + "</j><k>" + hREmployeeMonthlyTimeSheetSummaryEntity.LWP + "</k><l>" + hREmployeeMonthlyTimeSheetSummaryEntity.ACTUALWORKDAYS + "</l><m>" + hREmployeeMonthlyTimeSheetSummaryEntity.REMARKS + "</m><n>" + hREmployeeMonthlyTimeSheetSummaryEntity.NUMBEROFMEALS + "</n><o>" + hREmployeeMonthlyTimeSheetSummaryEntity.PROJECTACTUAL + "</o><p>" + hREmployeeMonthlyTimeSheetSummaryEntity.OTHERLEAVE + "</p><q>" + hREmployee_DetailedEntity.DepartmentID + "</q></i>";
                            xmlStr.Append(subXmlStr.ToString());
                        }
                    }
                }
                xmlStr.Append("</m>");

                FCCBulkInsertXML.GetFacadeCreate().GetIL(xmlStr.ToString(), CommonConstants.HREmployeeMonthlyTimeSheetSummary);

                MiscUtil.ShowMessage(lblMessage, "Time Sheet Has been Generated Successfully.", false);
            }
            catch (Exception ex)
            {
                MiscUtil.ShowMessage(lblMessage, "An Error Occoured.", true);
            }
        }
Exemplo n.º 5
0
        private void SaveHREmployeeEntity()
        {
            if (IsValid)
            {
                try
                {
                    #region Member

                    HRMemberEntity hRMemberEntity = BuildHRMemberEntity();

                    Int64 result = -1;

                    if (hRMemberEntity.IsNew)
                    {
                        result = FCCHRMember.GetFacadeCreate().Add(hRMemberEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HRMemberEntity.FLD_NAME_MemberID, hRMemberEntity.MemberID.ToString(), SQLMatchType.Equal);
                        result = FCCHRMember.GetFacadeCreate().Update(hRMemberEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    #endregion

                    if (result > 0)
                    {
                        _MemberID       = 0;
                        _HRMemberEntity = new HRMemberEntity();
                    }

                    if (result > 0)
                    {
                        HREmployeeEntity hREmployeeEntity = BuildHREmployeeEntity();

                        Int64 resultC = -1;

                        if (hREmployeeEntity.IsNew)
                        {
                            hREmployeeEntity.MemberID = result;

                            resultC = FCCHREmployee.GetFacadeCreate().Add(hREmployeeEntity, DatabaseOperationType.Add, TransactionRequired.No);
                        }
                        else
                        {
                            String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeEntity.FLD_NAME_EmployeeID, hREmployeeEntity.EmployeeID.ToString(), SQLMatchType.Equal);
                            resultC = FCCHREmployee.GetFacadeCreate().Update(hREmployeeEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                        }

                        #region Create Six Task For HR

                        try
                        {
                            StringBuilder xmlStr      = new StringBuilder();
                            Int64         employeeID  = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember);
                            Int64         referenceID = 49;
                            DateTime      joinDate    = (DateTime)hREmployeeEntity.JoinDate;
                            String        fe          = "DepartmentID = " + MasterDataConstants.MDDepartment.HR_DEPARTMENTID + "";

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

                            #region Delete Old Task

                            String filter = "IssueIdentityCategoryID = " + MasterDataConstants.MDIssueIdentityCategory.HRMETTINGWITHEMPLOYEE + " and SupervisorEmployeeID = " + hREmployeeEntity.EmployeeID + "";
                            IList <OTIssueEntity> issueList = FCCOTIssue.GetFacadeCreate().GetIL(null, null, String.Empty, filter, DatabaseOperationType.LoadWithFilterExpression);
                            if (issueList != null && issueList.Count > 0)
                            {
                                OTIssueEntity oTIssueEntity = new OTIssueEntity();
                                FCCOTIssue.GetFacadeCreate().Delete(oTIssueEntity, filter, DatabaseOperationType.Delete, TransactionRequired.No);
                            }

                            #endregion

                            String title = "Employee Name: " + hRMemberEntity.FirstName + " " + hRMemberEntity.MiddleName + " " + hRMemberEntity.LastName + ", Code: " + hREmployeeEntity.EmployeeCode + " join Date: " + hREmployeeEntity.JoinDate + " has metting with you";

                            xmlStr.Append("<m>");
                            if (lst != null && lst.Count > 0)
                            {
                                foreach (HREmployeeEntity e in lst)
                                {
                                    for (int i = 1; i <= 6; i++)
                                    {
                                        String subXmlStr = null;
                                        subXmlStr = subXmlStr + "<i><a>" + title + "</a><b>" + hREmployeeEntity.EmployeeID + "</b><c>" + e.EmployeeID + "</c><d>" + CurrentMember.MemberID + "</d><e>" + referenceID + "</e><f>" + joinDate.AddDays(i * 30) + "</f><g>" + joinDate.AddDays((i * 30) + 1) + "</g></i>";
                                        xmlStr.Append(subXmlStr.ToString());
                                    }
                                }
                            }
                            xmlStr.Append("</m>");

                            FCCBulkInsertXML.GetFacadeCreate().GetIL(xmlStr.ToString(), CommonConstants.CreateSixTaskForHR);

                            MiscUtil.ShowMessage(lblMessage, "Six Task has created for HR Successfully.", false);
                        }
                        catch (Exception ex)
                        {
                            MiscUtil.ShowMessage(lblMessage, "An Error Occoured.", true);
                        }

                        #endregion

                        if (resultC > 0)
                        {
                            _EmployeeID       = 0;
                            _HREmployeeEntity = new HREmployeeEntity();
                            PrepareInitialView();
                            BindHREmployeeList();

                            if (hREmployeeEntity.IsNew)
                            {
                                ResourceEntity resourceEntity = new ResourceEntity();

                                resourceEntity.ReferenceID        = resultC; // means new employee id
                                resourceEntity.ResourceCategoryID = MasterDataConstants.ResourceCategory.EMPLOYEE;

                                FCCResource.GetFacadeCreate().Add(resourceEntity, DatabaseOperationType.Add, TransactionRequired.No);
                            }

                            if (hREmployeeEntity.IsNew)
                            {
                                MiscUtil.ShowMessage(lblMessage, "Employee Information has been added successfully.", false);
                            }
                            else
                            {
                                MiscUtil.ShowMessage(lblMessage, "Employee Information has been updated successfully.", false);
                            }
                        }
                        else
                        {
                            if (hREmployeeEntity.IsNew)
                            {
                                MiscUtil.ShowMessage(lblMessage, "Failed to add Employee Information.", false);
                            }
                            else
                            {
                                MiscUtil.ShowMessage(lblMessage, "Failed to update Employee Information.", false);
                            }
                        }
                    }
                    else
                    {
                        if (hRMemberEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Member Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Member Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Exemplo n.º 6
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);
            }
        }