Ejemplo n.º 1
0
        public ActionResult ViewOrderDetail(long OrderId = 0)
        {
            ViewOrderModel model       = new ViewOrderModel();
            CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel;

            if (currentUser == null || currentUser.IsAdmin == false)
            {
                return(RedirectToAction("Login", "Login"));
            }

            CommonService comService = new CommonService();
            CommonDa      da         = new CommonDa();
            AdminOrderDa  dataAccess = new AdminOrderDa();

            if (OrderId > 0)
            {
                ViewOrderModel infor = new ViewOrderModel();
                infor = dataAccess.getInforOrder(OrderId);
                model = infor != null ? infor : model;
                string CompanyCd    = "00000";
                var    inforCompany = da.getInfoCompany(CompanyCd);
                if (inforCompany != null)
                {
                    model.CompanyName    = inforCompany.COMPANY_NAME;
                    model.CompanyAddress = inforCompany.COMPANY_ADDRESS;
                    model.CompanyEmail   = inforCompany.COMPANY_EMAIL;
                    model.CompanyPhone   = inforCompany.COMPANY_PHONE;
                }

                model.AddressCustomer   = model.DistrictName + ", " + model.Receive_Address;
                model.ORDER_STATUS_TEXT = OrderStatus.Items[model.Status].ToString();

                var getOrderDetail = dataAccess.getOrderDetail(model.ID).Take(3);
                ViewBag.listOrderDetail = getOrderDetail.ToList();
                foreach (var data in getOrderDetail)
                {
                    model.ProductDetailTotal += data.ProductName + " (Số lượng: " + data.Quantity.ToString() + "), ";
                }

                if (String.IsNullOrEmpty(model.LINK_QRCODE))
                {
                    model.LINK_QRCODE = QRCodeServices.creatQR(model.Code);
                    dataAccess.UpdateQRLink(OrderId, model.LINK_QRCODE);
                }
                if (!String.IsNullOrEmpty(model.LINK_QRCODE))
                {
                    model.LINK_QRCODE = model.LINK_QRCODE.Replace("~", "");
                }
            }

            return(this.PartialView("ViewOrderDetail", model));
        }
Ejemplo n.º 2
0
        public ActionResult PrintOrderCustom(string ORDER_ID_STRING)
        {
            CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel;

            if (currentUser == null || currentUser.IsAdmin == false)
            {
                return(RedirectToAction("Login", "Login"));
            }

            CommonService         comService      = new CommonService();
            CommonDa              da              = new CommonDa();
            AdminOrderDa          dataAccess      = new AdminOrderDa();
            List <ViewOrderModel> listOrderDetail = new List <ViewOrderModel>();
            ViewOrderModel        model           = new ViewOrderModel();

            if (!string.IsNullOrEmpty(ORDER_ID_STRING))
            {
                List <long> ORDER_ID_LIST = ORDER_ID_STRING.Split(',').Select(long.Parse).ToList();
                if (ORDER_ID_LIST.Count > 0)
                {
                    for (int i = 0; i < ORDER_ID_LIST.Count(); i++)
                    {
                        if (ORDER_ID_LIST[i] > 0)
                        {
                            ViewOrderModel infor = new ViewOrderModel();
                            infor = dataAccess.getInforOrder(ORDER_ID_LIST[i]);
                            model = infor != null ? infor : model;
                            string CompanyCd    = "00000";
                            var    inforCompany = da.getInfoCompany(CompanyCd);
                            if (inforCompany != null)
                            {
                                model.CompanyName    = inforCompany.COMPANY_NAME;
                                model.CompanyAddress = inforCompany.COMPANY_ADDRESS;
                                model.CompanyEmail   = inforCompany.COMPANY_EMAIL;
                                model.CompanyPhone   = inforCompany.COMPANY_PHONE;
                            }

                            model.AddressCustomer   = model.DistrictName + ", " + model.Receive_Address;
                            model.ORDER_STATUS_TEXT = OrderStatus.Items[model.Status].ToString();

                            var getOrderDetail = dataAccess.getOrderDetail(model.ID).Take(3);
                            ViewBag.listOrderDetail = getOrderDetail.ToList();
                            foreach (var data in getOrderDetail)
                            {
                                model.ProductDetailTotal += data.ProductName + " (Số lượng: " + data.Quantity.ToString() + "), ";
                            }

                            if (String.IsNullOrEmpty(model.LINK_QRCODE))
                            {
                                model.LINK_QRCODE = QRCodeServices.creatQR(model.Code);
                                dataAccess.UpdateQRLink(ORDER_ID_LIST[i], model.LINK_QRCODE);
                            }
                            if (!String.IsNullOrEmpty(model.LINK_QRCODE))
                            {
                                model.LINK_QRCODE = model.LINK_QRCODE.Replace("~", "");
                            }
                            listOrderDetail.Add(model);
                        }
                    }
                }
                //return new ViewAsPdf("ViewOrderDetailPDF", listOrderDetail);
                return(PartialView("ViewOrderDetailPDF", listOrderDetail));
            }

            return(new EmptyResult());
        }