Пример #1
0
        public static List <Model.mdlCustomerImageReport> LoadCustomerImageReport(string lBranchID, DateTime lStartDate, DateTime lEndDate, List <string> lEmployeeIDlist, List <string> lImgTypelist)
        {
            //Fill the lParam by the Value of EmployeeID CheckBoxList
            string lParam = string.Empty;

            foreach (var lEmployeeID in lEmployeeIDlist)
            {
                if (lParam == "")
                {
                    lParam = " d.EmployeeID =" + "'" + lEmployeeID + "'";
                }
                else
                {
                    lParam += " OR d.EmployeeID =" + "'" + lEmployeeID + "'";
                }
            }
            lParam = "(" + lParam + ")";

            //Fill the lParam2 by the Value of ImageType CheckBoxList
            string        lParam2  = string.Empty;
            List <string> listType = new List <string>();

            foreach (var lImgType in lImgTypelist)
            {
                if (lImgType == "VISIT")
                {
                    listType.Add("OutOfRangeVisitCheckIn");
                    listType.Add("OutOfRangeVisitCheckOut");
                    listType.Add("ReasonVisit");
                }

                else if (lImgType == "COST")
                {
                    var listCost = CostFacade.GetCost().Select(x => x.CostID);
                    listType.AddRange(listCost);
                }
            }

            foreach (var type in listType)
            {
                if (lParam2 == "")
                {
                    lParam2 = " a.ImageType =" + "'" + type + "'";
                }
                else
                {
                    lParam2 += " OR a.ImageType =" + "'" + type + "'";
                }
            }
            lParam2 = "AND (" + lParam2 + ")";

            List <SqlParameter> sp = new List <SqlParameter>()
            {
                new SqlParameter()
                {
                    ParameterName = "@StartDate", SqlDbType = SqlDbType.Date, Value = lStartDate
                },
                new SqlParameter()
                {
                    ParameterName = "@EndDate", SqlDbType = SqlDbType.Date, Value = lEndDate.AddDays(1)
                },                                                                                                        //010
                new SqlParameter()
                {
                    ParameterName = "@BranchID", SqlDbType = SqlDbType.NVarChar, Value = lBranchID
                }
            };

            var mdlCustImageReportList = new List <Model.mdlCustomerImageReport>();

            //001
            DataTable dtCustomerImageReport = Manager.DataFacade.DTSQLCommand(@"SELECT    d.BranchID,
                                                                                 e.BranchName,
                                                                                 d.EmployeeID,
                                                                                 f.EmployeeName,
                                                                                 d.VehicleID,
                                                                                 a.CustomerID,
                                                                                 b.CustomerName,
                                                                                 a.WarehouseID,
                                                                                 c.WarehouseName,
                                                                                 a.DocNumber,
                                                                                 a.VisitID,
                                                                                 a.ImageDate,
                                                                                 a.ImageBase64,
                                                                                 a.ImagePath,
									                                             a.ImageType,
                                                                                 g.CostName
		                                                                 FROM CustomerImage a 
											                                LEFT JOIN Customer b ON a.CustomerID = b.CustomerID
                                                                            LEFT JOIN Warehouse c ON a.WarehouseID = c.WarehouseID
			                                                                  INNER JOIN Visit d ON a.VisitID = d.VisitID
			                                                                  INNER JOIN Branch e ON d.BranchID = e.BranchID
			                                                                  INNER JOIN Employee f ON d.EmployeeID = f.EmployeeID
                                                                              LEFT JOIN Cost g on g.CostID = a.ImageType
                                                                            WHERE (d.BranchID = @BranchID) AND (a.ImageDate BETWEEN @StartDate and @EndDate) AND" + lParam + lParam2 + "Order by a.ImageDate", sp);

            foreach (DataRow row in dtCustomerImageReport.Rows)
            {
                var mdlCustomerImageReport = new Model.mdlCustomerImageReport();
                mdlCustomerImageReport.BranchID     = row["BranchID"].ToString();
                mdlCustomerImageReport.BranchName   = row["BranchName"].ToString();
                mdlCustomerImageReport.EmployeeID   = row["EmployeeID"].ToString();
                mdlCustomerImageReport.EmployeeName = row["EmployeeName"].ToString();
                mdlCustomerImageReport.VehicleID    = row["VehicleID"].ToString();
                mdlCustomerImageReport.DocNumber    = row["DocNumber"].ToString();
                mdlCustomerImageReport.VisitID      = row["VisitID"].ToString();

                mdlCustomerImageReport.CustomerID    = row["CustomerID"].ToString();
                mdlCustomerImageReport.CustomerName  = row["CustomerName"].ToString();
                mdlCustomerImageReport.WarehouseID   = row["WarehouseID"].ToString();
                mdlCustomerImageReport.WarehouseName = row["WarehouseName"].ToString();

                if (mdlCustomerImageReport.CustomerID == mdlCustomerImageReport.WarehouseID)
                {
                    mdlCustomerImageReport.CustomerID.ToString();
                }
                else
                {
                    mdlCustomerImageReport.CustomerID = mdlCustomerImageReport.CustomerID + " - " + mdlCustomerImageReport.WarehouseID;
                }

                mdlCustomerImageReport.ImageDate   = Convert.ToDateTime(row["ImageDate"]).ToString("dd-MM-yyyy HH:mm:ss");
                mdlCustomerImageReport.ImageBase64 = row["ImageBase64"].ToString();
                mdlCustomerImageReport.ImagePath   = row["ImagePath"].ToString();
                if (row["CostName"].ToString() != "")
                {
                    mdlCustomerImageReport.ImageType = row["CostName"].ToString();
                }
                else
                {
                    mdlCustomerImageReport.ImageType = row["ImageType"].ToString();
                }

                mdlCustImageReportList.Add(mdlCustomerImageReport);
            }
            return(mdlCustImageReportList);
        }
Пример #2
0
        //006 OPTIMAZE
        public static Model.mdlJsonList LoadJson(Model.mdlParam json)
        {
            //001
            var mdlJson     = new Model.mdlJson();
            var mdlJsonList = new List <Model.mdlJson>();

            var mdlCallPlan       = CallPlanFacade.LoadCallPlan(json);
            var mdlCallPlanDetail = CallPlanFacade.LoadCallPlanDetail(json);

            //--006
            var mdlCustomerList     = new List <Model.mdlCustomer>();
            var mdlCustomerTypeList = new List <Model.mdlCustomerType>();
            //mdlProductList = new List<Model.mdlProduct>();  //005 Close Code

            //--002
            var mdlCost = new List <Model.mdlCost>();
            var mdlDeliveryOrderList       = new List <Model.mdlDeliveryOrder>();
            var mdlDeliveryOrderDetailList = new List <Model.mdlDeliveryOrderDetail>();
            //002--

            var mdlProductList = new List <Model.mdlProduct>();

            var mdlDailyMsgList  = new List <Model.mdlDailyMsg>(); //003
            var mdlDailyCostList = new List <Model.mdlDailyCost>();

            var mdlReturOrderList       = new List <Model.mdlReturOrder>();
            var mdlReturOrderDetailList = new List <Model.mdlReturOrderDetail>();

            var mdlReasonList = new List <Model.mdlReason>();

            var mdlProductUOMList = new List <Model.mdlProductUOM>(); //007


            var mdlMobileConfigList = new List <Model.mdlMobileConfig>();


            var mdlWarehouseList = new List <Model.mdlWarehouse>();

            var mdlUnvalidDOProductList = new List <Model.mdlDeliveryOrderDetail>();

            var mdlVisit = new List <Model.mdlDBVisit>();

            var mdlVisitDetailList = new List <Model.mdlDBVisitDetail2>();

            //Wyeth
            var mdlPromoList = new List <Model.mdlPromo>();

            var mdlCompetitorActivityList = new List <Model.mdlCompetitorActivity>();

            var mdlCompetitor = new List <Model.mdlCompetitor>();

            var mdlPhotoTypeList = new List <Model.mdlPhotoType>();

            var mdlCompetitorProduct = new List <Model.mdlCompetitorProduct>();

            var mdlMenuMobileList = new List <Model.mdlMenuMobile>();

            var mdlPOSMProductList = new List <Model.mdlPOSM>();

            var mdlSisaStockType = new List <Model.mdlSisaStockType>();

            var mdlQuestion = new List <Model.mdlQuestion>();

            var mdlAnswer = new List <Model.mdlAnswer>();

            var mdlAnswerType = new List <Model.mdlAnswer_Type>();

            var mdlQuestionSet = new List <Model.mdlQuestion_Set>();

            var mdlQuestionCategory = new List <Model.mdlQuestion_Category>();

            var mdlCompetitorActivityType = new List <Model.mdlCompetitorActivityType>();

            var mdlDepositType = new List <Model.mdlDepositType>();

            //if (mdlCallPlan.Count > 0) -- fernandes

            //fernandes
            foreach (var cp in mdlCallPlan)
            {
                if (cp.Result == "FAILED" || mdlCallPlanDetail.Count == 0)
                {
                    mdlJson.Result = "Tidak ada call plan";
                }
                else if (cp.Result == "FINISH")
                {
                    mdlJson.Result = "Call plan sudah selesai";
                }
                else
                {
                    mdlCustomerList     = CustomerFacade.LoadCustomer(json);
                    mdlCustomerTypeList = CustomerTypeFacade.LoadCustomerType();

                    //mdlDeliveryOrderList = DeliveryOrderFacade.LoadDeliveryOrder(json);
                    //mdlDeliveryOrderDetailList = DeliveryOrderFacade.LoadDeliveryOrderDetail(json, mdlDeliveryOrderList);

                    //mdlUnvalidDOProductList = DeliveryOrderFacade.UnvalidDOProduct(mdlDeliveryOrderList);

                    mdlProductList = ProductFacade.LoadProduct(json);

                    //var mdlProductList = ProductFacade.LoadProduct();  //005 close code

                    //mdlReturOrderList = ReturFacade.LoadReturOrder(json);
                    //mdlReturOrderDetailList = ReturFacade.LoadReturOrderDetail(json);

                    mdlCost = CostFacade.LoadCost(); //002

                    mdlReasonList = ReasonFacade.LoadReason();
                    //christopher
                    mdlDailyMsgList = DailyMessageFacade.LoadDailyMessage2(json);                 //003
                    //christopher
                    mdlProductUOMList = ProductFacade.LoadProductUOM(mdlDeliveryOrderDetailList); //007

                    //christopher
                    mdlMobileConfigList = MobileConfigFacade.LoadMobileConfig(json);

                    //christopher
                    mdlWarehouseList = WarehouseFacade.LoadWarehouse(mdlCallPlan);

                    mdlVisit           = VisitFacade.LoadVisit(mdlCallPlan);
                    mdlVisitDetailList = VisitFacade.LoadVisitDetail(mdlVisit);

                    mdlDailyCostList = CostFacade.LoadDailyCost(mdlVisit);

                    //wyeth

                    mdlPromoList = PromoFacade.LoadPromo(json);

                    //mdlCompetitorActivityList = CompetitorFacade.LoadCompetitorActivity(json);

                    //mdlCompetitor = CompetitorFacade.LoadCompetitor(json);

                    //mdlCompetitorProduct = CompetitorFacade.LoadCompetitorProduct(json, mdlCompetitor);

                    mdlMenuMobileList = MenuFacade.LoadMenuMobile(json.Role);

                    mdlPOSMProductList = POSMFacade.LoadPOSMProduct();

                    mdlSisaStockType = SisaStockTypeFacade.LoadSisaStockType(json);

                    //mdlCompetitorActivityType = CompetitorActivityTypeFacade.LoadCompetitorActivityType(json);

                    mdlPhotoTypeList = PhotoTypeFacade.LoadPhotoType();

                    mdlQuestion = QuestionFacade.LoadQuestion(json);

                    //mdlAnswer = AnswerFacade.LoadAnswer();

                    //mdlAnswerType = AnswerFacade.LoadAnswerType();

                    //mdlQuestionSet = QuestionFacade.LoadQuestionSet();

                    //mdlQuestionCategory = QuestionFacade.LoadQuestionCategory();

                    mdlDepositType = DepositTypeFacade.LoadDepositType();

                    mdlJson.Result = "Unduh berhasil";
                }
            }
            //006--

            //var mdlVisitList = VisitFacade.LoadVisit(json);
            //var mdlVisitDetailList = VisitFacade.LoadVisitDetail(json);


            mdlJson.CustomerList     = mdlCustomerList;
            mdlJson.CustomerTypeList = mdlCustomerTypeList;

            mdlJson.DeliveryOrderList       = mdlDeliveryOrderList;
            mdlJson.DeliveryOrderDetailList = mdlDeliveryOrderDetailList;

            mdlJson.ProductList = mdlProductList;
            //mdlJson.ProductList = mdlProductList; //05 Close Code

            mdlJson.ReturOrderList       = mdlReturOrderList;
            mdlJson.ReturOrderDetailList = mdlReturOrderDetailList;

            mdlJson.CallPlanList       = mdlCallPlan;
            mdlJson.CallPlanDetailList = mdlCallPlanDetail;

            mdlJson.CostList = mdlCost;                 //002

            mdlJson.DailyMessageList = mdlDailyMsgList; //003

            mdlJson.ReasonList = mdlReasonList;

            mdlJson.ProductUOMList = mdlProductUOMList; //007

            //christopher
            mdlJson.MobileConfigList = mdlMobileConfigList;

            mdlJson.WarehouseList = mdlWarehouseList;

            mdlJson.UnvalidDOProductList = mdlUnvalidDOProductList;

            mdlJson.Visit           = mdlVisit;
            mdlJson.VisitDetailList = mdlVisitDetailList;

            mdlJson.DailyCostList = mdlDailyCostList;

            //wyeth

            mdlJson.PromoList = mdlPromoList;
            //mdlJson.CompetitorActivityList = mdlCompetitorActivityList;
            mdlJson.CompetitorList             = mdlCompetitor;
            mdlJson.SisaStockTypeList          = mdlSisaStockType;
            mdlJson.CompetitorActivityTypeList = mdlCompetitorActivityType;
            mdlJson.CompetitorProductList      = mdlCompetitorProduct;
            mdlJson.MenuMobileList             = mdlMenuMobileList;
            mdlJson.POSMProductList            = mdlPOSMProductList;
            mdlJson.PhotoTypeList        = mdlPhotoTypeList;
            mdlJson.QuestionList         = mdlQuestion;
            mdlJson.AnswerList           = mdlAnswer;
            mdlJson.AnswerTypeList       = mdlAnswerType;
            mdlJson.QuestionSetList      = mdlQuestionSet;
            mdlJson.QuestionCategoryList = mdlQuestionCategory;

            mdlJson.DepositTypeList = mdlDepositType;

            //mdlJson.VisitList = mdlVisitList;
            //mdlJson.VisitDetailList = mdlVisitDetailList;

            var mdlJsonListNew = new Model.mdlJsonList();

            mdlJsonList.Add(mdlJson);
            mdlJsonListNew.mdlJson = mdlJsonList;

            return(mdlJsonListNew);
            //001
        }
Пример #3
0
        public static Core.Model.mdlResultList UploadJson(Core.Model.mdlUploadJsonParam lParamlist)
        {
            var mdlResultList = new Model.mdlResultList();
            var listResult    = new List <Model.mdlResult>();
            var mdlResult     = new Model.mdlResult();

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    int err = 0;
                    mdlResultList = DeliveryOrderFacade.UpdateDeliveryOrder(lParamlist.UploadJson.ListDeliveryOrder);
                    mdlResultList = DeliveryOrderFacade.UpdateDeliveryOrderDetail(lParamlist.UploadJson.ListDeliveryOrderDetail);
                    mdlResultList = VisitFacade.InsertVisit(lParamlist.UploadJson.ListVisit);
                    if (mdlResultList.ResultList.FirstOrDefault().Result.Contains("IDExist") || mdlResultList.ResultList.FirstOrDefault().Result == "0")
                    {
                        err = 1;
                    }
                    mdlResultList = VisitFacade.InsertVisitDetail(lParamlist.UploadJson.ListVisitDetail);
                    if (mdlResultList.ResultList.FirstOrDefault().Result.Contains("IDExist") || mdlResultList.ResultList.FirstOrDefault().Result == "0")
                    {
                        err = 1;
                    }
                    mdlResultList = CostFacade.InsertDailyCost(lParamlist.UploadJson.ListCost);
                    if (mdlResultList.ResultList.FirstOrDefault().Result.Contains("IDExist") || mdlResultList.ResultList.FirstOrDefault().Result == "0")
                    {
                        err = 1;
                    }
                    mdlResultList = CustomerImageFacade.InsertCustomerImage(lParamlist.UploadJson.ListCustomerImage);
                    if (mdlResultList.ResultList.FirstOrDefault().Result.Contains("IDExist") || mdlResultList.ResultList.FirstOrDefault().Result == "0")
                    {
                        err = 1;
                    }
                    mdlResultList = LogVisitFacade.InsertLogVisit(lParamlist.UploadJson.ListLogVisit);
                    if (mdlResultList.ResultList.FirstOrDefault().Result.Contains("IDExist") || mdlResultList.ResultList.FirstOrDefault().Result == "0")
                    {
                        err = 1;
                    }
                    if (err == 0)
                    {
                        mdlResult.Result = "1";
                        scope.Complete();
                    }
                    else
                    {
                        mdlResult.Result = "0";
                    }
                }

                listResult.Add(mdlResult);
                mdlResultList.ResultList = listResult;

                return(mdlResultList);
            }
            catch (TransactionAbortedException ex)
            {
                mdlResult.Result = "0";
                listResult.Add(mdlResult);
                mdlResultList.ResultList = listResult;

                return(mdlResultList);
            }
        }