示例#1
0
        public int GetPageCount(int pageNumber)
        {
            int count = 0;

            for (int i = 0; i < this.rowPerPage && this.rowPerPage * pageNumber + i < this.GoodsCount.Length; i++)
            {
                GoodsCount gc = this.GoodsCount[this.rowPerPage * pageNumber + i];
                count += gc.Count;
            }
            return(count);
        }
示例#2
0
        public double GetPageMoney(int pageNumber)
        {
            double money = 0;

            for (int i = 0; i < this.rowPerPage && this.rowPerPage * pageNumber + i < this.GoodsCount.Length; i++)
            {
                GoodsCount gc = this.GoodsCount[this.rowPerPage * pageNumber + i];
                money += gc.Money * gc.Count;
            }
            return(money);
        }
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            if (this.OrderReturns.Count < 1)
            {
                MessageBox.Show("没有需要打印的数据");
                return;
            }

            try
            {
                string printer = LocalConfigService.GetValue(SystemNames.CONFIG_PRINTER_A4, "");
                if (string.IsNullOrWhiteSpace(printer))
                {
                    throw new Exception("请在系统配置里面,配置要使用的打印机");
                }

                if (MessageBox.Show("是否使用打印机:" + printer + Environment.NewLine + "打印?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
                {
                    return;
                }

                var           pd            = PrintUtil.GetPrinter(printer);
                VendorService vs            = ServiceContainer.GetService <VendorService>();
                var           goodsCountDoc = new OrderReturnOutPrintDocument();

                List <GoodsCount> counts = new List <GoodsCount>();
                foreach (var item in this.OrderReturns)
                {
                    string[] infos = item.Source.GoodsInfo.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
                    if (infos.Length < 4)
                    {
                        MessageBox.Show("退货信息不正确,请检查:" + item.Source.Id);
                        continue;
                    }
                    var vendor = vs.GetByAll(infos[0], "", "", "", 0, 0).First;
                    if (vendor == null)
                    {
                        vendor = vs.GetByAll(infos[0] + infos[1], "", "", "", 0, 0).First;
                    }

                    if (vendor == null)
                    {
                        MessageBox.Show("退货信息厂家找不到,请检查:" + item.Source.Id);
                        continue;
                    }

                    GoodsCount count = null;
                    if (infos.Length >= 5)
                    {
                        count = counts.FirstOrDefault(
                            obj => obj.Vendor == VendorService.FormatVendorName(infos[0]) && obj.Number == infos[1] &&
                            obj.Edtion == infos[2] && obj.Color == infos[3] && obj.Size == infos[4]);
                    }
                    else
                    {
                        count = counts.FirstOrDefault(
                            obj => obj.Vendor == VendorService.FormatVendorName(infos[0]) && obj.Number == infos[1] &&
                            obj.Color == infos[2] && obj.Size == infos[3]);
                    }

                    if (count == null)
                    {
                        count = new GoodsCount
                        {
                            Vendor       = infos[0].Trim(),
                            Number       = infos[1].Trim(),
                            Money        = (int)(item.Source.GoodsMoney / item.Source.Count),
                            Count        = 0,
                            FirstPayTime = item.Source.ProcessTime,
                        };

                        if (infos.Length >= 5)
                        {
                            count.Edtion = infos[2].Trim();
                            count.Color  = infos[3].Trim();
                            count.Size   = infos[4].Trim();
                        }
                        else
                        {
                            count.Edtion = "";
                            count.Color  = infos[2].Trim();
                            count.Size   = infos[3].Trim();
                        }
                        count.Address = vendor.MarketAddressShort;
                        count.Vendor  = VendorService.FormatVendorName(count.Vendor);
                        counts.Add(count);
                    }
                    foreach (var c in counts.Where(obj => obj.Vendor == count.Vendor && obj.Number == count.Number &&
                                                   obj.Edtion == count.Edtion))
                    {
                        //取消最大金额值
                        if (c.Money < count.Money)
                        {
                            c.Money = count.Money;
                        }
                        else
                        {
                            count.Money = c.Money;
                        }
                    }

                    if (count.FirstPayTime >= item.Source.ProcessTime)
                    {
                        count.FirstPayTime = item.Source.ProcessTime;
                    }

                    count.Count += item.Source.Count;
                }
                IComparer <GoodsCount> comparer = new OrderGoodsCountSortByDoor();
                counts.Sort(comparer); //拿货地址
                counts.Sort(comparer); //货号
                counts.Sort(comparer); //版本
                counts.Sort(comparer); //颜色
                counts.Sort(comparer); //尺码
                goodsCountDoc.PageSize = new Size(793, 1122.24);
                goodsCountDoc.SetGoodsCount(counts.ToArray());
                pd.PrintDocument(goodsCountDoc, "退货统计");
                foreach (var item in this.OrderReturns)
                {
                    this.OrderReturnService.Update(item.Source);
                }
                MessageBox.Show("打印完成");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "打印出错");
            }
        }
示例#4
0
        public DataCollectionResponse <GoodsCount> GetOrderGoodsCount(ColorFlag[] flags, string shipper, DateTime startTime, DateTime endTime, int pageIndex, int pageSize)
        {
            ISession session = null;

            try
            {
                string f = string.Join(" or ", flags.Select(obj => "PopFlag=" + ((int)obj).ToString()));
                if (string.IsNullOrWhiteSpace(f) == false)
                {
                    f = " and " + "(" + f + ")";
                }

                String hsqlWhere = String.Format("from Order order,OrderGoods orderGoods where order.Id=orderGoods.OrderId and order.Type<>2 and order.PopPayTime>='{0}' and order.PopPayTime<='{1}' and orderGoods.GetedCount<orderGoods.Count and (PopPayType=1 or (PopPayType=2 {2})) and order.State>={3} and order.State<{4} ", this.FormatDateTime(startTime), this.FormatDateTime(endTime), f, (int)OrderState.PAYED, (int)OrderState.SHIPPED);

                if (string.IsNullOrWhiteSpace(shipper) == false)
                {
                    hsqlWhere += " and Shipper like '%" + shipper + "%'";
                }

                String contenthsql = "select order.Id,orderGoods.Vendor,orderGoods.Number,orderGoods.Edtion,orderGoods.Color,orderGoods.Size,orderGoods.Count,orderGoods.GetedCount,orderGoods.Price,order.PopPayTime,orderGoods.State, orderGoods.GoodsId,order.PopType,order.DeliveryCompany ";
                string hsqlData    = contenthsql + hsqlWhere;
                string hsqlCount   = "select count(orderGoods.id) " + hsqlWhere;

                session = OpenSession();
                var query = session.CreateQuery(hsqlData);
                if (pageSize > 0)
                {
                    query.SetFirstResult(pageIndex * pageSize);
                    query.SetMaxResults(pageSize);
                }
                var rs = query.List <object>();
                List <GoodsCount> counts = new List <GoodsCount>();
                foreach (Object list in rs)
                {
                    Object[]   l  = (Object[])list;
                    GoodsCount gc = new GoodsCount();
                    gc.OrderId      = l[0].ToString();
                    gc.Vendor       = l[1].ToString();
                    gc.Number       = l[2].ToString();
                    gc.Edtion       = l[3] == null ? "" : l[3].ToString();
                    gc.Color        = l[4].ToString();
                    gc.Size         = l[5].ToString();
                    gc.Count        = (OrderState)l[10] == OrderState.GETED ? (int)l[6] - (int)l[7] : (int)l[6];
                    gc.Money        = (float)l[8];
                    gc.FirstPayTime = (DateTime)l[9];
                    gc.State        = (OrderState)l[10];
                    gc.GoodsId      = (long)l[11];
                    gc.PopType      = (PopType)l[12];
                    if ((OrderState)l[10] != OrderState.PAYED)
                    {
                        gc.DeliveryCompany = l[13].ToString();
                    }
                    else
                    {
                        gc.DeliveryCompany = "";
                    }

                    if ((int)gc.State < (int)OrderState.PAYED || (int)gc.State >= (int)OrderState.SHIPPED)
                    {
                        continue;
                    }
                    counts.Add(gc);
                }
                var  countQuery = session.CreateQuery(hsqlCount);
                long count      = (long)(countQuery.UniqueResult());
                DataCollectionResponse <GoodsCount> ret = new DataCollectionResponse <GoodsCount>(counts, (int)count);
                return(ret);
            }
            finally
            {
                if (session != null)
                {
                    session.Close();
                }
            }
        }
示例#5
0
        public override DocumentPage GetPage(int pageNumber)
        {
            DrawingVisual visual = new DrawingVisual();
            var           rendor = visual.RenderOpen();

            rendor.DrawRectangle(Brushes.White, null, new Rect(this.PageSize));

            //绘制标题
            double        money      = GetPageMoney(pageNumber);
            double        totalMoney = GetTotalMoney();
            string        strTitle   = string.Format("页码: {0}/{1} 本页数量:{2} 本页金额:{3:F0} 打印时间:{4},打印人员:{5}", pageNumber + 1, this.pageCount, this.GetPageCount(pageNumber), money, this.time.ToString("yyyy-MM-dd HH:mm:ss"), OperatorService.LoginOperator.Number);
            FormattedText textTitle  = CreateText(strTitle, 16, "黑体");

            rendor.DrawText(textTitle, new System.Windows.Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT, TOP_MARGIN + ITEM_MARGIN_HEIGHT));
            double eachItemHeight = textTitle.Height + ITEM_MARGIN_HEIGHT * 2;

            double[] itemWidth = this.GetItemWidth();

            Pen linePen          = new Pen(Brushes.Black, 2);
            int currentPageCount = (pageNumber + 1) == this.PageCount ? (this.GoodsCount.Length - this.rowPerPage * pageNumber) : this.rowPerPage;

            //绘制网格横线
            for (int i = 0; i <= currentPageCount + 1; i++)
            {
                double y = TOP_MARGIN + eachItemHeight + eachItemHeight * i - 1;
                rendor.DrawLine(linePen, new Point(LEFT_MARGIN, y), new Point(this.PageSize.Width - LEFT_MARGIN, y));
            }

            //绘制网格竖线
            double lineHeight = currentPageCount * eachItemHeight + eachItemHeight;

            for (int i = 0; i <= itemWidth.Length; i++)
            {
                double x = LEFT_MARGIN + GetPreWidth(itemWidth, i) - 1;
                rendor.DrawLine(linePen, new Point(x, TOP_MARGIN + eachItemHeight - 1),
                                new Point(x, TOP_MARGIN + eachItemHeight + lineHeight));
            }

            //绘制标题
            var title = this.CreateText("门牌编号", 16, "黑体");

            rendor.DrawText(title,
                            new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 0),
                                      TOP_MARGIN + ITEM_MARGIN_HEIGHT + eachItemHeight));

            title = this.CreateText("日期", 16, "黑体");
            rendor.DrawText(title,
                            new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 1),
                                      TOP_MARGIN + ITEM_MARGIN_HEIGHT + eachItemHeight));

            title = this.CreateText("厂家名称", 16, "黑体");
            rendor.DrawText(title,
                            new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 2),
                                      TOP_MARGIN + ITEM_MARGIN_HEIGHT + eachItemHeight));

            title = this.CreateText("厂家货号", 16, "黑体");
            rendor.DrawText(title,
                            new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 3),
                                      TOP_MARGIN + ITEM_MARGIN_HEIGHT + eachItemHeight));

            title = this.CreateText("版本", 16, "黑体");
            rendor.DrawText(title,
                            new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 4),
                                      TOP_MARGIN + ITEM_MARGIN_HEIGHT + eachItemHeight));

            title = this.CreateText("颜色", 16, "黑体");
            rendor.DrawText(title,
                            new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 5),
                                      TOP_MARGIN + ITEM_MARGIN_HEIGHT + eachItemHeight));

            title = this.CreateText("尺码", 16, "黑体");
            rendor.DrawText(title,
                            new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 6),
                                      TOP_MARGIN + ITEM_MARGIN_HEIGHT + eachItemHeight));

            title = this.CreateText("价格", 16, "黑体");
            rendor.DrawText(title,
                            new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 7),
                                      TOP_MARGIN + ITEM_MARGIN_HEIGHT + eachItemHeight));

            title = this.CreateText("数量", 16, "黑体");
            rendor.DrawText(title,
                            new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 8),
                                      TOP_MARGIN + ITEM_MARGIN_HEIGHT + eachItemHeight));

            title = this.CreateText("备注", 16, "黑体");
            rendor.DrawText(title,
                            new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 9),
                                      TOP_MARGIN + ITEM_MARGIN_HEIGHT + eachItemHeight));

            //绘制数据
            for (int i = 0; i < this.rowPerPage && this.rowPerPage * pageNumber + i < this.GoodsCount.Length; i++)
            {
                GoodsCount gc = this.GoodsCount[this.rowPerPage * pageNumber + i];

                double currentY = TOP_MARGIN + ITEM_MARGIN_HEIGHT + eachItemHeight * 2 + i * eachItemHeight;

                //厂家门牌号
                var doorText = this.CreateText(gc.Address);
                rendor.DrawText(doorText,
                                new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 0), currentY));

                //日期标记
                string mark = "";
                if (DateTime.Now.Subtract(gc.FirstPayTime).TotalHours >= 20)
                {
                    mark = gc.FirstPayTime.ToString("dd-HH") + " ";
                }
                if (gc.PopType == PopType.TMALL || gc.PopType == PopType.CHUCHUJIE)
                {
                    mark += gc.PopType == PopType.TMALL ? "T" : "C";
                }
                if (string.IsNullOrWhiteSpace(mark) == false)
                {
                    var markText = this.CreateText(mark);
                    rendor.DrawText(markText,
                                    new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 1), currentY));
                }

                //厂家名称
                string vendor = gc.Vendor;
                if (vendor.Length > 4)
                {
                    vendor = vendor.Substring(0, 4);
                }
                var vendorText = this.CreateText(vendor);
                rendor.DrawText(vendorText,
                                new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 2), currentY));

                //厂家货号
                var numberText = this.CreateText(gc.Number);
                rendor.DrawText(numberText,
                                new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 3), currentY));

                //版本
                var edtioText = this.CreateText(gc.Edtion);
                rendor.DrawText(edtioText,
                                new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 4), currentY));

                //颜色
                var colorText = this.CreateText(gc.Color);
                rendor.DrawText(colorText,
                                new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 5), currentY));

                //尺码
                var sizeText = this.CreateText(gc.Size);
                rendor.DrawText(sizeText,
                                new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 6), currentY));

                //单价
                var priceText = this.CreateText(gc.Money.ToString("F0"));
                rendor.DrawText(priceText,
                                new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 7), currentY));

                //数量
                var countText = this.CreateText(gc.Count.ToString());
                rendor.DrawText(countText,
                                new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 8), currentY));

                //快递打印在备注那里
                if (string.IsNullOrWhiteSpace(gc.Comment) == false)
                {
                    var dText = this.CreateText(gc.Comment);
                    rendor.DrawText(dText,
                                    new Point(LEFT_MARGIN + ITEM_MARGIN_WIDGHT + this.GetPreWidth(itemWidth, 9), currentY));
                }
            }
            rendor.Close();
            return(new DocumentPage(visual, this.PageSize, new System.Windows.Rect(this.PageSize), new System.Windows.Rect(this.PageSize)));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = PagesTitles.ManagerUserTicketEditTitle + BackendHelper.TagToValue("page_title_part");
            OtherMethods.ActiveRightMenuStyleChanche("hlTickets", this.Page);
            Form.DefaultButton = btnCreate.UniqueID;
            AppKey             = Globals.Settings.AppServiceSecureKey;
            FirstUserApiKey    = Globals.Settings.FirstUserApiKey;

            #region Блок доступа к странице
            var userInSession = (Users)Session["userinsession"];
            var rolesList     = Application["RolesList"] as List <Roles>;
            var currentRole   = Role = (Roles)rolesList.SingleOrDefault(u => u.Name.ToLower() == userInSession.Role.ToLower());
            if (currentRole.PageUserTicketEdit != 1)
            {
                Response.Redirect("~/Error.aspx?id=1");
            }
            #endregion

            #region Блок доступа к данным на странице
            IsVisibleUserProfileData = true;
            IsVisibleUserAccountData = true;

            if (currentRole.PageUserProfileView == 0)
            {
                IsVisibleUserProfileData = false;
            }

            if (currentRole.PageClientsView == 0)
            {
                IsVisibleUserAccountData = false;
            }

            trUserProfileData.Visible = IsVisibleUserProfileData;
            trUserAccountData.Visible = IsVisibleUserAccountData;
            #endregion

            #region  едирект на страницу всех заявок если заявки нет
            if (Page.Request.Params["id"] == null || Page.Request.Params["id"] == String.Empty)
            {
                Page.Response.Redirect("~/ManagerUI/Menu/Tickets/UserTicketView.aspx");
            }
            #endregion

            if (!IsPostBack)
            {
                #region Загрузка tickets по SecureID или FullSecureID. Метод на очистку.
                DAL.DataBaseObjects.Tickets ticket;
                if (Page.Request.Params["id"].Length > 7)
                {
                    ticket = new DAL.DataBaseObjects.Tickets {
                        FullSecureID = Page.Request.Params["id"]
                    };
                    ticket.GetByFullSecureId();
                }
                else
                {
                    ticket = new DAL.DataBaseObjects.Tickets {
                        SecureID = Page.Request.Params["id"]
                    };
                    ticket.GetBySecureId();
                }
                #endregion

                #region Создание форм для груза
                GoodsCount = GoodsHelper.GoodsCount(ticket.FullSecureID);
                hfHowManyControls.Value = GoodsCount.ToString();
                AddGodsInPanel(GoodsCount);
                #endregion

                #region Заполнение созданных формы
                var goods = new Goods {
                    TicketFullSecureID = ticket.FullSecureID
                };
                var ds            = goods.GetAllItems("ID", "ASC", "TicketFullSecureID");
                var goodsIterator = 1;
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    var tbGoodsDescription = (TextBox)pnlBooks.FindControl("tbGoodsDescription" + goodsIterator);
                    var tbGoodsModel       = (TextBox)pnlBooks.FindControl("tbGoodsModel" + goodsIterator);
                    var tbGoodsNumber      = (TextBox)pnlBooks.FindControl("tbGoodsNumber" + goodsIterator);
                    var tbGoodsCost        = (TextBox)pnlBooks.FindControl("tbGoodsCost" + goodsIterator);
                    var hfGoodsID          = (HiddenField)pnlBooks.FindControl("hfGoodsID" + goodsIterator);
                    var hfWithoutAkciza    = (HiddenField)pnlBooks.FindControl("hfWithoutAkciza" + goodsIterator);

                    var hfGoodsNumber      = (HiddenField)pnlBooks.FindControl("hfGoodsNumber" + goodsIterator);
                    var hfGoodsCost        = (HiddenField)pnlBooks.FindControl("hfGoodsCost" + goodsIterator);
                    var hfGoodsDescription = (HiddenField)pnlBooks.FindControl("hfGoodsDescription" + goodsIterator);
                    var hfGoodsModel       = (HiddenField)pnlBooks.FindControl("hfGoodsModel" + goodsIterator);

                    tbGoodsDescription.Text = hfGoodsDescription.Value = row["Description"].ToString();
                    tbGoodsModel.Text       = hfGoodsModel.Value = row["Model"].ToString();
                    tbGoodsNumber.Text      = hfGoodsNumber.Value = row["Number"].ToString();
                    tbGoodsCost.Text        = hfGoodsCost.Value = MoneyMethods.MoneySeparator(row["Cost"].ToString());
                    hfGoodsID.Value         = row["ID"].ToString();
                    hfWithoutAkciza.Value   = row["WithoutAkciza"].ToString();
                    goodsIterator++;
                }
                #endregion

                #region Вывод старых грузов. Метод на очистку.
                if (GoodsCount == 0)
                {
                    lblOldGoods.Visible = true;
                    lblOldGoods.Text    = "<b>" + OtherMethods.GoodsStringFromTicketID(ticket.ID.ToString()) + "</b><br/>";
                }
                #endregion

                #region Инициализация сущностей
                var user = new Users();
                user.ID = Convert.ToInt32(ticket.UserID);
                user.GetById();

                #region Блок конфигурации удаления заявки
                if (currentRole.ActionUserTicketDelete != 1)
                {
                    btnDelete.Visible = false;
                }
                #endregion

                var profile = new UsersProfiles();
                profile.ID = Convert.ToInt32(ticket.UserProfileID);
                profile.GetById();
                #endregion

                #region блок общей информации

                SpecialClient = user.SpecialClient;

                hfID.Value                = ticket.ID.ToString();
                hfDriverID.Value          = ticket.DriverID.ToString();
                hfStatusID.Value          = ticket.StatusID.ToString();
                hfStatusIDOld.Value       = ticket.StatusIDOld.ToString();
                hfStatusDescription.Value = ticket.StatusDescription;
                hfAdmissionDate.Value     = ticket.AdmissionDate.ToString();

                hfUserID.Value          = UserID = ticket.UserID.ToString();
                hfUserDiscount.Value    = user.Discount.ToString();
                hfUserProfileType.Value = profile.TypeID.ToString();
                hfFullSecureID.Value    = ticket.FullSecureID;
                lblID.Text                 = ticket.SecureID;
                hlUser.Text                = user.Family + ' ' + user.Name;
                hlUser.NavigateUrl         = "~/ManagerUI/Menu/Souls/ClientEdit.aspx?id=" + ticket.UserID;
                hlProfile.Text             = profile.TypeID == 1 ? (profile.FirstName + ' ' + profile.LastName) : profile.CompanyName;
                hlProfile.NavigateUrl      = "~/ManagerUI/Menu/Souls/ProfileView.aspx?id=" + ticket.UserProfileID;
                lblProfileType.Text        = UsersProfilesHelper.UserProfileTypeToText(Convert.ToInt32(profile.TypeID));
                lblCreateDate.Text         = OtherMethods.DateConvert(ticket.CreateDate.ToString());
                lblAdmissionDate.Text      = OtherMethods.DateConvert(ticket.AdmissionDate.ToString());
                lblDeliveryDateStatic.Text = OtherMethods.DateConvert(ticket.DeliveryDate.ToString());
                lblIsExchange.Text         = ticket.IsExchange == 0 ? "нет" : "да";
                cbWithoutMoney.Checked     = ticket.WithoutMoney != 0;
                lblNN.Text                 = ticket.PrintNaklInMap == 0 ? "нет" : "да";
                lblPN.Text                 = ticket.PrintNakl == 0 ? "нет" : "да";
                if (String.IsNullOrEmpty(ticket.Comment))
                {
                    tdComment.Visible = false;
                }
                else
                {
                    lblComment.Text = WebUtility.HtmlDecode(ticket.Comment);
                }
                var regionText = CityHelper.CityToTrack(Convert.ToInt32(ticket.CityID), ticket.ID.ToString());
                if (ticket.TrackIDUser != 0 || regionText == "Не задано")
                {
                    ddlUserTrack.Visible = true;
                    lblTrack.Visible     = false;

                    var region = new Tracks();
                    ddlUserTrack.DataSource     = region.GetAllItems();
                    ddlUserTrack.DataTextField  = "Name";
                    ddlUserTrack.DataValueField = "ID";
                    ddlUserTrack.DataBind();
                    ddlUserTrack.Items.Insert(0, new ListItem("Не задано", "0"));
                    ddlUserTrack.SelectedValue = Convert.ToString(ticket.TrackIDUser);
                }
                else
                {
                    lblTrack.Text = regionText;
                }

                if (string.IsNullOrEmpty(lblAdmissionDate.Text))
                {
                    lblAdmissionDate.Text = "Груз пока не на складе";
                }
                #endregion

                #region блок информации, заполняемой пользователем
                AssessedCost         = MoneyMethods.MoneySeparator(ticket.AssessedCost.ToString());
                hfAssessedCost.Value = ticket.AssessedCost.ToString();
                lblAssessedCost.Text = MoneyMethods.MoneySeparator(ticket.AssessedCost.ToString());

                tbDeliveryCost.Text = MoneyMethods.MoneySeparator(ticket.DeliveryCost.ToString());
                ddlRecipientStreetPrefix.SelectedValue = ticket.RecipientStreetPrefix;
                tbRecipientStreet.Text              = ticket.RecipientStreet;
                tbRecipientStreetNumber.Text        = ticket.RecipientStreetNumber;
                tbRecipientKorpus.Text              = ticket.RecipientKorpus;
                tbRecipientKvartira.Text            = ticket.RecipientKvartira;
                tbRecipientPhone.Text               = ticket.RecipientPhone;
                tbRecipientPhone2.Text              = ticket.RecipientPhoneTwo;
                ddlSenderStreetPrefix.SelectedValue = ticket.SenderStreetPrefix;
                tbSenderStreetName.Text             = ticket.SenderStreetName;
                tbSenderStreetNumber.Text           = ticket.SenderStreetNumber;
                tbSenderHousing.Text         = ticket.SenderHousing;
                tbSenderApartmentNumber.Text = ticket.SenderApartmentNumber;
                tbNote.Text               = ticket.Note;
                tbBoxesNumber.Text        = string.IsNullOrEmpty(ticket.BoxesNumber.ToString()) ? "1" : ticket.BoxesNumber.ToString();
                tbDeliveryDate.Text       = Convert.ToDateTime(ticket.DeliveryDate).ToString("dd-MM-yyyy");
                tbRecipientFirstName.Text = ticket.RecipientFirstName;
                tbRecipientLastName.Text  = ticket.RecipientLastName;
                tbRecipientThirdName.Text = ticket.RecipientThirdName;
                tbTtnSeria.Text           = ticket.TtnSeria;
                tbTtnNumber.Text          = ticket.TtnNumber;
                tbOtherDocuments.Text     = ticket.OtherDocuments;
                tbPassportNumber.Text     = ticket.PassportNumber;
                tbPassportSeria.Text      = ticket.PassportSeria;

                if (!String.IsNullOrEmpty(ticket.DeliveryCost.ToString()) && ticket.DeliveryCost != 0)
                {
                    cbIsDeliveryCost.Checked = true;
                }

                //автокомплит наименования
                var titles          = new Titles();
                var availableTitles = titles.GetAllItems("Name", "ASC", null).Tables[0].Rows.Cast <DataRow>().Aggregate(String.Empty, (current, items) => current + ("\"" + items["Name"] + "\","));
                AvailableTitles = availableTitles.Remove(availableTitles.Length - 1);
                #endregion

                #region Заполнение города
                var allCity = Application["CityList"] as List <City>;
                if (allCity != null)
                {
                    tbCity.Text    = CityHelper.CityIDToAutocompleteString(allCity.FirstOrDefault(u => u.ID == ticket.CityID));
                    hfCityID.Value = ticket.CityID.ToString();

                    var senderCity = allCity.First(u => u.ID == ticket.SenderCityID);
                    tbSenderCity.Text    = CityHelper.CityIDToAutocompleteString(senderCity);
                    hfSenderCityID.Value = ticket.SenderCityID.ToString();
                }
                #endregion

                hfWharehouse.Value = ticket.WharehouseId.ToString();

                #region блок информации, заполняемой менеджером
                ddlStatus.DataSource     = DAL.DataBaseObjects.Tickets.TicketStatuses;
                ddlStatus.DataTextField  = "Value";
                ddlStatus.DataValueField = "Key";
                ddlStatus.DataBind();
                ddlStatus.SelectedValue = Convert.ToString(ticket.StatusID);

                var ddrivers = new Drivers {
                    StatusID = 1
                };
                var dataSet5 = ddrivers.GetAllActivatedDrivers();
                dataSet5.Tables[0].Columns.Add("FIOAndID", typeof(string), "'(' + ID + ') ' + FirstName + ' ' + SUBSTRING(LastName,1,1) + '.' +  SUBSTRING(ThirdName,1,1) + '.'");
                ddlDrivers.DataSource     = dataSet5;
                ddlDrivers.DataTextField  = "FIOAndID";
                ddlDrivers.DataValueField = "ID";
                ddlDrivers.DataBind();
                ddlDrivers.Items.Insert(0, new ListItem("Водитель не назначен", "0"));

                tbAgreedCost.Text   = MoneyMethods.MoneySeparator(ticket.AgreedCost.ToString());
                tbGruzobozCost.Text = MoneyMethods.MoneySeparator(ticket.GruzobozCost.ToString());

                #region Блок блокировки полей
                if (currentRole.ActionControlGruzobozCost != 1)
                {
                    tbGruzobozCost.Enabled = false;
                }
                if (currentRole.ActionStatusAdd != 1)
                {
                    ddlStatus.Enabled           = false;
                    tbDeliveryDate.Enabled      = false;
                    tbStatusDescription.Enabled = false;
                }
                if (currentRole.ActionDriverAdd != 1)
                {
                    ddlDrivers.Enabled = false;
                }
                if (currentRole.ActionAllowChangeMoneyAndCourse != 1)
                {
                    tbAgreedCost.Enabled   = false;
                    tbGruzobozCost.Enabled = false;
                }
                #endregion

                //если id водителя 0 или -1 - водитель не назначен
                if (ticket.DriverID != 0 && ticket.DriverID != -1)
                {
                    ddlDrivers.SelectedValue = ticket.DriverID.ToString();
                }
                else
                {
                    ddlDrivers.SelectedValue = "0";
                }

                //если статусы На складе (перенесен), Отказ (у курьера), Возврат (на складе), Отмена (на складе), Отмена то показываем почему
                if (ddlStatus.SelectedValue == "7" || ddlStatus.SelectedValue == "8" || ddlStatus.SelectedValue == "4" || ddlStatus.SelectedValue == "9" || ddlStatus.SelectedValue == "10")
                {
                    lblStatusDescription.Visible = true;
                    tbStatusDescription.Visible  = true;
                    tbStatusDescription.Text     = ticket.StatusDescription;
                }
                #endregion

                #region Ограничения на правку текстбоксов
                //если админ или статусы "Не обработана" или "На складе" или "На складе (перенесено)", или "Отмена" или "Отмена (на складе)" - можно изменять все поля пользователя
                if (currentRole.ActionDisallowEditSomeFieldInTickets != 1 &&
                    (ddlStatus.SelectedValue == "1" || ddlStatus.SelectedValue == "2" || ddlStatus.SelectedValue == "4" || ddlStatus.SelectedValue == "9" || ddlStatus.SelectedValue == "10") &&
                    currentRole.ActionDisallowTicketChangeWithoutManagerInfo != 1)
                {
                    tbCity.Enabled =
                        tbRecipientStreetNumber.Enabled                                                       =
                            tbRecipientKorpus.Enabled                                                         =
                                tbRecipientFirstName.Enabled                                                  =
                                    tbRecipientLastName.Enabled                                               =
                                        tbRecipientThirdName.Enabled                                          =
                                            tbRecipientKvartira.Enabled                                       =
                                                tbRecipientPhone.Enabled                                      =
                                                    tbBoxesNumber.Enabled                                     =
                                                        tbDeliveryDate.Enabled                                =
                                                            tbOtherDocuments.Enabled                          =
                                                                tbTtnNumber.Enabled                           =
                                                                    tbTtnSeria.Enabled                        =
                                                                        tbPassportNumber.Enabled              =
                                                                            tbPassportSeria.Enabled           =
                                                                                tbRecipientPhone2.Enabled     =
                                                                                    tbRecipientStreet.Enabled =
                                                                                        tbNote.Enabled        = true;
                    for (var i = 1; i <= GoodsCount; i++)
                    {
                        var tbGoodsDescription = (TextBox)pnlBooks.FindControl("tbGoodsDescription" + i);
                        var tbGoodsModel       = (TextBox)pnlBooks.FindControl("tbGoodsModel" + i);
                        var tbGoodsNumber      = (TextBox)pnlBooks.FindControl("tbGoodsNumber" + i);
                        tbGoodsDescription.Enabled = true;
                        tbGoodsModel.Enabled       = true;
                        tbGoodsNumber.Enabled      = true;
                    }
                }

                if (currentRole.ActionDisallowTicketChangeWithoutManagerInfo == 1)
                {
                    ddlUserTrack.Enabled         = false;
                    tbRecipientFirstName.Enabled = false;
                    tbRecipientLastName.Enabled  = false;
                    tbRecipientThirdName.Enabled = false;
                }

                //только админ может изменять курсы
                if (currentRole.ActionAllowChangeMoneyAndCourse == 1 && currentRole.ActionDisallowTicketChangeWithoutManagerInfo != 1)
                {
                    cbIsDeliveryCost.Enabled   =
                        tbDeliveryCost.Enabled = true;

                    for (var i = 1; i <= GoodsCount; i++)
                    {
                        var tbGoodsCost = (TextBox)pnlBooks.FindControl("tbGoodsCost" + i);
                        tbGoodsCost.Enabled = true;
                    }
                }
                #endregion
            }

            if (!String.IsNullOrEmpty(hfCityID.Value))
            {
                var coefficientDeviationCost = Convert.ToDouble(BackendHelper.TagToValue("coefficient_deviation_cost"));
                var city = new City {
                    ID = Convert.ToInt32(hfCityID.Value)
                };
                city.GetById();
                var district = new Districts {
                    ID = Convert.ToInt32(city.DistrictID)
                };
                district.GetById();
                lblCityCost.Text         = MoneyMethods.MoneySeparatorForCityTableView((city.DistanceFromCity * Convert.ToDecimal(coefficientDeviationCost)).ToString());
                lblCityDeliveryDate.Text =
                    DistrictsHelper.DeliveryDateStringToRuss(DistrictsHelper.DeliveryDateString(city.DistrictID));
                lblCityDeliveryTerms.Text =
                    DistrictsHelper.DeliveryTermsToRuss(DistrictsHelper.DeliveryTerms(city.DistrictID));
            }
        }