Пример #1
0
        private void processActualConstructionCost(DataTable dtCostcontractProjectMapping, int batchid, DateTime asofdate)
        {
            string CCProjectGroupID = "";
            var    DT_CostcontractProjectMapping = (from DataRow dRow in dtCostcontractProjectMapping.Rows
                                                    select new
            {
                CCProjectCode = dRow["CCProjectCode"],
                CCProjectGroupCode = dRow["CCProjectGroupCode"],
                CCProjectGroupID = dRow["CCProjectGroupID"],
                LippoMasterProjectCode = dRow["LippoMasterProjectCode"],
                LippoMasterClusterCode = dRow["LippoMasterClusterCode"]
            }).Distinct().ToList();

            if (DT_CostcontractProjectMapping.Count > 0)
            {
                var SingleRow_DT_CostcontractProjectMapping = DT_CostcontractProjectMapping.FirstOrDefault();
                CCProjectGroupID = SingleRow_DT_CostcontractProjectMapping.CCProjectGroupID.ToString();
            }
            else
            {
                log.DebugFormat("var DT_CostcontractProjectMapping is empty.");
            }


            initDT_CostApportionmentDetail();
            CostContractWS.WS_CostAndContract CostContractWS = new LKReportingSystem.CostContractWS.WS_CostAndContract();
            _DT_CostApportionmentDetail = CostContractWS.RetreiveCostApportionmentBasedOnContract(CCProjectGroupID, asofdate).Tables[0];

            initDTFinal_CostContractDetail();

            string  CCProjectCode  = "";
            string  Header         = "";
            int     ProjectGroupID = 0;
            string  ProjectCode;
            string  WBSCode;
            string  WBSName;
            string  parentWBSCode;
            int     WBSLevel = 0;
            string  currCode;
            string  currRate;
            decimal ContractAmount = 0;
            decimal Apportionment  = 0;

            string DirectCostCategory = "DIRECTCOST";
            string DirectCostApportionmentCategory = "DIRECTCOSTWITHCOSTAPPORTIONMENT";

            decimal TotalActualValueDirectCost = 0;
            decimal TotalActualValueDirectCostApportionment = 0;

            //Adding new column
            _DT_CostContractProjectMapping.Columns.Add("BatchID", System.Type.GetType("System.Int32"));
            _DT_CostContractProjectMapping.Columns.Add("DirectCost", System.Type.GetType("System.Decimal"));
            _DT_CostContractProjectMapping.Columns.Add("DirectCostWithApportionment", System.Type.GetType("System.Decimal"));
            _DT_CostContractProjectMapping.Columns["BatchID"].SetOrdinal(0);

            //Looping project
            foreach (var x in DT_CostcontractProjectMapping)
            {
                CCProjectCode = x.CCProjectCode.ToString();

                TotalActualValueDirectCost = 0;
                TotalActualValueDirectCostApportionment = 0;

                var DT_CostApportionmentDetail = (from DataRow dRow in _DT_CostApportionmentDetail.Rows
                                                  where (dRow["ProjectCode"].ToString() == CCProjectCode.ToString())
                                                  select new
                {
                    Header = dRow["Header"],
                    ProjectGroupID = dRow["ProjectGroupID"],
                    ProjectCode = dRow["ProjectCode"],
                    WBSCode = dRow["WBSCode"],
                    WBSName = dRow["WBSName"],
                    parentWBSCode = dRow["parentWBSCode"],
                    WBSLevel = dRow["level"],
                    currCode = dRow["currCode"],
                    currRate = dRow["currRate"],
                    ContractAmount = dRow["ContractAmount"],
                    Apportionment = dRow["Apportionment"]
                }).Distinct().ToList();

                foreach (var v in DT_CostApportionmentDetail)
                {
                    Header         = v.Header.ToString().ToUpper();
                    ProjectGroupID = int.Parse(v.ProjectGroupID.ToString());
                    ProjectCode    = v.ProjectCode.ToString();
                    WBSCode        = v.WBSCode.ToString();
                    WBSName        = v.WBSName.ToString();
                    parentWBSCode  = v.parentWBSCode.ToString();
                    WBSLevel       = int.Parse(v.WBSLevel.ToString());
                    currCode       = v.currCode.ToString();
                    currRate       = v.currRate.ToString();
                    ContractAmount = decimal.Parse(v.ContractAmount.ToString());
                    Apportionment  = decimal.Parse(v.Apportionment.ToString());

                    if (Header == DirectCostCategory)
                    {
                        TotalActualValueDirectCost = TotalActualValueDirectCost + Apportionment;

                        _DTFinal_CostContractDetail.Rows.Add(batchid, ProjectGroupID, Header, ProjectCode, WBSCode, WBSName, parentWBSCode, WBSLevel, currCode, currRate, ContractAmount, Apportionment);
                    }
                    else if (Header == DirectCostApportionmentCategory)
                    {
                        TotalActualValueDirectCostApportionment = TotalActualValueDirectCostApportionment + Apportionment;

                        _DTFinal_CostContractDetail.Rows.Add(batchid, ProjectGroupID, Header, ProjectCode, WBSCode, WBSName, parentWBSCode, WBSLevel, currCode, currRate, ContractAmount, Apportionment);
                    }
                }

                //update nilai Cost Contract pada datatable
                DataRow oDr = _DT_CostContractProjectMapping.AsEnumerable().Where(r => ((string)r["CCProjectCode"]).Equals(CCProjectCode)).First();
                oDr["BatchID"]    = batchid;
                oDr["DirectCost"] = TotalActualValueDirectCost;
                oDr["DirectCostWithApportionment"] = TotalActualValueDirectCostApportionment;
            }
        }
Пример #2
0
        public bool RunGenerateReport()
        {
            log.DebugFormat("RunGenerateReport() - Start");
            bool result = true;

            try
            {
                for (int i = 0; i < dtProject.Rows.Count; i++)
                {
                    log.DebugFormat("RunGenerateReport() - Process {0}/{1} for Project {2}", i + 1, dtProject.Rows.Count, dtProject.Rows[i]["projectcode"].ToString());

                    string projectcode = dtProject.Rows[i]["projectcode"].ToString();

                    if (!CheckIsProjectInAllowed(projectcode))
                    {
                        log.DebugFormat("RunGenerateReport() - Process {0}/{1} Stopped because Project {2} is in exception.", i + 1, dtProject.Rows.Count, dtProject.Rows[i]["projectcode"].ToString());
                        continue;
                    }

                    string   sCluster = GetClusterFormattedString(projectcode);
                    DateTime asofDate = DateTime.Now;

                    if (string.IsNullOrEmpty(sCluster))
                    {
                        log.DebugFormat("RunGenerateReport() - Process {0}/{1} Failed. Cannot found Cluster for Project {2} ", i + 1, dtProject.Rows.Count, dtProject.Rows[i]["projectcode"].ToString());
                        continue;
                    }


                    int batchid = clsSalesSummary.GenerateSalesSummary(projectcode, sCluster, asofDate, "System Generated");

                    if (batchid != null)
                    {
                        log.DebugFormat("RunGenerateReport() - Process {0}/{1} for Project {2}. BatchID : {3}", i + 1, dtProject.Rows.Count, dtProject.Rows[i]["projectcode"].ToString(), batchid);

                        //update collection
                        initDTFinal_CollectionDetail();
                        _DTFinal_CollectionDetail = clsSalesSummary.GenerateScheduleCollection(projectcode, sCluster);
                        _DTFinal_CollectionDetail.Columns.Add("BatchID", System.Type.GetType("System.Int32"), batchid.ToString());
                        _DTFinal_CollectionDetail.Columns["BatchID"].SetOrdinal(0);

                        clsSalesSummary.InsertScheduleCollectionDetail(_DTFinal_CollectionDetail);


                        //update paidcomm
                        NewCommWS.NewComm_Services1 NewCommWS = new LKReportingSystem.NewCommWS.NewComm_Services1();
                        NewCommWS.Timeout = 600000;
                        decimal PaidComm   = 0;
                        decimal UnpaidComm = 0;
                        log.DebugFormat("NewComm Web Service Invoked.. Parameter sent: projectcode={0}", projectcode);
                        PaidComm   = NewCommWS.getCommPaid(projectcode);
                        UnpaidComm = NewCommWS.getCommUnprocessed(projectcode);


                        BudgetMktWS.WS_BudgetMarketing BudgetMktWS = new LKReportingSystem.BudgetMktWS.WS_BudgetMarketing();
                        BudgetMktWS.Timeout = 600000;

                        //update budgetmkt
                        decimal BudgetMKTExpense = 0;
                        log.DebugFormat("BudgetMkt Web Service [getBudgetMktActualExpense] Method Invoked.. Parameter sent: projectcode={0}", projectcode);
                        BudgetMKTExpense = BudgetMktWS.getBudgetMktActualExpense(projectcode);

                        //insert budgetmkt detail
                        initDTFinal_MktExpenseDetail();

                        log.DebugFormat("BudgetMkt Web Service [getBudgetMktActualExpenseDetail] Method Invoked.. Parameter sent: projectcode={0}", projectcode);
                        _DTFinal_MktExpenseDetail = Helper.ConvertXMLToDataset(BudgetMktWS.getBudgetMktActualExpenseDetail(projectcode)).Tables[0];
                        _DTFinal_MktExpenseDetail.Columns.Add("BatchID", System.Type.GetType("System.Int32"), batchid.ToString());
                        _DTFinal_MktExpenseDetail.Columns["BatchID"].SetOrdinal(0);

                        clsSalesSummary.InsertActualBudgetMktDetail(_DTFinal_MktExpenseDetail);


                        //actual Cost Contract
                        CostContractWS.WS_CostAndContract CostContractWS = new LKReportingSystem.CostContractWS.WS_CostAndContract();
                        CostContractWS.Timeout = 600000;
                        log.DebugFormat("CostContract Web Service [RetrieveProjectMapping] Method Invoked.. Parameter sent: projectcode={0}", projectcode);

                        initDT_CostContractProjectMapping();

                        if (CostContractWS.RetrieveProjectMapping(projectcode).Tables.Count != 0)
                        {
                            _DT_CostContractProjectMapping = CostContractWS.RetrieveProjectMapping(projectcode).Tables[0];

                            processActualConstructionCost(_DT_CostContractProjectMapping, batchid, asofDate);

                            clsSalesSummary.UpdateActualCost(_DT_CostContractProjectMapping, "System Generated");

                            clsSalesSummary.InsertActualCostContractDetail(_DTFinal_CostContractDetail);
                        }

                        clsSalesSummary.UpdateProjectByWsValue(batchid, PaidComm, UnpaidComm, BudgetMKTExpense);
                    }
                    else
                    {
                        log.DebugFormat("RunGenerateReport() - Failed to generate BatchId for project {0} and cluster {1}", projectcode, sCluster);
                    }
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat("RunGenerateReport() - {0}", ex.Message);
                result = false;
            }

            log.DebugFormat("RunGenerateReport() - End");
            return(result);
        }
Пример #3
0
        protected void btnGenerate_Click(object sender, EventArgs e)
        {
            try
            {
                string projectcode = ddlProject.SelectedValue.ToString();
                string clustercode = "";

                foreach (ListItem item in lbxCluster.Items)
                {
                    if (item.Selected)
                    {
                        clustercode += item.Value.ToString() + ",";
                    }
                }


                DateTime asofdate = DateTime.ParseExact(txtAsOfDate.Text + " " + DateTime.Now.ToString("hh:mm:ss"), "dd/MM/yyyy hh:mm:ss", System.Globalization.CultureInfo.InvariantCulture);

                int batchid = clsSalesSummary.GenerateSalesSummary(projectcode, clustercode, asofdate, "System Generated");

                if (batchid != null)
                {
                    //update collection
                    initDTFinal_CollectionDetail();
                    _DTFinal_CollectionDetail = clsSalesSummary.GenerateScheduleCollection(projectcode, clustercode);

                    _DTFinal_CollectionDetail.Columns.Add("BatchID", System.Type.GetType("System.Int32"), batchid.ToString());
                    _DTFinal_CollectionDetail.Columns["BatchID"].SetOrdinal(0);

                    clsSalesSummary.InsertScheduleCollectionDetail(_DTFinal_CollectionDetail);


                    //update paidcomm
                    NewCommWS.NewComm_Services1 NewCommWS = new LKReportingSystem.NewCommWS.NewComm_Services1();
                    NewCommWS.Timeout = 600000;
                    decimal PaidComm   = 0;
                    decimal UnpaidComm = 0;
                    log.DebugFormat("NewComm Web Service Invoked.. Parameter sent: projectcode={0}", projectcode);
                    PaidComm   = NewCommWS.getCommPaid(projectcode);
                    UnpaidComm = NewCommWS.getCommUnprocessed(projectcode);

                    BudgetMktWS.WS_BudgetMarketing BudgetMktWS = new LKReportingSystem.BudgetMktWS.WS_BudgetMarketing();
                    BudgetMktWS.Timeout = 600000;

                    //update budgetmkt
                    decimal BudgetMKTExpense = 0;
                    log.DebugFormat("BudgetMkt Web Service [getBudgetMktActualExpense] Method Invoked.. Parameter sent: projectcode={0}", projectcode);
                    BudgetMKTExpense = BudgetMktWS.getBudgetMktActualExpense(projectcode);

                    //insert budgetmkt detail
                    //initDTFinal_MktExpenseDetail();

                    //log.DebugFormat("BudgetMkt Web Service [getBudgetMktActualExpenseDetail] Method Invoked.. Parameter sent: projectcode={0}", projectcode);

                    //_DTFinal_MktExpenseDetail = Helper.ConvertXMLToDataset(BudgetMktWS.getBudgetMktActualExpenseDetail(projectcode)).Tables[0];

                    //_DTFinal_MktExpenseDetail.Columns.Add("BatchID", System.Type.GetType("System.Int32"), batchid.ToString());
                    //_DTFinal_MktExpenseDetail.Columns["BatchID"].SetOrdinal(0);

                    //clsSalesSummary.InsertActualBudgetMktDetail(_DTFinal_MktExpenseDetail);



                    //actual Cost Contract
                    CostContractWS.WS_CostAndContract CostContractWS = new LKReportingSystem.CostContractWS.WS_CostAndContract();
                    CostContractWS.Timeout = 600000;
                    log.DebugFormat("CostContract Web Service [RetrieveProjectMapping] Method Invoked.. Parameter sent: projectcode={0}", projectcode);

                    initDT_CostContractProjectMapping();

                    if (CostContractWS.RetrieveProjectMapping(projectcode).Tables.Count != 0)
                    {
                        _DT_CostContractProjectMapping = CostContractWS.RetrieveProjectMapping(projectcode).Tables[0];

                        processActualConstructionCost(_DT_CostContractProjectMapping, batchid, asofdate);

                        clsSalesSummary.UpdateActualCost(_DT_CostContractProjectMapping, "System Generated");

                        clsSalesSummary.InsertActualCostContractDetail(_DTFinal_CostContractDetail);
                    }



                    clsSalesSummary.UpdateProjectByWsValue(batchid, PaidComm, UnpaidComm, BudgetMKTExpense);

                    BindDataSalesSummaryHistory();
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "BootboxAlert('Failed when Generate Sales Summary Report');", true);
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat("btnGenerate_Click() ERROR: {0}.", ex.Message);
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "BootboxAlert('There is an error: " + ex.Message.Replace("'", "\\'") + "');", true);
            }
        }