Пример #1
0
        /// <summary>
        /// Setting init when load page
        /// </summary>
        private void Initialize(int ID)
        {
            var company = TransportCompanyController.GetTransportCompanyByID(ID);

            if (company == null)
            {
                PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy nhà xe " + ID, "e", true, "/danh-sach-nha-xe", Page);
            }
            else
            {
                this.hdfID.Value            = ID.ToString();
                this.txtCompanyName.Text    = company.CompanyName;
                this.txtCompanyPhone.Text   = company.CompanyPhone;
                this.txtCompanyAddress.Text = company.CompanyAddress;
                this.txtNote.Text           = company.Note;
                this.txtPrepay.Text         = company.Prepay ? "Trả cước trước" : "Trả cước sau";
                this.txtCOD.Text            = company.COD ? "Có thu hộ" : "Không thu hộ";

                ltrEditButton.Text = "<a href=\"/sua-thong-tin-nha-xe?id=" + ID.ToString() + "\" class=\"btn primary-btn fw-btn not-fullwidth\"><i class=\"fa fa-pencil-square-o\" aria-hidden=\"true\"></i> Chỉnh sửa</a>";

                var transprots = TransportCompanyController.GetReceivePlace(ID);

                pagingall(transprots);
            }
        }
Пример #2
0
        public static string getTransportSub(int transComID)
        {
            if (transComID > 0)
            {
                var data = new List <object>();
                data.Add(new
                {
                    key   = "0",
                    value = "Chọn nơi nhận"
                });

                var ShipTo = TransportCompanyController.GetReceivePlace(transComID);

                foreach (var p in ShipTo)
                {
                    data.Add(new
                    {
                        key   = p.SubID.ToString(),
                        value = p.ShipTo.ToTitleCase()
                    });
                }

                JavaScriptSerializer serializer = new JavaScriptSerializer();

                return(serializer.Serialize(data));
            }

            return(String.Empty);
        }
Пример #3
0
        /// <summary>
        /// Setting init when load page
        /// </summary>
        /// <param name="ID"></param>
        private void Initialize(int ID, int SubID)
        {
            // Init value
            var transportCompany = TransportCompanyController.GetAllReceivePlaceByID(ID, SubID);

            if (transportCompany != null)
            {
                this.hdfID.Value             = transportCompany.ID.ToString();
                this.hdfSubID.Value          = transportCompany.SubID.ToString();
                this.txtCompanyName.Text     = transportCompany.CompanyName;
                this.txtCompanyPhone.Text    = transportCompany.CompanyPhone;
                this.txtCompanyAddress.Text  = transportCompany.CompanyAddress;
                this.txtShipTo.Text          = transportCompany.ShipTo;
                this.txtAddress.Text         = transportCompany.Address;
                this.rdbPrepay.SelectedValue = transportCompany.Prepay? "true" : "false";
                this.rdbCOD.SelectedValue    = transportCompany.COD ? "true" : "false";
                this.pNote.Text = transportCompany.Note;
            }
            else
            {
                Response.Redirect("/danh-sach-nha-xe");
            }

            // Setting display
            this.txtShipTo.Focus();
        }
Пример #4
0
        public static string updateStatus(int ID, int SubID)
        {
            string update = TransportCompanyController.UpdateStatus(ID, SubID);

            if (update == "true")
            {
                return("true");
            }
            else
            {
                return("false");
            }
        }
        public void LoadTransportCompany()
        {
            var TransportCompany = TransportCompanyController.GetTransportCompany();

            ddlTransportCompanyID.Items.Clear();
            ddlTransportCompanyID.Items.Insert(0, new ListItem("Chọn chành xe", "0"));
            if (TransportCompany.Count > 0)
            {
                foreach (var p in TransportCompany)
                {
                    ListItem listitem = new ListItem(p.CompanyName, p.ID.ToString());
                    ddlTransportCompanyID.Items.Add(listitem);
                }
                ddlTransportCompanyID.DataBind();
            }
        }
Пример #6
0
        public static string checkPrepayTransport(int ID, int SubID)
        {
            var a = TransportCompanyController.GetReceivePlaceByID(ID, SubID);

            if (a != null)
            {
                if (a.Prepay == true)
                {
                    return("yes");
                }
                else
                {
                    return("no");
                }
            }
            return("null");
        }
Пример #7
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["userLoginSystem"].Value;

            tbl_TransportCompany transportCompanyNew = new tbl_TransportCompany();

            transportCompanyNew.CompanyName    = this.txtCompanyName.Text;
            transportCompanyNew.CompanyPhone   = this.txtCompanyPhone.Text;
            transportCompanyNew.CompanyAddress = this.txtCompanyAddress.Text;
            transportCompanyNew.Prepay         = Convert.ToBoolean(this.rdbPrepay.SelectedValue);
            transportCompanyNew.COD            = Convert.ToBoolean(this.rdbCOD.SelectedValue);
            transportCompanyNew.Note           = this.pNote.Text;
            transportCompanyNew.CreatedBy      = username;

            int ID = TransportCompanyController.InsertTransportCompany(transportCompanyNew);

            Response.Redirect(String.Format("/chi-tiet-nha-xe?id={0}", ID));
        }
Пример #8
0
        /// <summary>
        /// Setting init when load page
        /// </summary>
        private void LoadData(int ID)
        {
            var company = TransportCompanyController.GetAllTransportCompanyByID(ID);

            if (company == null)
            {
                PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy nhà xe " + ID, "e", true, "/danh-sach-nha-xe", Page);
            }
            else
            {
                this.hdfID.Value             = ID.ToString();
                this.txtCompanyName.Text     = company.CompanyName;
                this.txtCompanyPhone.Text    = company.CompanyPhone;
                this.txtCompanyAddress.Text  = company.CompanyAddress;
                this.rdbPrepay.SelectedValue = company.Prepay ? "true" : "false";
                this.rdbCOD.SelectedValue    = company.COD ? "true" : "false";
                this.pNote.Text = company.Note;
            }
        }
        public void LoadTransportCompanySubID(int ID)
        {
            ddlTransportCompanySubID.Items.Clear();
            ddlTransportCompanySubID.Items.Insert(0, new ListItem("Chọn nơi nhận", "0"));
            if (ID > 0)
            {
                var ShipTo = TransportCompanyController.GetReceivePlace(ID);;

                if (ShipTo.Count > 0)
                {
                    foreach (var p in ShipTo)
                    {
                        ListItem listitem = new ListItem(p.ShipTo, p.SubID.ToString());
                        ddlTransportCompanySubID.Items.Add(listitem);
                    }
                }
                ddlTransportCompanySubID.DataBind();
            }
        }
Пример #10
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;

            tbl_TransportCompany transportCompany = new tbl_TransportCompany();

            transportCompany.ID             = Convert.ToInt32(this.hdfID.Value);
            transportCompany.CompanyName    = this.txtCompanyName.Text;
            transportCompany.CompanyPhone   = this.txtCompanyPhone.Text;
            transportCompany.CompanyAddress = this.txtCompanyAddress.Text;
            transportCompany.Prepay         = Convert.ToBoolean(this.rdbPrepay.SelectedValue);
            transportCompany.COD            = Convert.ToBoolean(this.rdbCOD.SelectedValue);
            transportCompany.Note           = this.pNote.Text;
            transportCompany.ModifiedBy     = username;

            int ID = TransportCompanyController.UpdateTransportCompany(transportCompany);

            Response.Redirect(String.Format("/chi-tiet-nha-xe?id={0}", this.hdfID.Value));
        }
Пример #11
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;

            tbl_TransportCompany receivePlaceUpdate = new tbl_TransportCompany();

            receivePlaceUpdate.ID         = Convert.ToInt32(this.hdfID.Value);
            receivePlaceUpdate.SubID      = Convert.ToInt32(this.hdfSubID.Value);
            receivePlaceUpdate.ShipTo     = this.txtShipTo.Text;
            receivePlaceUpdate.Address    = this.txtAddress.Text;
            receivePlaceUpdate.Prepay     = Convert.ToBoolean(this.rdbPrepay.SelectedValue);
            receivePlaceUpdate.COD        = Convert.ToBoolean(this.rdbCOD.SelectedValue);
            receivePlaceUpdate.Note       = this.pNote.Text;
            receivePlaceUpdate.ModifiedBy = username;

            TransportCompanyController.UpdateReceivePlace(receivePlaceUpdate);

            Response.Redirect(String.Format("/chi-tiet-nha-xe/?id={0}", this.hdfID.Value));
        }
        /// <summary>
        /// Setting init when load page
        /// </summary>
        /// <param name="ID"></param>
        private void Initialize(int ID)
        {
            // Init value
            var transportCompany = TransportCompanyController.GetTransportCompanyByID(ID);

            if (transportCompany != null)
            {
                this.hdfID.Value            = transportCompany.ID.ToString();
                this.txtCompanyName.Text    = transportCompany.CompanyName;
                this.txtCompanyPhone.Text   = transportCompany.CompanyPhone;
                this.txtCompanyAddress.Text = transportCompany.CompanyAddress;
            }
            else
            {
                Response.Redirect("/danh-sach-nha-xe");
            }

            // Setting display
            this.txtShipTo.Focus();
        }
Пример #13
0
        public void LoadTransportCompany()
        {
            var TransportCompany = TransportCompanyController.GetTransportCompany();

            ddlTransportCompany.Items.Clear();
            ddlTransportCompany.Items.Insert(0, new ListItem("Chành xe", "0"));
            // drop down list at update delivery modal
            ddlTransferCompanyModal.Items.Clear();
            ddlTransferCompanyModal.Items.Insert(0, new ListItem("Chành xe", "0"));

            if (TransportCompany.Count > 0)
            {
                foreach (var p in TransportCompany)
                {
                    ListItem listitem = new ListItem(p.CompanyName.ToTitleCase(), p.ID.ToString());
                    ddlTransportCompany.Items.Add(listitem);
                    ddlTransferCompanyModal.Items.Add(listitem);
                }
                ddlTransportCompany.DataBind();
                ddlTransferCompanyModal.DataBind();
            }
        }
Пример #14
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;

            tbl_TransportCompany receivePlaceNew = new tbl_TransportCompany();

            receivePlaceNew.ID             = Convert.ToInt32(this.hdfID.Value);
            receivePlaceNew.CompanyName    = this.txtCompanyName.Text;
            receivePlaceNew.CompanyPhone   = this.txtCompanyPhone.Text;
            receivePlaceNew.CompanyAddress = this.txtCompanyAddress.Text;
            receivePlaceNew.ShipTo         = this.txtShipTo.Text;
            receivePlaceNew.Address        = this.txtAddress.Text;
            receivePlaceNew.Prepay         = Convert.ToBoolean(this.rdbPrepay.SelectedValue);
            receivePlaceNew.COD            = Convert.ToBoolean(this.rdbCOD.SelectedValue);
            receivePlaceNew.Note           = this.pNote.Text;
            receivePlaceNew.Status         = 1;
            receivePlaceNew.CreatedBy      = username;

            TransportCompanyController.InsertReceivePlace(receivePlaceNew);

            Response.Redirect(String.Format("/chi-tiet-nha-xe/?id={0}", this.hdfID.Value));
        }
Пример #15
0
        /// <summary>
        /// Setting init when load page
        /// </summary>
        /// <param name="ID"></param>
        private void Initialize(int ID)
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            // Init value
            var transportCompany = TransportCompanyController.GetAllTransportCompanyByID(ID);

            if (transportCompany != null)
            {
                this.hdfID.Value            = transportCompany.ID.ToString();
                this.txtCompanyName.Text    = transportCompany.CompanyName;
                this.txtCompanyPhone.Text   = transportCompany.CompanyPhone;
                this.txtCompanyAddress.Text = transportCompany.CompanyAddress;
                if (transportCompany.Prepay == true)
                {
                    this.rdbPrepay.SelectedValue = "true";
                    this.rdbPrepay.Enabled       = false;
                    if (acc.RoleID == 0)
                    {
                        this.rdbPrepay.Enabled = true;
                    }
                }
                else
                {
                    this.rdbPrepay.SelectedValue = "false";
                }
            }
            else
            {
                Response.Redirect("/danh-sach-nha-xe");
            }

            // Setting display
            this.txtShipTo.Focus();
        }
Пример #16
0
        /// <summary>
        /// Setting init when load page
        /// </summary>
        private void LoadData()
        {
            string TextSearch  = "";
            string COD         = "";
            string Prepay      = "";
            string CreatedBy   = "";
            string CreatedDate = "";

            if (Request.QueryString["textsearch"] != null)
            {
                TextSearch = Request.QueryString["textsearch"].Trim();
            }
            if (Request.QueryString["cod"] != null)
            {
                COD = Request.QueryString["cod"];
            }
            if (Request.QueryString["prepay"] != null)
            {
                Prepay = Request.QueryString["prepay"];
            }
            if (Request.QueryString["createdby"] != null)
            {
                CreatedBy = Request.QueryString["createdby"];
            }
            if (Request.QueryString["createddate"] != null)
            {
                CreatedDate = Request.QueryString["createddate"];
            }

            txtTextSearch.Text           = TextSearch;
            ddlCOD.SelectedValue         = COD.ToString();
            ddlPrepay.SelectedValue      = Prepay.ToString();
            ddlCreatedBy.SelectedValue   = CreatedBy.ToString();
            ddlCreatedDate.SelectedValue = CreatedDate.ToString();

            var rs = TransportCompanyController.Filter(TextSearch);

            if (COD != "")
            {
                rs = rs.Where(x => x.COD == COD.ToBool()).ToList();
            }
            if (Prepay != "")
            {
                rs = rs.Where(x => x.Prepay == Prepay.ToBool()).ToList();
            }
            if (CreatedBy != "")
            {
                rs = rs.Where(x => x.CreatedBy == CreatedBy).ToList();
            }
            if (CreatedDate != "")
            {
                DateTime fromdate = DateTime.Today;
                DateTime todate   = DateTime.Now;
                switch (CreatedDate)
                {
                case "today":
                    fromdate = DateTime.Today;
                    todate   = DateTime.Now;
                    break;

                case "yesterday":
                    fromdate = fromdate.AddDays(-1);
                    todate   = DateTime.Today;
                    break;

                case "beforeyesterday":
                    fromdate = DateTime.Today.AddDays(-2);
                    todate   = DateTime.Today.AddDays(-1);
                    break;

                case "week":
                    int days = DateTime.Today.DayOfWeek == DayOfWeek.Sunday ? 7 : (int)DateTime.Today.DayOfWeek;
                    fromdate = fromdate.AddDays(-days + 1);
                    todate   = DateTime.Now;
                    break;

                case "month":
                    fromdate = new DateTime(fromdate.Year, fromdate.Month, 1);
                    todate   = DateTime.Now;
                    break;

                case "7days":
                    fromdate = DateTime.Today.AddDays(-6);
                    todate   = DateTime.Now;
                    break;

                case "30days":
                    fromdate = DateTime.Today.AddDays(-29);
                    todate   = DateTime.Now;
                    break;
                }
                rs = rs.Where(x => x.CreatedDate >= fromdate && x.CreatedDate <= todate).ToList();
            }

            pagingall(rs);

            ltrNumberOfTransport.Text = rs.Count().ToString();
        }
Пример #17
0
        public void pagingall(List <OrderList> acs, PaginationMetadataModel page)
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            StringBuilder html = new StringBuilder();

            html.AppendLine("<thead>");
            html.AppendLine("<tr>");
            html.AppendLine("    <th>Mã</th>");
            html.AppendLine("    <th></th>");
            html.AppendLine("    <th class='col-customer'>Khách hàng</th>");
            html.AppendLine("    <th>Mua</th>");
            html.AppendLine("    <th>Xử lý</th>");
            html.AppendLine("    <th>Thanh toán</th>");
            html.AppendLine("    <th>Kiểu thanh toán</th>");
            html.AppendLine("    <th>Giao hàng</th>");
            html.AppendLine("    <th>Tổng tiền</th>");
            if (acc.RoleID == 0)
            {
                html.AppendLine("    <th>Nhân viên</th>");
            }
            html.AppendLine("    <th>Ngày tạo</th>");
            html.AppendLine("    <th>Hoàn tất</th>");
            html.AppendLine("    <th></th>");
            html.AppendLine("</tr>");
            html.AppendLine("</thead>");

            html.AppendLine("<tbody>");
            if (acs.Count > 0)
            {
                PageCount = page.totalPages;
                Int32 Page = page.currentPage;

                foreach (var item in acs)
                {
                    html.AppendLine("<tr>");
                    html.AppendLine("   <td data-title='Mã đơn'><a target='_blank' href='/thong-tin-don-hang?id=" + item.ID + "'>" + item.ID + "</a></td>");
                    html.AppendLine("   <td data-title='Loại đơn'>" + PJUtils.OrderTypeStatus(Convert.ToInt32(item.OrderType)) + "</td>");

                    if (!string.IsNullOrEmpty(item.Nick))
                    {
                        html.AppendLine("   <td data-title='Khách hàng' class='customer-td'><a class='col-customer-name-link' target='_blank' href='/thong-tin-don-hang?id=" + item.ID + "'>" + item.Nick.ToTitleCase() + "</a><br><span class='name-bottom-nick'>(" + item.CustomerName.ToTitleCase() + ")</span></td>");
                    }
                    else
                    {
                        html.AppendLine("   <td data-title='Khách hàng' class='customer-td'><a class='col-customer-name-link' target='_blank' href='/thong-tin-don-hang?id=" + item.ID + "'>" + item.CustomerName.ToTitleCase() + "</a></td>");
                    }

                    html.AppendLine("   <td data-title='Đã mua'>" + item.Quantity + "</td>");
                    if (acc.RoleID == 0 && item.ExcuteStatus == 2)
                    {
                        html.AppendLine("   <td data-title='Xử lý'><span class='bg-green' style='cursor: pointer' onclick='onClick_spFinishStatusOrder(this, " + item.ID + ")'>Đã hoàn tất</span></td>");
                    }
                    else
                    {
                        html.AppendLine("   <td data-title='Xử lý'>" + PJUtils.OrderExcuteStatus(Convert.ToInt32(item.ExcuteStatus)) + "</td>");
                    }
                    html.AppendLine("   <td data-title='Thanh toán'>" + PJUtils.OrderPaymentStatus(Convert.ToInt32(item.PaymentStatus)) + "</td>");

                    #region Phương thức thanh toán
                    html.AppendLine("   <td data-title='Kiểu thanh toán' class='payment-type'>");
                    html.AppendLine(PJUtils.PaymentType(Convert.ToInt32(item.PaymentType)));
                    // Đã nhận tiền chuyển khoản
                    if (item.PaymentType == 2)
                    {
                        if (item.TransferStatus.HasValue && item.TransferStatus.Value == 1)
                        {
                            html.AppendLine("       <br/><div class='new-status-btn'><span class='bg-green'>Đã nhận tiền</span></div>");
                        }
                        else
                        {
                            if (acc.RoleID == 0)
                            {
                                html.AppendLine("       <br/><a class='new-status-btn' target='_blank' href='/danh-sach-chuyen-khoan?&textsearch=" + item.ID + "'><span class='bg-black'>Cập nhật</span></a>");
                            }
                        }
                    }
                    html.AppendLine("   </td>");
                    #endregion


                    #region Giao hàng
                    html.AppendLine("   <td data-title='Giao hàng' class='shipping-type'>");
                    html.AppendLine(PJUtils.ShippingType(Convert.ToInt32(item.ShippingType)));
                    // Đã giao hàng
                    if (item.DeliveryStatus.HasValue && item.DeliveryStatus.Value == 1)
                    {
                        html.AppendLine("       <br/><div class='new-status-btn'><span class='bg-green'>Đã giao</span></div>");
                    }
                    html.AppendLine("   </td>");
                    #endregion

                    // Tổng tiền
                    if (acc.RoleID == 0)
                    {
                        html.AppendLine("   <td data-title='Tổng tiền'>");
                        html.AppendLine(String.Format("        <strong>{0:N0}</strong>", item.TotalPrice - item.TotalRefund));
                        html.AppendLine(String.Format("        <br/><span class='{0}'><strong>{1:N0}</strong></span>", item.TotalProfit > 0 ? "bg-green" : "bg-red", item.TotalProfit));
                        html.AppendLine("   </td>");
                    }
                    else
                    {
                        html.AppendLine(String.Format("   <td data-title='Tổng tiền'><strong>{0:N0}</strong></td>", item.TotalPrice - item.TotalRefund));
                    }

                    if (acc.RoleID == 0)
                    {
                        html.AppendLine("   <td data-title='Nhân viên'>" + item.CreatedBy + "</td>");
                    }

                    string date = string.Format("<strong>{0:dd/MM}</strong><br>{0:HH:mm}", item.CreatedDate);
                    html.AppendLine("   <td data-title='Ngày tạo'>" + date + "</td>");

                    string datedone = "";
                    if (item.ExcuteStatus == 2)
                    {
                        datedone = string.Format("<strong>{0:dd/MM}</strong><br>{0:HH:mm}", item.DateDone);
                    }
                    html.AppendLine("   <td data-title='Hoàn tất'>" + datedone + "</td>");

                    html.AppendLine("   <td data-title='Thao tác' class='update-button'>");
                    html.AppendLine("       <a href='/print-invoice?id=" + item.ID + "' title='In hóa đơn' target='_blank' class='btn primary-btn h45-btn'><i class='fa fa-print' aria-hidden='true'></i></a>");
                    html.AppendLine("       <a href='/print-shipping-note?id=" + item.ID + "' title='In phiếu gửi hàng' target='_blank' class='btn primary-btn btn-red h45-btn'><i class='fa fa-file-text-o' aria-hidden='true'></i></a>");
                    html.AppendLine("       <a href='/chi-tiet-khach-hang?id=" + item.CustomerID + "' title='Thông tin khách hàng " + item.CustomerName + "' target='_blank' class='btn primary-btn btn-black h45-btn'><i class='fa fa-user-circle' aria-hidden='true'></i></a>");
                    if (item.DeliveryStatus.HasValue && item.DeliveryStatus.Value == 1 && !string.IsNullOrEmpty(item.InvoiceImage))
                    {
                        html.AppendLine("       <a href='javascript:;' onclick='openImageInvoice($(this))' data-link='" + item.InvoiceImage + "' title='Biên nhận gửi hàng' class='btn primary-btn btn-blue h45-btn'><i class='fa fa-file-text-o' aria-hidden='true'></i></a>");
                    }
                    html.AppendLine("       <a href='javascript:;' onclick='copyInvoiceURL(" + item.ID + ", " + item.CustomerID + ")' title='Copy link hóa đơn' class='btn primary-btn btn-violet h45-btn'><i class='glyphicon glyphicon-list-alt' aria-hidden='true'></i></a>");
                    html.AppendLine("   </td>");
                    html.AppendLine("</tr>");

                    // thông tin thêm
                    html.AppendLine("<tr class='tr-more-info'>");
                    html.AppendLine("<td colspan='2'></td>");
                    html.AppendLine("<td colspan='11'>");

                    if (item.TotalRefund != 0)
                    {
                        html.AppendLine("<span class='order-info'><strong>Đổi trả:</strong> -" + string.Format("{0:N0}", item.TotalRefund) + " (<a href='xem-don-hang-doi-tra?id=" + item.RefundsGoodsID + "' target='_blank'>Đơn " + item.RefundsGoodsID + "</a>)</span>");
                    }

                    if (item.TotalDiscount > 0)
                    {
                        html.AppendLine("<span class='order-info'><strong>Chiết khấu:</strong> -" + string.Format("{0:N0}", Convert.ToDouble(item.TotalDiscount)) + "</span>");
                    }
                    if (item.OtherFeeValue != 0)
                    {
                        html.AppendLine("<span class='order-info'><strong>Phí khác:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.OtherFeeValue)) + " (<a href='#feeInfoModal' data-toggle='modal' data-backdrop='static' onclick='onClick_aFeeInfoModal(" + item.ID + ")'>" + item.OtherFeeName.Trim() + "</a>)</span>");
                    }
                    if (item.ShippingType == 4)
                    {
                        if (item.TransportCompanyID != 0)
                        {
                            var transport    = TransportCompanyController.GetTransportCompanyForOrderList(Convert.ToInt32(item.TransportCompanyID));
                            var transportsub = TransportCompanyController.GetReceivePlaceForOrderList(Convert.ToInt32(item.TransportCompanyID), Convert.ToInt32(item.TransportCompanySubID));
                            html.AppendLine("<span class='order-info'><strong>Gửi xe: </strong> " + transport.CompanyName.ToTitleCase() + " (" + transportsub.ShipTo.ToTitleCase() + ")</span>");
                        }
                    }
                    if (!string.IsNullOrEmpty(item.ShippingCode))
                    {
                        string moreInfo = "";
                        if (item.ShippingType == 3 && !String.IsNullOrEmpty(item.ShippingCode))
                        {
                            moreInfo = " (<a href='https://proship.vn/quan-ly-van-don/?isInvoiceFilter=1&amp;generalInfo=" + item.ShippingCode + "' target='_blank'>Xem</a>)";
                        }
                        if (item.ShippingType == 2)
                        {
                            moreInfo = " (Chuyển " + ((item.PostalDeliveryType == 1) ? "thường" : "nhanh") + ")";
                        }
                        if (item.ShippingType == 6 && !String.IsNullOrEmpty(item.ShippingCode))
                        {
                            moreInfo = " (<a href='https://khachhang.giaohangtietkiem.vn/khachhang?code=" + item.ShippingCode + "' target='_blank'>Xem</a>)";
                        }
                        html.AppendLine("<span class='order-info'><strong>Vận đơn:</strong> " + item.ShippingCode + moreInfo + "</span>");
                    }
                    if (item.FeeShipping > 0)
                    {
                        html.AppendLine("<span class='order-info'><strong>Ship:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.FeeShipping)) + "</span>");
                    }
                    if ((item.ShippingType == 4 || item.ShippingType == 5) && !string.IsNullOrEmpty(item.ShipperName))
                    {
                        html.AppendLine("<span class='order-info'><strong>Shipper:</strong> " + item.ShipperName + "</span>");
                    }
                    if (!string.IsNullOrEmpty(item.CouponCode))
                    {
                        html.AppendLine(String.Format("<span class='order-info'><strong>Coupon ({0}):</strong> -{1:N0}</span>", item.CouponCode.Trim().ToUpper(), item.CouponValue));
                    }
                    if (!string.IsNullOrEmpty(item.OrderNote))
                    {
                        html.AppendLine("<span class='order-info'><strong>Ghi chú:</strong> " + item.OrderNote + "</span>");
                    }
                    html.AppendLine("</td>");
                    html.AppendLine("</tr>");
                }
            }
            else
            {
                if (acc.RoleID == 0)
                {
                    html.AppendLine("<tr><td colspan='13'>Không tìm thấy đơn hàng...</td></tr>");
                }
                else
                {
                    html.AppendLine("<tr><td colspan='12'>Không tìm thấy đơn hàng...</td></tr>");
                }
            }
            html.AppendLine("</tbody>");

            ltrList.Text = html.ToString();
        }
Пример #18
0
        public void pagingall(List <OrderList> acs, PaginationMetadataModel page)
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            StringBuilder html = new StringBuilder();

            html.Append("<thead>");
            html.Append("<tr>");
            html.Append("    <th><input id='checkPrintAll' type='checkbox' onchange='changeCheckPrintAll($(this).prop(`checked`))'/></th>");
            html.Append("    <th>Mã</th>");
            html.Append("    <th class='col-customer'>Khách hàng</th>");
            html.Append("    <th>Mua</th>");
            html.Append("    <th>Kiểu giao</th>");
            html.Append("    <th>Thanh toán</th>");
            html.Append("    <th>Shipper</th>");
            html.Append("    <th>Trạng thái</th>");
            html.Append("    <th>Tổng tiền</th>");
            html.Append("    <th>COD</th>");
            html.Append("    <th>Ship</th>");
            html.Append("    <th>Ngày giao</th>");
            html.Append("    <th>Đợt</th>");
            html.Append("    <th>Ngày hoàn tất</th>");

            if (acc.RoleID == 0 || acc.Username == "nhom_zalo406" || acc.Username == "hotline" || acc.Username == "nhom_zalo502")
            {
                html.Append("    <th>Nhân viên</th>");
            }
            html.Append("    <th></th>");
            html.Append("</tr>");
            html.Append("</thead>");

            html.Append("<tbody>");
            if (acs.Count > 0)
            {
                PageCount = page.totalPages;
                Int32 Page = page.currentPage;

                foreach (var item in acs)
                {
                    // Insert transfer bank info for tr tag
                    var TrTag = new StringBuilder();
                    TrTag.AppendLine("<tr ");
                    TrTag.AppendLine(String.Format("data-orderid='{0}' ", item.ID));
                    TrTag.AppendLine(String.Format("data-paymenttype='{0}' ", item.PaymentType));
                    TrTag.AppendLine(String.Format("data-shippingtype='{0}' ", item.ShippingType));
                    TrTag.AppendLine(String.Format("data-deliverystatus='{0}' ", item.DeliveryStatus));
                    TrTag.AppendLine(String.Format("data-invoiceimage='{0}' ", item.InvoiceImage));
                    TrTag.AppendLine(String.Format("data-coloford='{0:#,###}' ", item.CollectionOfOrder.HasValue ? item.CollectionOfOrder : Convert.ToDecimal(item.TotalPrice - item.TotalRefund)));
                    TrTag.AppendLine(String.Format("data-shipperid='{0}' ", item.ShipperID));
                    TrTag.AppendLine(String.Format("data-cosofdev='{0:#,###}' ", item.CostOfDelivery.HasValue ? item.CostOfDelivery :  Convert.ToDecimal(item.FeeShipping)));
                    TrTag.AppendLine(String.Format("data-deliverydate='{0:dd/MM/yyyy HH:mm}' ", item.DeliveryDate));
                    TrTag.AppendLine(String.Format("data-shippernote='{0}' ", item.ShipNote));
                    TrTag.AppendLine(String.Format("data-transfercompany='{0}' ", item.TransportCompanyID));
                    TrTag.AppendLine(String.Format("data-deliverytimes='{0}' ", item.DeliveryTimes));
                    TrTag.AppendLine("/>");

                    html.Append(TrTag.ToString());
                    // Hình thức giáo hàng là chuyển xe
                    // và gói hàng chưa được giao hoặc đang giao
                    if (item.CheckDelivery.HasValue && item.CheckDelivery.Value)
                    {
                        html.Append("   <td><input type='checkbox' onchange='changeCheckPrint($(this))' checked/></td>");
                    }
                    else
                    {
                        html.Append("   <td><input type='checkbox' onchange='changeCheckPrint($(this))'/></td>");
                    }
                    html.Append("   <td><a href='/thong-tin-don-hang?id=" + item.ID + "'>" + item.ID + "</a></td>");
                    if (!string.IsNullOrEmpty(item.Nick))
                    {
                        html.Append("   <td data-title='Khách hàng' class='customer-td'><a class='col-customer-name-link' href='/thong-tin-don-hang?id=" + item.ID + "'>" + item.CustomerName.ToTitleCase() + "</a><br><span class='name-bottom-nick'>Nick: " + item.Nick.ToTitleCase() + "</span></td>");
                    }
                    else
                    {
                        html.Append("   <td data-title='Khách hàng' class='customer-td'><a class='col-customer-name-link' href='/thong-tin-don-hang?id=" + item.ID + "'>" + item.CustomerName.ToTitleCase() + "</a></td>");
                    }
                    html.Append("   <td data-title='Đã mua'>" + item.Quantity + "</td>");
                    html.Append("   <td data-title='Kiểu giao'>" + PJUtils.ShippingType(Convert.ToInt32(item.ShippingType)) + "</td>");
                    html.Append("   <td data-title='Kiểu thanh toán'>" + PJUtils.PaymentType(Convert.ToInt32(item.PaymentType)) + "</td>");
                    html.Append("   <td data-title='Shipper' id='shiperName'>" + item.ShipperName + "</td>");
                    html.Append("   <td data-title='Trạng thái' id='deliveryStatus'>" + PJUtils.DeliveryStatus(Convert.ToInt32(item.DeliveryStatus)) + "</td>");
                    // Tổng đơn hàng
                    html.Append("   <td data-title='Tổng đơn'><strong>" + String.Format("{0:#,###}", Convert.ToDouble(item.TotalPrice - item.TotalRefund)) + "</strong></td>");
                    // Số tiền đã thu chỉ hiện khi thanh toán kiểu thu hộ và đơn hàng đã giao hoặc đang giao
                    if (item.PaymentType == 3 && (item.DeliveryStatus == 1 || item.DeliveryStatus == 3))
                    {
                        html.Append("   <td data-title='COD' id='colOfOrd'><strong>" + String.Format("{0:#,###}", item.CollectionOfOrder) + "</strong></td>");
                    }
                    else
                    {
                        html.Append("   <td data-title='COD' id='colOfOrd'></td>");
                    }
                    // Phí giao hàng khi nhân viên giao
                    if (item.ShippingType == 5 && (item.DeliveryStatus == 1 || item.DeliveryStatus == 3) && item.CostOfDelivery != 0)
                    {
                        html.Append("   <td data-title='Ship' id='cosOfDel'><strong>" + String.Format("{0:#,###}", item.CostOfDelivery) + "</strong></td>");
                    }
                    else
                    {
                        html.Append("   <td data-title='Ship' id='cosOfDel'></td>");
                    }
                    // Ngày giao
                    if (item.DeliveryStatus == 1)
                    {
                        html.Append("   <td data-title='Ngày giao' id='delDate'>" + String.Format("{0:dd/MM HH:mm}", item.DeliveryDate) + "</td>");
                    }
                    else
                    {
                        html.Append("   <td data-title='Ngày giao' id='delDate'></td>");
                    }
                    // Đợt giao
                    if (item.DeliveryTimes > 0)
                    {
                        html.Append("   <td data-title='Đợt giao' id='deliveryTimes'>Đợt " + item.DeliveryTimes.ToString() + "</td>");
                    }
                    else
                    {
                        html.Append("   <td data-title='Đợt giao' id='deliveryTimes'></td>");
                    }
                    // Ngày hoàn tất đơn
                    string datedone = "";
                    if (item.ExcuteStatus == 2)
                    {
                        datedone = string.Format("{0:dd/MM}", item.DateDone);
                    }
                    html.Append("   <td data-title='Ngày hoàn tất'>" + datedone + "</td>");
                    html.Append("   <td data-title='Nhân viên tạo đơn'>" + item.CreatedBy + "</td>");
                    html.Append("   <td data-title='Thao tác' class='update-button' id='updateButton'>");

                    if (acc.RoleID == 0)
                    {
                        html.Append("       <button type='button' class='btn primary-btn h45-btn' data-toggle='modal' data-target='#TransferBankModal' data-backdrop='static' data-keyboard='false' title='Cập nhật thông tin chuyển khoản'><span class='glyphicon glyphicon-edit'></span></button>");
                    }

                    if (item.DeliveryStatus == 1 && !string.IsNullOrEmpty(item.InvoiceImage))
                    {
                        html.Append("       <a id='downloadInvoiceImage' href='javascript:;' onclick='openImageInvoice($(this))' data-link='" + item.InvoiceImage + "' title='Biên nhận gửi hàng' class='btn primary-btn btn-blue h45-btn'><i class='fa fa-file-text-o' aria-hidden='true'></i></a>");
                    }
                    html.Append("   </td>");
                    html.Append("</tr>");

                    // thông tin thêm
                    html.Append("<tr class='tr-more-info'>");
                    html.Append("   <td colspan='2' data-title='Thông tin thêm'></td>");
                    html.Append("   <td colspan='14'>");

                    if (item.ShippingType == 4)
                    {
                        if (item.TransportCompanyID != 0)
                        {
                            var transport    = TransportCompanyController.GetTransportCompanyForOrderList(Convert.ToInt32(item.TransportCompanyID));
                            var transportsub = TransportCompanyController.GetReceivePlaceForOrderList(Convert.ToInt32(item.TransportCompanyID), Convert.ToInt32(item.TransportCompanySubID));
                            html.Append("<span class='order-info'><strong>Gửi xe: </strong> " + transport.CompanyName.ToTitleCase() + " (" + transportsub.ShipTo.ToTitleCase() + ")</span>");
                        }
                    }
                    if (item.TotalRefund != 0)
                    {
                        html.Append("<span class='order-info'><strong>Đổi trả:</strong> -" + string.Format("{0:N0}", item.TotalRefund) + " (<a href='xem-don-hang-doi-tra?id=" + item.RefundsGoodsID + "' target='_blank'>Xem đơn " + item.RefundsGoodsID + "</a>)</span>");
                    }
                    if (item.TotalDiscount > 0)
                    {
                        html.Append("<span class='order-info'><strong>Chiết khấu:</strong> -" + string.Format("{0:N0}", Convert.ToDouble(item.TotalDiscount)) + "</span>");
                    }
                    if (item.OtherFeeValue != 0)
                    {
                        html.Append("<span class='order-info'><strong>Phí khác:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.OtherFeeValue)) + " (<a href='#feeInfoModal' data-toggle='modal' data-backdrop='static' onclick='openFeeInfoModal(" + item.ID + ")'>" + item.OtherFeeName.Trim() + "</a>)</span>");
                    }
                    if (item.FeeShipping > 0)
                    {
                        html.Append("<span class='order-info'><strong>Ship:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.FeeShipping)) + "</span>");
                    }
                    if (!string.IsNullOrEmpty(item.CouponCode))
                    {
                        html.Append(String.Format("<span class='order-info'><strong>Coupon ({0}):</strong> -{1:N0}</span>", item.CouponCode.Trim().ToUpper(), item.CouponValue));
                    }
                    if (!string.IsNullOrEmpty(item.OrderNote))
                    {
                        html.Append("<span class='order-info'><strong>Ghi chú:</strong> " + item.OrderNote + "</span>");
                    }
                    html.Append("</td>");
                    html.Append("</tr>");
                }
            }
            else
            {
                if (acc.RoleID == 0)
                {
                    html.Append("<tr><td colspan='14'>Không tìm thấy đơn hàng...</td></tr>");
                }
                else
                {
                    html.Append("<tr><td colspan='13'>Không tìm thấy đơn hàng...</td></tr>");
                }
            }
            html.Append("</tbody>");

            ltrList.Text = html.ToString();
        }
Пример #19
0
        public void LoadData()
        {
            string username = Request.Cookies["userLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            string error = "";

            int ID = Request.QueryString["id"].ToInt(0);

            String rowHtml = String.Empty;

            var order = OrderController.GetByID(ID);

            if (order != null)
            {
                if (order.PaymentStatus == 1)
                {
                    error += "<p>- Đơn hàng này <strong>chưa thanh toán</strong>!</p>";
                }

                if (order.ExcuteStatus != 2)
                {
                    error += "<p>- Đơn hàng này <strong>chưa hoàn tất</strong>!</p>";
                }

                if (order.ShippingType == 1)
                {
                    error += "<p>- Đơn hàng này đang có phương thức giao hàng: <strong>Lấy trực tiếp</strong>. Hãy chuyển sang phương thức khác!</p>";
                }

                string address = "";
                string phone   = "0914615408 - 0918567409";
                string leader  = "";
                var    agent   = AgentController.GetByID(Convert.ToInt32(order.AgentID));

                if (agent != null)
                {
                    address = agent.AgentAddress;
                    leader  = agent.AgentLeader;
                }

                double TotalOrder = Convert.ToDouble(order.TotalPrice);

                if (order.RefundsGoodsID != null)
                {
                    var refund = RefundGoodController.GetByID(Convert.ToInt32(order.RefundsGoodsID));
                    if (refund != null)
                    {
                        TotalOrder = TotalOrder - Convert.ToDouble(refund.TotalPrice);
                    }
                    else
                    {
                        error += "<p>Không tìm thấy đơn hàng đổi trả " + order.RefundsGoodsID.ToString() + " (có thể đã bị xóa khi làm lại đơn đổi trả). Thêm lại đơn hàng đổi trả nhé!</p>";
                    }
                }

                rowHtml += Environment.NewLine + String.Format("<div class=\"table\">");
                rowHtml += Environment.NewLine + String.Format("    <div class=\"top-left\">");
                rowHtml += Environment.NewLine + String.Format("        <p><span>Người gửi: <span class=\"name\">{0}</span></span></p>", leader);
                rowHtml += Environment.NewLine + String.Format("        <p><span>{0}</span></p>", phone);
                rowHtml += Environment.NewLine + String.Format("        <p><span>{0}</span></p>", address);
                rowHtml += Environment.NewLine + String.Format("        <p><span class=\"web\">ANN.COM.VN</span></p>");
                rowHtml += Environment.NewLine + String.Format("    </div>");
                rowHtml += Environment.NewLine + String.Format("    <div class=\"bottom-left\">");
                if (order.PaymentType == 3)
                {
                    rowHtml += Environment.NewLine + String.Format("        <p><span class=\"cod\">Thu hộ: {0}</span></p>", string.Format("{0:N0}", TotalOrder));
                }
                else
                {
                    rowHtml += Environment.NewLine + String.Format("        <p><span class=\"cod\">Thu hộ: KHÔNG</span></p>");
                }

                rowHtml += Environment.NewLine + String.Format("        <p><span>Mã đơn hàng: {0}</span></p>", order.ID);
                rowHtml += Environment.NewLine + String.Format("        <p><span>Nhân viên: {0}</span></p>", order.CreatedBy);

                rowHtml += Environment.NewLine + String.Format("    </div>");
                rowHtml += Environment.NewLine + String.Format("    <div class=\"top-right\">");
                rowHtml += Environment.NewLine + String.Format("        <img class=\"img\" src=\"https://ann.com.vn/wp-content/uploads/ANN-logo-3.png\">");

                var    company                 = TransportCompanyController.GetTransportCompanyByID(Convert.ToInt32(order.TransportCompanyID));
                string transportCompany        = "";
                string transportCompanyPhone   = "";
                string transportCompanyAddress = "";
                string transportCompanyNote    = "";

                string CustomerAddress = order.CustomerAddress;

                if (company != null)
                {
                    transportCompany = "<strong>" + company.CompanyName + "</strong>";
                    if (company.CompanyPhone != "")
                    {
                        transportCompanyPhone = "<span class=\"transport-info\">(" + company.CompanyPhone + ")</span>";
                    }

                    transportCompanyAddress = "<p class=\"transport-info capitalize\">" + company.CompanyAddress + "</p>";

                    if (company.Note != "")
                    {
                        transportCompanyNote = "<span class=\"transport-info capitalize\"> - " + company.Note + "</span>";
                    }

                    var subID  = Convert.ToInt32(order.TransportCompanySubID);
                    var shipto = TransportCompanyController.GetReceivePlaceByID(company.ID, subID);
                    if (shipto != null && subID > 0)
                    {
                        CustomerAddress = "<span class=\"phone\">" + shipto.ShipTo + "</span>";
                    }
                    else
                    {
                        error += "<p>- Đơn hàng này gửi chành xe " + transportCompany + " nhưng <strong>chưa chọn Nơi nhận</strong>!</p>";
                    }
                }

                if (order.ShippingType == 2)
                {
                    string PostalDeliveryType = "Thường";
                    if (order.PostalDeliveryType == 2)
                    {
                        PostalDeliveryType = "Nhanh";
                    }

                    if (!string.IsNullOrEmpty(order.ShippingCode))
                    {
                        rowHtml += Environment.NewLine + String.Format("        <p class=\"delivery\"><span><strong>Gửi Bưu điện - {0}:</strong> {1}</span></p>", PostalDeliveryType, order.ShippingCode);
                    }
                    else
                    {
                        error += "<p>- Đơn hàng này <strong>gửi Bưu điện</strong> nhưng <strong>chưa nhập</strong> MÃ VẬN ĐƠN!</p>";
                    }

                    if (order.PaymentType != 3 && acc.RoleID != 0)
                    {
                        error += "<p>- Đơn hàng này <strong>gửi Bưu điện</strong> nhưng <strong>Không gửi thu hộ</strong>. Nếu có lý do thì báo chị Ngọc xử lý nhé!</p>";
                    }
                }
                else if (order.ShippingType == 3)
                {
                    rowHtml += Environment.NewLine + String.Format("        <p class=\"delivery\"><span>Dịch vụ ship</span></p>");
                    if (!string.IsNullOrEmpty(order.ShippingCode))
                    {
                        rowHtml += Environment.NewLine + String.Format("        <p class=\"delivery\"><span>{0}</span></p>", order.ShippingCode);
                    }
                    else
                    {
                        error += "<p>- Đơn hàng này <strong>gửi Dịch vụ ship</strong> nhưng <strong>chưa nhập</strong> MÃ VẬN ĐƠN!</p>";
                    }
                }
                else if (order.ShippingType == 4)
                {
                    if (transportCompany == "")
                    {
                        error += "<p>- Đơn hàng này <strong>gửi xe</strong> nhưng <strong>chưa chọn Chành xe</strong> nào!</p>";
                    }
                    else
                    {
                        rowHtml += Environment.NewLine + String.Format("        <p class=\"delivery\"><span>Gửi xe: {0} {1} {2}</p>", transportCompany, transportCompanyPhone, transportCompanyNote);

                        // Lấy thông tin xe ra gửi
                        rowHtml += Environment.NewLine + String.Format("        {0}", transportCompanyAddress);
                    }
                }
                else if (order.ShippingType == 5)
                {
                    rowHtml += Environment.NewLine + String.Format("        <p class=\"delivery\"><span>Nhân viên giao hàng</span></p>");
                }

                if (order.PaymentType == 3)
                {
                    rowHtml += Environment.NewLine + String.Format("        <p><span class=\"cod\">Thu hộ: {0}</span></p>", string.Format("{0:N0}", TotalOrder));
                }
                else
                {
                    rowHtml += Environment.NewLine + String.Format("        <p><span class=\"cod\">Thu hộ: KHÔNG</span></p>");
                }
                rowHtml += Environment.NewLine + String.Format("    </div>");
                rowHtml += Environment.NewLine + String.Format("    <div class=\"bottom-right\">");
                rowHtml += Environment.NewLine + String.Format("        <p><span>Người nhận: <span class=\"name\">{0}</span></span></p>", order.CustomerName);

                string CustomerPhone2 = "";

                var customer = CustomerController.GetByID(Convert.ToInt32(order.CustomerID));
                if (!string.IsNullOrEmpty(customer.CustomerPhone2))
                {
                    CustomerPhone2 = " - " + customer.CustomerPhone2;
                }

                rowHtml += Environment.NewLine + String.Format("        <p><span>Điện thoại: <span class=\"phone\">{0}{1}</span></span></p>", order.CustomerPhone, CustomerPhone2);
                rowHtml += Environment.NewLine + String.Format("        <p><span>Địa chỉ: <span class=\"address\">{0}</span></span></p>", CustomerAddress);
                rowHtml += Environment.NewLine + String.Format("    </div>");
                rowHtml += Environment.NewLine + String.Format("</div>");
            }
            else
            {
                error += "Không tìm thấy đơn hàng!";
            }

            if (error != "")
            {
                ltrShippingNote.Text = "<h1>Lỗi:</h1>" + error;
            }
            else
            {
                ltrShippingNote.Text = rowHtml;
                ltrPrintButton.Text  = "<div class=\"print-it\">";
                ltrPrintButton.Text += "<a class=\"btn\" href=\"javascript:;\" onclick=\"printIt()\">In phiếu gửi hàng</a>";
                if (order.ShippingType == 4)
                {
                    ltrPrintButton.Text += "<a class=\"btn show-transport-info\" href=\"javascript:;\" onclick=\"showTransportInfo()\">Hiện thông tin nhà xe</a>";
                }
                ltrPrintButton.Text += "</div>";
            }
        }
Пример #20
0
        /// <summary>
        /// Setting init when load page
        /// </summary>
        private void LoadData()
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            string TextSearch  = "";
            string COD         = "";
            string Prepay      = "";
            string CreatedDate = "";
            string Status      = "";

            if (Request.QueryString["textsearch"] != null)
            {
                TextSearch = Request.QueryString["textsearch"].Trim();
            }
            if (Request.QueryString["cod"] != null)
            {
                COD = Request.QueryString["cod"];
            }
            if (Request.QueryString["prepay"] != null)
            {
                Prepay = Request.QueryString["prepay"];
            }
            if (Request.QueryString["createddate"] != null)
            {
                CreatedDate = Request.QueryString["createddate"];
            }
            if (Request.QueryString["status"] != null)
            {
                Status = Request.QueryString["status"];
            }

            txtTextSearch.Text           = TextSearch;
            ddlCOD.SelectedValue         = COD.ToString();
            ddlPrepay.SelectedValue      = Prepay.ToString();
            ddlCreatedDate.SelectedValue = CreatedDate.ToString();
            ddlStatus.SelectedValue      = Status.ToString();

            var rs = TransportCompanyController.Filter(TextSearch);

            if (acc.RoleID == 2)
            {
                rs = rs.Where(x => x.Status == 1).ToList();
            }

            if (acc.RoleID == 0)
            {
                if (Status != "")
                {
                    rs = rs.Where(x => x.Status == Status.ToInt()).ToList();
                }
            }

            if (COD != "")
            {
                rs = rs.Where(x => x.COD == COD.ToBool()).ToList();
            }

            if (Prepay != "")
            {
                rs = rs.Where(x => x.Prepay == Prepay.ToBool()).ToList();
            }

            if (CreatedDate != "")
            {
                DateTime fromdate = DateTime.Today;
                DateTime todate   = DateTime.Now;
                switch (CreatedDate)
                {
                case "today":
                    fromdate = DateTime.Today;
                    todate   = DateTime.Now;
                    break;

                case "yesterday":
                    fromdate = fromdate.AddDays(-1);
                    todate   = DateTime.Today;
                    break;

                case "beforeyesterday":
                    fromdate = DateTime.Today.AddDays(-2);
                    todate   = DateTime.Today.AddDays(-1);
                    break;

                case "week":
                    int days = DateTime.Today.DayOfWeek == DayOfWeek.Sunday ? 7 : (int)DateTime.Today.DayOfWeek;
                    fromdate = fromdate.AddDays(-days + 1);
                    todate   = DateTime.Now;
                    break;

                case "thismonth":
                    fromdate = new DateTime(fromdate.Year, fromdate.Month, 1);
                    todate   = DateTime.Now;
                    break;

                case "7days":
                    fromdate = DateTime.Today.AddDays(-6);
                    todate   = DateTime.Now;
                    break;

                case "30days":
                    fromdate = DateTime.Today.AddDays(-29);
                    todate   = DateTime.Now;
                    break;
                }
                rs = rs.Where(x => x.CreatedDate >= fromdate && x.CreatedDate <= todate).ToList();
            }

            pagingall(rs.Distinct().ToList());

            ltrNumberOfTransport.Text = rs.Count().ToString();
        }
Пример #21
0
        public void LoadData()
        {
            // Fix bug, case setting value for pDiscount on HTML but don't change value
            pDiscount.Value = 1;
            pFeeShip.Value  = 1;

            // Init drop down list ddlFeeType
            var feeTypes = FeeTypeController.getDropDownList();

            feeTypes[0].Text = "Loại Phí";
            ddlFeeType.Items.Clear();
            ddlFeeType.Items.AddRange(feeTypes.ToArray());
            ddlFeeType.DataBind();
            ddlFeeType.SelectedIndex = 0;

            // Init Price Type List
            hdfFeeType.Value = FeeTypeController.getFeeTypeJSON();

            // Init drop down list Excute Status
            var excuteStatus = new List <ListItem>();

            excuteStatus.Add(new ListItem("Đang xử lý", "1"));
            excuteStatus.Add(new ListItem("Đã hoàn tất", "2"));

            ddlExcuteStatus.Items.Clear();
            ddlExcuteStatus.Items.AddRange(excuteStatus.ToArray());
            ddlExcuteStatus.DataBind();
            ddlExcuteStatus.SelectedIndex = 0;

            // Init drop down list Payment Status
            var payStatus = new List <ListItem>();

            payStatus.Add(new ListItem("Chưa thanh toán", "1"));
            payStatus.Add(new ListItem("Thanh toán thiếu", "2"));
            payStatus.Add(new ListItem("Đã thanh toán", "3"));

            ddlPaymentStatus.Items.Clear();
            ddlPaymentStatus.Items.AddRange(payStatus.ToArray());
            ddlPaymentStatus.DataBind();
            ddlPaymentStatus.SelectedIndex = 0;

            // Init drop down list Payment Type
            var payType = new List <ListItem>();

            payType.Add(new ListItem("Tiền mặt", "1"));
            payType.Add(new ListItem("Chuyển khoản", "2"));
            payType.Add(new ListItem("Thu hộ", "3"));
            payType.Add(new ListItem("Công nợ", "4"));

            ddlPaymentType.Items.Clear();
            ddlPaymentType.Items.AddRange(payType.ToArray());
            ddlPaymentType.DataBind();
            ddlPaymentType.SelectedIndex = 1;

            // Init drop down list Bank
            var banks = BankController.getDropDownList();

            banks[0].Text = "Chọn ngân hàng";

            ddlBank.Items.Clear();
            ddlBank.Items.AddRange(banks.ToArray());
            ddlBank.DataBind();

            // Init drop down list Shipping Type
            var shipType = new List <ListItem>();

            shipType.Add(new ListItem("Lấy trực tiếp", "1"));
            shipType.Add(new ListItem("Bưu điện", "2"));
            shipType.Add(new ListItem("Proship", "3"));
            shipType.Add(new ListItem("Chuyển xe", "4"));
            shipType.Add(new ListItem("Nhân viên giao", "5"));
            shipType.Add(new ListItem("GHTK", "6"));
            shipType.Add(new ListItem("Viettel", "7"));

            ddlShippingType.Items.Clear();
            ddlShippingType.Items.AddRange(shipType.ToArray());
            ddlShippingType.DataBind();
            ddlShippingType.SelectedIndex = 3;

            // Init drop down list Bank
            var trans = TransportCompanyController.getDropDownListTrans();

            trans[0].Text = "Chọn chành xe";

            ddlTransportCompanyID.Items.Clear();

            ddlTransportCompanyID.Items.AddRange(trans.ToArray());
            ddlTransportCompanyID.DataBind();
            ddlTransportCompanyID.SelectedIndex = 0;

            ddlTransportCompanySubID.Items.Clear();
            ddlTransportCompanySubID.Items.Add(new ListItem("Chọn nơi nhận", "0"));
            ddlTransportCompanySubID.DataBind();
            ddlTransportCompanySubID.SelectedIndex = 0;
        }
Пример #22
0
        public void pagingall(List <OrderList> acs)
        {
            string username = Request.Cookies["userLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            int PageSize = 30;

            StringBuilder html = new StringBuilder();

            html.Append("<tr>");
            html.Append("    <th>Mã</th>");
            html.Append("    <th>Loại</th>");
            html.Append("    <th class='col-customer'>Khách hàng</th>");
            html.Append("    <th>Mua</th>");
            html.Append("    <th>Xử lý</th>");
            html.Append("    <th>Thanh toán</th>");
            html.Append("    <th>Thanh toán</th>");
            html.Append("    <th>Giao hàng</th>");
            html.Append("    <th>Tổng tiền</th>");
            if (acc.RoleID == 0)
            {
                html.Append("    <th>Nhân viên</th>");
            }
            html.Append("    <th>Ngày tạo</th>");
            html.Append("    <th>Hoàn tất</th>");
            html.Append("    <th></th>");
            html.Append("</tr>");

            if (acs.Count > 0)
            {
                int TotalItems = acs.Count;
                if (TotalItems % PageSize == 0)
                {
                    PageCount = TotalItems / PageSize;
                }
                else
                {
                    PageCount = TotalItems / PageSize + 1;
                }

                Int32 Page = GetIntFromQueryString("Page");

                if (Page == -1)
                {
                    Page = 1;
                }
                int FromRow = (Page - 1) * PageSize;
                int ToRow   = Page * PageSize - 1;
                if (ToRow >= TotalItems)
                {
                    ToRow = TotalItems - 1;
                }


                for (int i = FromRow; i < ToRow + 1; i++)
                {
                    var item = acs[i];
                    html.Append("<tr>");
                    html.Append("   <td><a href=\"/thong-tin-don-hang?id=" + item.ID + "\">" + item.ID + "</a></td>");
                    html.Append("   <td>" + PJUtils.OrderTypeStatus(Convert.ToInt32(item.OrderType)) + "</td>");

                    if (!string.IsNullOrEmpty(item.Nick))
                    {
                        html.Append("   <td><a class=\"col-customer-name-link capitalize\" href=\"/thong-tin-don-hang?id=" + item.ID + "\">" + item.Nick + "</a><br><span class=\"name-bottom-nick\">(" + item.CustomerName + ")</span></td>");
                    }
                    else
                    {
                        html.Append("   <td><a class=\"col-customer-name-link capitalize\" href=\"/thong-tin-don-hang?id=" + item.ID + "\">" + item.CustomerName + "</a></td>");
                    }

                    html.Append("   <td>" + item.Quantity + "</td>");
                    html.Append("   <td>" + PJUtils.OrderExcuteStatus(Convert.ToInt32(item.ExcuteStatus)) + "</td>");
                    html.Append("   <td>" + PJUtils.OrderPaymentStatus(Convert.ToInt32(item.PaymentStatus)) + "</td>");
                    html.Append("   <td>" + PJUtils.PaymentType(Convert.ToInt32(item.PaymentType)) + "</td>");
                    html.Append("   <td>" + PJUtils.ShippingType(Convert.ToInt32(item.ShippingType)) + "</td>");
                    html.Append("   <td><strong>" + string.Format("{0:N0}", Convert.ToDouble(item.TotalPrice)) + "</strong></td>");

                    if (acc.RoleID == 0)
                    {
                        html.Append("   <td>" + item.CreatedBy + "</td>");
                    }

                    string date = string.Format("{0:dd/MM}", item.CreatedDate);
                    html.Append("   <td>" + date + "</td>");

                    string datedone = "";
                    if (item.ExcuteStatus == 2)
                    {
                        datedone = string.Format("{0:dd/MM}", item.DateDone);
                    }
                    html.Append("   <td>" + datedone + "</td>");

                    html.Append("   <td>");
                    html.Append("       <a href=\"/print-invoice?id=" + item.ID + "\" title=\"In hóa đơn\" target=\"_blank\" class=\"btn primary-btn h45-btn\"><i class=\"fa fa-print\" aria-hidden=\"true\"></i></a>");
                    html.Append("       <a href=\"/print-shipping-note?id=" + item.ID + "\" title=\"In phiếu gửi hàng\" target=\"_blank\" class=\"btn primary-btn btn-red h45-btn\"><i class=\"fa fa-file-text-o\" aria-hidden=\"true\"></i></a>");
                    html.Append("       <a href=\"/chi-tiet-khach-hang?id=" + item.CustomerID + "\" title=\"Thông tin khách hàng " + item.CustomerName + "\" target=\"_blank\" class=\"btn primary-btn btn-black h45-btn\"><i class=\"fa fa-user-circle\" aria-hidden=\"true\"></i></a>");
                    html.Append("   </td>");
                    html.Append("</tr>");

                    // thông tin thêm

                    html.Append("<tr class='tr-more-info'>");
                    html.Append("   <td colspan='2'>");
                    html.Append("   </td>");
                    html.Append("   <td colspan='11'>");

                    if (item.RefundsGoodsID != null)
                    {
                        var refund = RefundGoodController.GetByID(Convert.ToInt32(item.RefundsGoodsID));
                        if (refund != null)
                        {
                            html.Append("<span class='order-info'><strong>Trừ hàng trả:</strong> " + string.Format("{0:N0}", Convert.ToDouble(refund.TotalPrice)) + " (<a href='xem-don-hang-doi-tra?id=" + item.RefundsGoodsID + "' target='_blank'>Xem đơn " + item.RefundsGoodsID + "</a>)</span>");
                        }
                    }
                    if (item.TotalDiscount > 0)
                    {
                        html.Append("<span class='order-info'><strong>Chiết khấu:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.TotalDiscount)) + "</span>");
                    }
                    if (item.OtherFeeValue != 0)
                    {
                        html.Append("<span class='order-info'><strong>Phí khác:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.OtherFeeValue)) + " (" + item.OtherFeeName.Trim() + ")</span>");
                    }
                    if (item.FeeShipping > 0)
                    {
                        html.Append("<span class='order-info'><strong>Phí vận chuyển:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.FeeShipping)) + "</span>");
                    }
                    if (!string.IsNullOrEmpty(item.ShippingCode))
                    {
                        string moreInfo = "";
                        if (item.ShippingType == 3)
                        {
                            moreInfo = " (<a href='https://proship.vn/quan-ly-van-don/?isInvoiceFilter=1&amp;generalInfo=" + item.ShippingCode + "' target='_blank'>Xem</a>)";
                        }
                        if (item.ShippingType == 2)
                        {
                            moreInfo = " (Chuyển " + ((item.PostalDeliveryType == 1) ? "thường" : "nhanh") + ")";
                        }
                        html.Append("<span class='order-info'><strong>Mã vận đơn:</strong> " + item.ShippingCode + moreInfo + "</span>");
                    }
                    if (item.ShippingType == 4)
                    {
                        if (item.TransportCompanyID != 0)
                        {
                            var transport    = TransportCompanyController.GetTransportCompanyByID(Convert.ToInt32(item.TransportCompanyID));
                            var transportsub = TransportCompanyController.GetReceivePlaceByID(Convert.ToInt32(item.TransportCompanyID), Convert.ToInt32(item.TransportCompanySubID));
                            html.Append("<span class='order-info'><strong>Gửi xe: </strong> " + transport.CompanyName + " (" + transportsub.ShipTo + ")</span>");
                        }
                    }
                    if (!string.IsNullOrEmpty(item.OrderNote))
                    {
                        html.Append("<span class='order-info'><strong>Ghi chú:</strong> " + item.OrderNote + "</span>");
                    }
                    html.Append("   </td>");
                    html.Append("</tr>");
                }
            }
            else
            {
                if (acc.RoleID == 0)
                {
                    html.Append("<tr><td colspan=\"13\">Không tìm thấy đơn hàng...</td></tr>");
                }
                else
                {
                    html.Append("<tr><td colspan=\"12\">Không tìm thấy đơn hàng...</td></tr>");
                }
            }

            ltrList.Text = html.ToString();
        }
Пример #23
0
        public void pagingall(List <OrderList> acs, PaginationMetadataModel page)
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            StringBuilder html = new StringBuilder();

            html.Append("<thead>");
            html.Append("<tr>");
            html.Append("    <th>Mã</th>");
            html.Append("    <th class='col-customer'>Khách hàng</th>");
            html.Append("    <th>Mua</th>");
            html.Append("    <th>Xử lý đơn</th>");
            html.Append("    <th>Ngân hàng</th>");
            html.Append("    <th>Trạng thái</th>");
            html.Append("    <th>Tổng đơn</th>");
            html.Append("    <th>Đã nhận</th>");
            html.Append("    <th>Ngày nhận tiền</th>");
            html.Append("    <th>Hoàn tất đơn</th>");
            if (acc.RoleID == 0)
            {
                html.Append("    <th>Nhân viên</th>");
            }
            html.Append("    <th></th>");
            html.Append("</tr>");
            html.Append("</thead>");

            html.Append("<tbody>");
            if (acs.Count > 0)
            {
                PageCount = page.totalPages;
                Int32 Page = page.currentPage;

                foreach (var item in acs)
                {
                    // Insert transfer bank info for tr tag
                    var TrTag = new StringBuilder();
                    TrTag.AppendLine("<tr ");
                    TrTag.AppendLine(String.Format("data-orderid='{0}' ", item.ID));
                    TrTag.AppendLine(String.Format("data-cusID='{0}' ", item.CustomerID));
                    TrTag.AppendLine(String.Format("data-cusbankid='{0:#}' ", item.CusBankID));
                    TrTag.AppendLine(String.Format("data-cusbankname='{0}' ", item.CusBankName));
                    TrTag.AppendLine(String.Format("data-accbankid='{0:#}' ", item.AccBankID));
                    TrTag.AppendLine(String.Format("data-accbankname='{0}' ", item.AccBankName));
                    TrTag.AppendLine(String.Format("data-statusid='{0:#}' ", item.TransferStatus));
                    TrTag.AppendLine(String.Format("data-statusname='{0}' ", item.StatusName));
                    TrTag.AppendLine(String.Format("data-price='{0:#}' ", Convert.ToDouble(item.TotalPrice - item.TotalRefund)));
                    TrTag.AppendLine(String.Format("data-moneyreceived='{0:#}' ", item.MoneyReceive != 0 ? item.MoneyReceive : Convert.ToDecimal(item.TotalPrice - item.TotalRefund)));
                    TrTag.AppendLine(String.Format("data-doneat='{0:dd/MM/yyyy HH:mm}' ", item.DoneAt));
                    TrTag.AppendLine(String.Format("data-transfernote='{0}' ", item.TransferNote));
                    TrTag.AppendLine("/>");

                    html.Append(TrTag.ToString());
                    html.Append("   <td data-title='Mã đơn'><a href=\"/thong-tin-don-hang?id=" + item.ID + "\">" + item.ID + "</a></td>");
                    if (!string.IsNullOrEmpty(item.Nick))
                    {
                        html.Append("   <td data-title='Khách hàng' class='customer-td'><a class=\"col-customer-name-link\" href=\"/thong-tin-don-hang?id=" + item.ID + "\">" + item.Nick.ToTitleCase() + "</a><br><span class=\"name-bottom-nick\">(" + item.CustomerName.ToTitleCase() + ")</span></td>");
                    }
                    else
                    {
                        html.Append("   <td data-title='Khách hàng' class='customer-td'><a class=\"col-customer-name-link\" href=\"/thong-tin-don-hang?id=" + item.ID + "\">" + item.CustomerName.ToTitleCase() + "</a></td>");
                    }
                    html.Append("   <td data-title='Đã mua'>" + item.Quantity + "</td>");
                    html.Append("   <td data-title='Xử lý đơn'>" + PJUtils.OrderExcuteStatus(Convert.ToInt32(item.ExcuteStatus)) + "</td>");
                    html.Append("   <td data-title='Ngân hàng' id='accBankName'>" + item.AccBankName + "</td>");
                    if (item.TransferStatus == 1)
                    {
                        html.Append("   <td id='statusName' data-title='Trạng thái'><span class='bg-green'>" + item.StatusName + "</span></td>");
                    }
                    else
                    {
                        html.Append("   <td id='statusName' data-title='Trạng thái'><span class='bg-red'>" + (string.IsNullOrEmpty(item.StatusName) ? "Chưa nhận tiền" : item.StatusName) + "</span></td>");
                    }
                    html.Append("   <td data-title='Tổng tiền'><strong>" + String.Format("{0:#,###}", Convert.ToDouble(item.TotalPrice - item.TotalRefund)) + "</strong></td>");
                    if (item.TransferStatus == 1)
                    {
                        html.Append("   <td data-title='Đã nhận' id='moneyReceive'><strong>" + String.Format("{0:#,###}", item.MoneyReceive) + "</strong></td>");
                        html.Append("   <td data-title='Ngày nhận tiền' id='doneAt'>" + String.Format("{0:dd/MM HH:mm}", item.DoneAt) + "</td>");
                    }
                    else
                    {
                        html.Append("   <td data-title='Đã nhận' id='moneyReceive'></td>");
                        html.Append("   <td data-title='Ngày nhận tiền' id='doneAt'></td>");
                    }

                    string datedone = "";
                    if (item.ExcuteStatus == 2)
                    {
                        datedone = string.Format("{0:dd/MM}", item.DateDone);
                    }
                    html.Append("   <td data-title='Ngày hoàn tất đơn'>" + datedone + "</td>");

                    if (acc.RoleID == 0)
                    {
                        html.Append("   <td data-title='Nhân viên tạo đơn'>" + item.CreatedBy + "</td>");
                    }
                    html.Append("   <td data-title='Thao tác' class='update-button'>");
                    html.Append("       <button type='button' class='btn primary-btn h45-btn' data-toggle='modal' data-target='#TransferBankModal' data-backdrop='static' data-keyboard='false' title='Cập nhật thông tin chuyển khoản'><span class='glyphicon glyphicon-edit'></span></button>");
                    html.Append("   </td>");
                    html.Append("</tr>");

                    // thông tin thêm
                    html.Append("<tr class='tr-more-info'>");
                    html.Append("<td colspan='1'></td>");
                    html.Append("<td colspan='12'>");

                    if (item.TotalRefund != 0)
                    {
                        html.Append("<span class='order-info'><strong>Trừ hàng trả:</strong> " + string.Format("{0:N0}", item.TotalRefund) + " (<a href='xem-don-hang-doi-tra?id=" + item.RefundsGoodsID + "' target='_blank'>Xem đơn " + item.RefundsGoodsID + "</a>)</span>");
                    }

                    if (item.TotalDiscount > 0)
                    {
                        html.Append("<span class='order-info'><strong>Chiết khấu:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.TotalDiscount)) + "</span>");
                    }
                    if (item.OtherFeeValue != 0)
                    {
                        html.Append("<span class='order-info'><strong>Phí khác:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.OtherFeeValue)) + " (<a href='#feeInfoModal' data-toggle='modal' data-backdrop='static' onclick='openFeeInfoModal(" + item.ID + ")'>" + item.OtherFeeName.Trim() + "</a>)</span>");
                    }
                    if (item.FeeShipping > 0)
                    {
                        html.Append("<span class='order-info'><strong>Phí vận chuyển:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.FeeShipping)) + "</span>");
                    }
                    if (!string.IsNullOrEmpty(item.ShippingCode))
                    {
                        string moreInfo = "";
                        if (item.ShippingType == 3)
                        {
                            moreInfo = " (<a href='https://proship.vn/quan-ly-van-don/?isInvoiceFilter=1&amp;generalInfo=" + item.ShippingCode + "' target='_blank'>Xem</a>)";
                        }
                        if (item.ShippingType == 2)
                        {
                            moreInfo = " (Chuyển " + ((item.PostalDeliveryType == 1) ? "thường" : "nhanh") + ")";
                        }
                        html.Append("<span class='order-info'><strong>Mã vận đơn:</strong> " + item.ShippingCode + moreInfo + "</span>");
                    }
                    if (item.ShippingType == 4)
                    {
                        if (item.TransportCompanyID != 0)
                        {
                            var transport    = TransportCompanyController.GetTransportCompanyForOrderList(Convert.ToInt32(item.TransportCompanyID));
                            var transportsub = TransportCompanyController.GetReceivePlaceForOrderList(Convert.ToInt32(item.TransportCompanyID), Convert.ToInt32(item.TransportCompanySubID));
                            html.Append("<span class='order-info'><strong>Gửi xe: </strong> " + transport.CompanyName.ToTitleCase() + " (" + transportsub.ShipTo.ToTitleCase() + ")</span>");
                        }
                    }
                    if (!string.IsNullOrEmpty(item.OrderNote))
                    {
                        html.Append("<span class='order-info'><strong>Ghi chú:</strong> " + item.OrderNote + "</span>");
                    }
                    html.Append("</td>");
                    html.Append("</tr>");
                }
            }
            else
            {
                if (acc.RoleID == 0)
                {
                    html.Append("<tr><td colspan=\"13\">Không tìm thấy đơn hàng...</td></tr>");
                }
                else
                {
                    html.Append("<tr><td colspan=\"12\">Không tìm thấy đơn hàng...</td></tr>");
                }
            }
            html.Append("</tbody>");

            ltrList.Text = html.ToString();
        }
Пример #24
0
        public void LoadData()
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            string error = "";

            String rowHtml = String.Empty;

            string PrintButton = "";

            int ID    = Request.QueryString["id"].ToInt(0);
            var order = OrderController.GetByID(ID);

            if (order == null)
            {
                error += "Không tìm thấy đơn hàng!";
            }
            else
            {
                if (order.PaymentStatus == 1)
                {
                    error += "<p>- Đơn hàng này <strong>Chưa thanh toán</strong>!</p>";
                }

                if (order.ExcuteStatus != 2)
                {
                    error += "<p>- Đơn hàng này <strong>Chưa hoàn tất</strong>!</p>";
                }

                if (order.ShippingType == 1 && acc.RoleID != 0)
                {
                    error += "<p>- Đơn hàng này <strong>Lấy trực tiếp</strong>. Hãy chuyển sang phương thức khác hoặc nhờ chị Ngọc in phiếu!</p>";
                }

                if (order.PaymentType == 1 && acc.RoleID != 0)
                {
                    error += "<p>- Đơn hàng này <strong>Thanh toán tiền mặt</strong>. Hãy chuyển sang phương thức khác hoặc nhờ chị Ngọc in phiếu!</p>";
                }

                string address = "";
                string phone   = "";
                string leader  = "";
                var    agent   = AgentController.GetByID(Convert.ToInt32(order.AgentID));

                if (agent != null)
                {
                    address = agent.AgentAddress;
                    leader  = agent.AgentLeader;
                    phone   = agent.AgentPhone;
                }

                double TotalOrder = Convert.ToDouble(order.TotalPrice);

                if (order.RefundsGoodsID != null)
                {
                    var refund = RefundGoodController.GetByID(Convert.ToInt32(order.RefundsGoodsID));
                    if (refund != null)
                    {
                        TotalOrder = TotalOrder - Convert.ToDouble(refund.TotalPrice);
                    }
                    else
                    {
                        error += "<p>Không tìm thấy đơn hàng đổi trả " + order.RefundsGoodsID.ToString() + " (có thể đã bị xóa khi làm lại đơn đổi trả). Thêm lại đơn hàng đổi trả nhé!</p>";
                    }
                }
                var customer = CustomerController.GetByID(order.CustomerID.Value);

                string addressDetail = "";
                string ProvinceName  = "";
                if (customer.ProvinceID.HasValue)
                {
                    var Province = ProvinceController.GetByID(customer.ProvinceID.Value);
                    addressDetail = ", " + Province.Name;
                    ProvinceName  = Province.Name;
                }
                if (customer.DistrictId.HasValue)
                {
                    var District = ProvinceController.GetByID(customer.DistrictId.Value);
                    addressDetail = ", " + District.Name + addressDetail;
                }
                if (customer.WardId.HasValue && customer.WardId.Value > 0)
                {
                    var Ward = ProvinceController.GetByID(customer.WardId.Value);
                    addressDetail = ", " + Ward.Name + addressDetail;
                }

                string CustomerAddress = order.CustomerAddress.ToTitleCase() + addressDetail;
                string DeliveryInfo    = "";
                string ShippingFeeInfo = "";
                string ShipperFeeInfo  = "";

                // BƯU ĐIỆN
                if (order.ShippingType == 2)
                {
                    if (!string.IsNullOrEmpty(order.ShippingCode))
                    {
                        string PostalDeliveryType = "Thường";
                        if (order.PostalDeliveryType == 2)
                        {
                            PostalDeliveryType = "Nhanh";
                        }
                        DeliveryInfo = String.Format("<p class='delivery'><strong>Bưu điện - {0}:</strong> {1}</p><p><img src='{2}'></p>", PostalDeliveryType, order.ShippingCode, createBarcode(order.ShippingCode));
                    }
                    else
                    {
                        error += "<p>- Đơn hàng này <strong>gửi Bưu điện</strong> nhưng <strong>chưa nhập</strong> MÃ VẬN ĐƠN!</p>";
                    }

                    if (order.PaymentType != 3 && acc.RoleID != 0)
                    {
                        PrintButton = "<a class='btn btn-black' href='javascript:;' onclick='printError(`Bưu điện`)'>Không in được</a>";
                    }
                }
                // PROSHIP
                else if (order.ShippingType == 3)
                {
                    if (!string.IsNullOrEmpty(order.ShippingCode))
                    {
                        DeliveryInfo = String.Format("<p class='delivery'><strong>Proship:</strong> {0}</p><p><img src='{1}'></p>", order.ShippingCode, createBarcode(order.ShippingCode));
                    }
                    else
                    {
                        error += "<p>- Đơn hàng này <strong>gửi Proship</strong> nhưng <strong>chưa nhập</strong> MÃ VẬN ĐƠN!</p>";
                    }

                    if (order.PaymentType != 3 && acc.RoleID != 0)
                    {
                        PrintButton = "<a class='btn btn-black' href='javascript:;' onclick='printError(`Proship`)'>Không in được</a>";
                    }
                }
                // GỬI XE
                else if (order.ShippingType == 4)
                {
                    var company = TransportCompanyController.GetTransportCompanyForOrderList(Convert.ToInt32(order.TransportCompanyID));
                    if (company != null)
                    {
                        string transportCompany        = "";
                        string transportCompanyPhone   = "";
                        string transportCompanyAddress = "";
                        string transportCompanyNote    = "";

                        transportCompany = "<strong>" + company.CompanyName.ToTitleCase() + "</strong>";
                        if (company.CompanyPhone != "")
                        {
                            transportCompanyPhone = "<span class='transport-info'>(" + company.CompanyPhone + ")</span>";
                        }
                        transportCompanyAddress = "<span class='transport-info'>" + company.CompanyAddress.ToTitleCase() + "</span>";
                        if (company.Note != "")
                        {
                            transportCompanyNote = "<span class='transport-info capitalize'> - " + company.Note.ToTitleCase() + "</span>";
                        }

                        var subID  = Convert.ToInt32(order.TransportCompanySubID);
                        var shipto = TransportCompanyController.GetReceivePlaceForOrderList(company.ID, subID);
                        if (shipto != null && subID > 0)
                        {
                            if (!String.IsNullOrEmpty(ProvinceName))
                            {
                                CustomerAddress = "<span class='phone'>" + shipto.ShipTo.ToTitleCase() + " (" + ProvinceName + ")</span>";
                            }
                            else
                            {
                                CustomerAddress = "<span class='phone'>" + shipto.ShipTo.ToTitleCase() + "</span>";
                            }
                        }
                        else
                        {
                            error += "<p>- Đơn hàng này gửi xe " + transportCompany + " nhưng <strong>chưa chọn Nơi nhận</strong>!</p>";
                        }

                        DeliveryInfo = String.Format("<p class='delivery'>Xe: {0} {1} {2}</p><p>{3}</p>", transportCompany, transportCompanyPhone, transportCompanyNote, transportCompanyAddress);
                    }
                    else
                    {
                        error += "<p>- Đơn hàng này <strong>gửi xe</strong> nhưng <strong>chưa chọn Chành xe</strong> nào!</p>";
                    }
                }
                // NHÂN VIÊN GIAO
                else if (order.ShippingType == 5)
                {
                    DeliveryInfo = String.Format("<p class='delivery'>Nhân viên giao</p>");
                }
                // GHTK
                else if (order.ShippingType == 6)
                {
                    if (!string.IsNullOrEmpty(order.ShippingCode))
                    {
                        string[] barcode = order.ShippingCode.Split('.');
                        string   newCode = barcode[barcode.Length - 1];
                        if (newCode.Length < 9)
                        {
                            error += "<p>- MÃ VẬN ĐƠN của GHTK phải có ít nhất 9 số ở cuối!</p>";
                        }
                        DeliveryInfo  = String.Format("<p class='delivery'><strong>GHTK:</strong> {0}</p>", order.ShippingCode);
                        DeliveryInfo += String.Format("<p><img src='{0}'></p>", createBarcode(newCode));
                    }
                    else
                    {
                        error += "<p>- Đơn hàng này <strong>gửi GHTK</strong> nhưng <strong>chưa nhập</strong> MÃ VẬN ĐƠN!</p>";
                    }

                    if (order.PaymentType != 3 && acc.RoleID != 0)
                    {
                        PrintButton = "<a class='btn btn-black' href='javascript:;' onclick='printError(`GHTK`)'>Không in được</a>";
                    }
                }
                // VIETTEL
                else if (order.ShippingType == 7)
                {
                    DeliveryInfo = String.Format("<p class='delivery'><strong>Viettel</strong></p>");
                }

                // Lấy tiền THU HỘ
                if (order.PaymentType == 3)
                {
                    ShippingFeeInfo = String.Format("<p class='cod'>Thu hộ: {0}</p>", string.Format("{0:N0}", TotalOrder));
                }
                else
                {
                    ShippingFeeInfo = String.Format("<p class='cod'>Thu hộ: KHÔNG</p>");
                }

                // Lấy phí nhân viên giao
                if (order.ShippingType == 5)
                {
                    if (Convert.ToDouble(order.FeeShipping) > 0)
                    {
                        ShipperFeeInfo = String.Format("<p class='shipping-fee'>Phí ship (đã cộng vào thu hộ): {0}</p>", string.Format("{0:N0}", Convert.ToDouble(order.FeeShipping)));
                    }
                    else
                    {
                        ShipperFeeInfo = String.Format("<p class='shipping-fee'>Phí ship: không</p>");
                    }
                }

                // Lấy số điện thoại 2 nếu có
                string CustomerPhone = order.CustomerPhone;

                if (!string.IsNullOrEmpty(customer.CustomerPhone2))
                {
                    CustomerPhone += " - " + customer.CustomerPhone2;
                }

                // Lấy logo ANN
                string LogoANN = "";
                if (order.ShippingType != 2 && order.ShippingType != 3 && order.ShippingType != 6)
                {
                    LogoANN = String.Format("<img class='img' src='https://ann.com.vn/wp-content/uploads/ANN-logo-3.png'>");
                }

                // Xử lý phiếu GHTK
                string cssClass    = "";
                string bodyClass   = "";
                string destination = "";
                if (order.ShippingType == 6 && !string.IsNullOrEmpty(order.ShippingCode))
                {
                    string[] barcode = order.ShippingCode.Split('.');
                    if (barcode.Length < 6 && barcode.Length > 3)
                    {
                        destination = String.Format("<p>{0}.{1}</p>", barcode[barcode.Length - 3], barcode[barcode.Length - 2]);
                    }
                    else if (barcode.Length >= 6)
                    {
                        destination = String.Format("<p>{0}.{1}.{2}</p>", barcode[barcode.Length - 4], barcode[barcode.Length - 3], barcode[barcode.Length - 2]);
                    }
                }
                if (destination != "")
                {
                    bodyClass = "table-ghtk";
                }

                // HTML in phiếu gửi hàng
                rowHtml += Environment.NewLine + String.Format("<div class='table {0}'>", bodyClass);
                rowHtml += Environment.NewLine + String.Format("    <div class='top-left'>");
                rowHtml += Environment.NewLine + String.Format("        <p>Người gửi: <span class='name'>{0}</span></p>", leader);
                rowHtml += Environment.NewLine + String.Format("        <p>{0}</p>", phone);
                rowHtml += Environment.NewLine + String.Format("        <p class='agent-address'>{0}</p>", address);
                rowHtml += Environment.NewLine + String.Format("        <p class='web'>ANN.COM.VN</p>");
                rowHtml += Environment.NewLine + String.Format("    </div>");
                rowHtml += Environment.NewLine + String.Format("    <div class='bottom-left'>");
                rowHtml += Environment.NewLine + String.Format("    {0}", ShippingFeeInfo);
                rowHtml += Environment.NewLine + String.Format("        <p>Nhân viên: {0}</p>", order.CreatedBy);
                rowHtml += Environment.NewLine + String.Format("        <p><img src='{0}'></p>", createBarcode(order.ID.ToString()));
                rowHtml += Environment.NewLine + String.Format("        <p>Mã đơn hàng: {0}</p>", order.ID);
                rowHtml += Environment.NewLine + String.Format("    </div>");
                rowHtml += Environment.NewLine + String.Format("    <div class='top-right'>");
                rowHtml += Environment.NewLine + String.Format("        {0}", LogoANN);
                rowHtml += Environment.NewLine + String.Format("        {0}", DeliveryInfo);
                rowHtml += Environment.NewLine + String.Format("        {0}", ShippingFeeInfo);
                rowHtml += Environment.NewLine + String.Format("        {0}", ShipperFeeInfo);
                rowHtml += Environment.NewLine + String.Format("    </div>");
                rowHtml += Environment.NewLine + String.Format("    <div class='bottom-right'>");
                rowHtml += Environment.NewLine + String.Format("        <p>Người nhận: <span class='name'>{0}</span></p>", order.CustomerName.ToTitleCase());
                rowHtml += Environment.NewLine + String.Format("        <p>Điện thoại: <span class='phone'>{0}</span></p>", CustomerPhone);
                rowHtml += Environment.NewLine + String.Format("        <p>Địa chỉ: <span class='address'>{0}</span></p>", CustomerAddress);
                rowHtml += Environment.NewLine + String.Format("    </div>");
                if (destination != "")
                {
                    rowHtml += Environment.NewLine + String.Format("    <div class='rotated ghtk'>");
                    rowHtml += Environment.NewLine + String.Format("        {0}", destination);
                    rowHtml += Environment.NewLine + String.Format("    </div>");
                    cssClass = "margin-left-ghtk";
                }
                rowHtml += Environment.NewLine + String.Format("    <div class='rotated {0}'>", cssClass);
                rowHtml += Environment.NewLine + String.Format("        KHO HÀNG SỈ ANN");
                rowHtml += Environment.NewLine + String.Format("    </div>");
                rowHtml += Environment.NewLine + String.Format("</div>");
                // Kết thúc HTML in phiếu gửi hàng
            }

            /// Hiển thị lỗi nếu có
            if (error != "")
            {
                ltrShippingNote.Text = "<h1>Lỗi:</h1>" + error;
            }
            else
            {
                ltrShippingNote.Text = rowHtml;
                ltrPrintButton.Text  = "<div class='print-it'>";
                if (!string.IsNullOrEmpty(PrintButton))
                {
                    ltrPrintButton.Text  += PrintButton;
                    ltrDisablePrint.Text  = "<style type='text/css' media='print'>* { display: none; }</style>";
                    ltrDisablePrint.Text += "<script type='text/javascript'>jQuery(document).bind('keyup keydown', function(e){ if (e.ctrlKey && e.keyCode == 80){ return false;}});</script>";
                }
                else
                {
                    ltrPrintButton.Text += "<a class='btn' href='javascript:;' onclick='printIt()'>In phiếu gửi hàng</a>";
                }
                if (order.ShippingType == 4)
                {
                    ltrPrintButton.Text += "<a class='btn show-transport-info' href='javascript:;' onclick='showTransportInfo()'>Hiện thông tin nhà xe</a>";
                }
                if (order.ShippingType == 3 && order.PaymentType == 3)
                {
                    ltrPrintButton.Text += "<a class='btn show-transport-info' href='https://proship.vn/quan-ly-van-don/?isInvoiceFilter=1&generalInfo=" + order.ShippingCode + "' target='_blank'>Kiểm tra thu hộ trên Proship</a>";
                }
                ltrPrintButton.Text += "</div>";
            }
        }