Beispiel #1
0
        public ActionResult Index(int?page)
        {
            int pageIndex = PagingHelper.GetPageIndex(page);

            ProcessOrderSearchModel q = new ProcessOrderSearchModel();

            IProcessOrderService ps = new ProcessOrderService(Settings.Default.db);

            IPagedList <ProcessOrder> processOrders = ps.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            SetProcessOrderStatusList(null);
            SetPartTypeList(null);
            SetProcessOrderMrpRoundList(null);

            //ProcessOrderInfoModel info = ps.GetProcessOrderInfo(q);
            //ViewBag.Info = info;

            return(View(processOrders));
        }
Beispiel #2
0
        public ActionResult Search([Bind(Include = "OrderNr,SourceDoc,DerivedFrom,ProceeDateFrom,ProceeDateTo,PartNr,ActualQuantityFrom,ActualQuantityTo,CompleteRateFrom,CompleteRateTo,Status,MrpRound,KanbanNr,PartType,CreateAtFrom,CreateAtTo")] ProcessOrderSearchModel q)
        {
            int pageIndex = 0;

            int.TryParse(Request.QueryString.Get("page"), out pageIndex);
            pageIndex = PagingHelper.GetPageIndex(pageIndex);

            IProcessOrderService ps = new ProcessOrderService(Settings.Default.db);

            IPagedList <ProcessOrder> processOrders = ps.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            SetProcessOrderStatusList(q.Status);
            SetPartTypeList(q.PartType);
            SetProcessOrderMrpRoundList(q.MrpRound);

            //ProcessOrderInfoModel info = ps.GetProcessOrderInfo(q);
            //ViewBag.Info = info;

            return(View("Index", processOrders));
        }
Beispiel #3
0
        public void ExportKB([Bind(Include = "OrderNr,SourceDoc,DerivedFrom,ProceeDateFrom,ProceeDateTo,PartNr,ActualQuantityFrom,ActualQuantityTo,CompleteRateFrom,CompleteRateTo,Status,MrpRound,PartType,CreateAt")] ProcessOrderSearchModel q)
        {
            var isNew = Request.QueryString["isNew"];
            IProcessOrderService ps = new ProcessOrderService(Settings.Default.db);

            if (!q.ActualQuantityFrom.HasValue)
            {
                q.ActualQuantityFrom = 0.0000009;
            }
            List <ProcessOrder> processOrders = ps.Search(q).ToList();

            ViewBag.Query = q;

            MemoryStream ms = new MemoryStream();

            using (StreamWriter sw = new StreamWriter(ms, Encoding.UTF8))
            {
                List <string> head = new List <string> {
                    " No.", "Product", "PartNr", "Kanban", "PartType(KB Type)", "Position", "ActualQuantity", "BundleQuantity", "BatchQuantity", "KanBanPosition", "RouteNr", "ChangeQty", "CreateAt", "CurrentStock"
                };
                sw.WriteLine(string.Join(Settings.Default.csvDelimiter, head));
                for (var i = 0; i < processOrders.Count; i++)
                {
                    List <string> ii = new List <string>();
                    ii.Add((i + 1).ToString());

                    double sourceQuantity  = processOrders[i].sourceQuantity;
                    double actualQuantity  = processOrders[i].actualQuantity;
                    double kanbanBundleQty = processOrders[i].Part.kanbanBundleQty;
                    double kanbanBatchQty  = processOrders[i].Part.kanbanBatchQty;
                    #region V2
                    if ((!string.IsNullOrEmpty(isNew)))
                    {
                        //if (processOrders[i].currentStock >= 0)
                        //{
                        ProcessOrderSearchModel qq = new ProcessOrderSearchModel()
                        {
                            PartNrAct    = processOrders[i].partNr,
                            Status       = processOrders[i].status,
                            ProceeDateTo = processOrders[i].proceeDate
                        };
                        List <ProcessOrder> orders = ps.Search(qq).ToList();
                        double qty = processOrders[i].currentStock >= 0 ? sourceQuantity : processOrders[i].requirementQuantity.Value;
                        if (orders.Count > 0)
                        {
                            qty = 0;
                            foreach (ProcessOrder o in orders)
                            {
                                qty += (processOrders[i].currentStock >= 0 ? o.sourceQuantity : o.requirementQuantity.Value);
                            }
                        }
                        sourceQuantity = qty;
                        if (kanbanBundleQty > 0)
                        {
                            if (sourceQuantity % kanbanBundleQty == 0)
                            {
                                // do nothing
                            }
                            else
                            {
                                actualQuantity = kanbanBundleQty * (((int)(sourceQuantity / kanbanBundleQty)) + 1);
                            }
                        }
                        //}
                    }
                    #endregion

                    #region V1
                    //if ((!string.IsNullOrEmpty(isNew)) && processOrders[i].currentStock > 0)
                    //{
                    //    ProcessOrderSearchModel qq = new ProcessOrderSearchModel()
                    //    {
                    //        PartNrAct = processOrders[i].partNr,
                    //        Status = processOrders[i].status,
                    //        ProceeDateTo = processOrders[i].proceeDate
                    //    };
                    //    List<ProcessOrder> orders = ps.Search(qq).ToList();
                    //    double qty = sourceQuantity;
                    //    if (orders.Count > 0)
                    //    {
                    //        qty = 0;
                    //        foreach (ProcessOrder o in orders)
                    //        {
                    //            qty += o.sourceQuantity;
                    //        }
                    //    }
                    //    sourceQuantity = qty;
                    //    if (kanbanBundleQty > 0)
                    //    {
                    //        if (sourceQuantity % kanbanBundleQty == 0)
                    //        {
                    //            // do nothing
                    //        }
                    //        else
                    //        {
                    //            actualQuantity = kanbanBundleQty * (((int)(sourceQuantity / kanbanBundleQty)) + 1);
                    //        }
                    //    }
                    //}
                    #endregion

                    ii.Add(processOrders[i].Part.productNr);
                    ii.Add(processOrders[i].partNr);
                    ii.Add(processOrders[i].Part.kanbanNrs);
                    ii.Add(processOrders[i].Part.partTypeDisplay);
                    ii.Add(processOrders[i].Part.kanbanPosition);
                    ii.Add(actualQuantity.ToString());
                    ii.Add(kanbanBundleQty.ToString());
                    ii.Add(processOrders[i].Part.kanbanBatchQty.ToString());
                    ii.Add(processOrders[i].Part.kanbanPosition.ToString());
                    ii.Add(processOrders[i].Part.routeNr.ToString());
                    ii.Add(actualQuantity > kanbanBatchQty ? "Y" : "N");
                    ii.Add(processOrders[i].createAt.ToString());
                    ii.Add(processOrders[i].currentStock.ToString());
                    sw.WriteLine(string.Join(Settings.Default.csvDelimiter, ii.ToArray()));
                }
                //sw.WriteLine(max);
            }
            var filename    = "Kanban" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv";
            var contenttype = "text/csv";
            Response.Clear();
            Response.ContentEncoding = Encoding.UTF8;
            Response.ContentType     = contenttype;
            Response.AddHeader("content-disposition", "attachment;filename=" + filename);
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.BinaryWrite(ms.ToArray());
            Response.End();
        }