Ejemplo n.º 1
0
        private object getPostProductTestData(int orderID, string prodName, int ordLine)
        {
            Sample      s  = new Sample();
            Order       o  = new Order();
            Product     p  = new Product();
            PageObject  po = new PageObject();
            DelayReason d  = new DelayReason();

            po.lstAttachments      = new List <Attachments>();
            po.lstOrderAttachments = new List <OrderAttachment>();
            po.User                = Session["USER_LOGIN"] as AppUser;
            o.UserLanguage         = po.User.Language;
            d.UserLanguage         = po.User.Language;
            s.UserLanguage         = po.User.Language;
            po.objOrder            = o.GetOrderProductDetails(orderID, prodName);
            po.lstDelayReason      = d.GetDelayReasons();
            po.lstOrderAttachments = o.GetOrderAttachments(po.objOrder.ORDNAME);
            if (null != po.lstOrderAttachments && po.lstOrderAttachments.Count > 0)
            {
                if (null != po.lstOrderAttachments[0].EXTFILES_SUBFORM && po.lstOrderAttachments[0].EXTFILES_SUBFORM.Count > 0)
                {
                    foreach (Attachments item in po.lstOrderAttachments[0].EXTFILES_SUBFORM)
                    {
                        string[] arr = item.EXTFILENAME.Split('\\'); //item.EXTFILENAME.Split(' / ');
                        if (string.IsNullOrEmpty(arr[arr.Length - 1]))
                        {
                            item.FILE_NAME = arr[0];
                            item.FOLDER    = arr[1];
                        }
                        else
                        {
                            if (arr.Length == 3)
                            {
                                item.FILE_NAME = arr[arr.Length - 1];
                                item.FOLDER    = arr[arr.Length - 2];
                            }
                            if (arr.Length == 4)
                            {
                                item.FILE_NAME = arr[arr.Length - 1];
                                item.FOLDER    = arr[arr.Length - 3] + @"\" + arr[arr.Length - 2];
                            }
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(po.objOrder.TYPECODE))
            {
                OrderType oi = new OrderType();
                if (po.User.Language.Equals("English"))
                {
                    po.htmlText = oi.GetOrderTypeText_EN(po.objOrder.TYPECODE);
                }
                else
                {
                    po.htmlText = oi.GetOrderTypeText(po.objOrder.TYPECODE);
                }
            }

            if ((null != po.objOrder.PORDERITEMS_SUBFORM) && (po.objOrder.PORDERITEMS_SUBFORM.Count /*Length*/ > 0))
            {
                po.objProduct         = po.objOrder.PORDERITEMS_SUBFORM[0];
                po.objProduct.ORD     = po.objOrder.ORD;
                po.objProduct.ORDNAME = po.objOrder.ORDNAME;
                // Get order line text
                if ((null != po.objOrder.PORDERITEMS_SUBFORM[0].PORDERITEMSTEXT_SUBFORM) && (po.objOrder.PORDERITEMS_SUBFORM[0].PORDERITEMSTEXT_SUBFORM.Length > 0))
                {
                    po.objItemText = new OrdersItemText();
                    foreach (OrdersItemText item in po.objOrder.PORDERITEMS_SUBFORM[0].PORDERITEMSTEXT_SUBFORM)
                    {
                        po.objItemText.TEXT += item.TEXT.Replace(" ", "&nbsp;").Replace("Pdir", "P dir");
                    }
                }

                if (null != po.objProduct)
                {
                    GetProductObjAndSamples(po.objOrder.OrderID, po.objOrder.OrderNumber, po.objProduct.PARTNAME, ordLine, ref po);
                }

                // Get Sampels
                if ((null != po.objSample) && (null != po.objSample.MED_TRANSSAMPLEQA_SUBFORM) && (po.objSample.MED_TRANSSAMPLEQA_SUBFORM.Count > 0))
                {
                    foreach (Sample_QA item in po.objSample.MED_TRANSSAMPLEQA_SUBFORM)
                    {
                        item.DOCNO    = po.objSample.DOCNO;
                        item.SUPNAME  = po.objSample.SUPNAME;
                        item.PARTNAME = po.objSample.PARTNAME;
                    }
                }
            }
            // Get Attachments
            if ((null == po.objOrder.EXTFILES_SUBFORM) || (po.objOrder.EXTFILES_SUBFORM.Count /*.Length*/ == 0))
            {
                GetProductAttachments(orderID, prodName, ref po);
            }
            else
            {
                po.lstAttachments = new List <Attachments>();
                po.lstAttachments.AddRange(po.objOrder.EXTFILES_SUBFORM);
                foreach (Attachments item in po.lstAttachments)
                {
                    string[] arr = item.EXTFILENAME.Split('\\'); //item.EXTFILENAME.Split(' / ');
                    if (string.IsNullOrEmpty(arr[arr.Length - 1]))
                    {
                        item.FILE_NAME = arr[0];
                        item.FOLDER    = arr[1];
                    }
                    else
                    {
                        item.FILE_NAME = arr[arr.Length - 1];
                        item.FOLDER    = arr[arr.Length - 2];
                    }
                }
            }
            return(po);
        }
Ejemplo n.º 2
0
        public JsonResult GetSalesorderDetail(int orderID, string prodName, int ordLine)
        {
            if (Session["USER_LOGIN"] == null)
            {
                return(Json(RedirectToAction("Login", "Account")));
            }
            PageObject po = new PageObject();

            po.User = Session["USER_LOGIN"] as AppUser;
            Sample s = new Sample();
            Order  o = new Order();
            //Product p = new Product();
            DelayReason d = new DelayReason();

            po.lstAttachments      = new List <Attachments>();
            po.lstOrderAttachments = new List <OrderAttachment>();
            o.UserLanguage         = po.User.Language;
            d.UserLanguage         = po.User.Language;
            s.UserLanguage         = po.User.Language;
            string tmpProdName = prodName;

            prodName = prodName.Replace("#", "");

            po.objOrder = o.GetOrderProductDetailsByLine(orderID, prodName, ordLine);
            if (null == po.objOrder || null == po.objOrder.PORDERITEMS_SUBFORM || po.objOrder.PORDERITEMS_SUBFORM.Count /*Length*/ == 0)
            {
                po.ErrorDescription = "Bed request ==> PART NAME was not found => PARTNAME = " + tmpProdName;
                return(Json(po));
            }
            po.lstDelayReason      = d.GetDelayReasons();
            po.lstOrderAttachments = o.GetOrderAttachments(po.objOrder.ORDNAME);

            if (null != po.lstOrderAttachments && po.lstOrderAttachments.Count > 0)
            {
                if (null != po.lstOrderAttachments[0].EXTFILES_SUBFORM && po.lstOrderAttachments[0].EXTFILES_SUBFORM.Count > 0)
                {
                    foreach (Attachments item in po.lstOrderAttachments[0].EXTFILES_SUBFORM)
                    {
                        string[] arr = item.EXTFILENAME.Split('\\'); //item.EXTFILENAME.Split(' / ');
                        if (string.IsNullOrEmpty(arr[arr.Length - 1]))
                        {
                            item.FILE_NAME = arr[0];
                            item.FOLDER    = arr[1];
                        }
                        else
                        {
                            if (arr.Length == 3)
                            {
                                item.FILE_NAME = arr[arr.Length - 1];
                                item.FOLDER    = arr[arr.Length - 2];
                            }
                            if (arr.Length == 4)
                            {
                                item.FILE_NAME = arr[arr.Length - 1];
                                item.FOLDER    = arr[arr.Length - 3] + @"\" + arr[arr.Length - 2];
                            }
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(po.objOrder.TYPECODE))
            {
                OrderType oi = new OrderType();
                if (po.User.Language.Equals("English"))
                {
                    po.htmlText = oi.GetOrderTypeText_EN(po.objOrder.TYPECODE);
                }
                else
                {
                    po.htmlText = oi.GetOrderTypeText(po.objOrder.TYPECODE);
                }
            }

            if ((null != po.objOrder.PORDERSTEXT_SUBFORM) /* && (po.objOrder.PORDERSTEXT_SUBFORM.Count/*Length > 0)*/)
            {
                //foreach (PORDERSTEXT item in po.objOrder.PORDERSTEXT_SUBFORM)
                //{
                po.objOrderText += po.objOrder.PORDERSTEXT_SUBFORM.TEXT.Replace("Pdir", "P dir").Replace("dir", " dir");
                //po.objOrderText += item.TEXT.Replace(" ", "&nbsp;").Replace("Pdir", "P dir").Replace("dir", " dir");
                //}
            }

            if ((null != po.objOrder.PORDERITEMS_SUBFORM) && (po.objOrder.PORDERITEMS_SUBFORM.Count /*Length*/ > 0))
            {
                po.objProduct                 = po.objOrder.PORDERITEMS_SUBFORM[0];
                po.objProduct.ORD             = po.objOrder.ORD;
                po.objProduct.ORDNAME         = po.objOrder.ORDNAME;
                po.objProduct.SHR_SUP_REMARKS = po.objProduct.GerSupplierRemarks(po.objOrder.ORDNAME, po.objProduct.KLINE);
                // Get order line text
                if ((null != po.objOrder.PORDERITEMS_SUBFORM[0].PORDERITEMSTEXT_SUBFORM) && (po.objOrder.PORDERITEMS_SUBFORM[0].PORDERITEMSTEXT_SUBFORM.Length > 0))
                {
                    po.objItemText = new OrdersItemText();
                    foreach (OrdersItemText item in po.objOrder.PORDERITEMS_SUBFORM[0].PORDERITEMSTEXT_SUBFORM)
                    {
                        po.objItemText.TEXT += item.TEXT.Replace(" ", "&nbsp;").Replace("Pdir", "P dir");
                    }
                }
            }
            return(Json(po));
        }