Пример #1
0
        public void initialize()
        {
            UpdatedDate      = 0;
            _viewId          = Guid.NewGuid();
            Warehouses       = DataOpers.getWarehouses();
            Notifications    = DataOpers.getNotifications();
            Providers        = DataOpers.getProviders();
            ReportService    = new SupplyReportService();
            Navigation       = 0;
            CommoditiesLabel = "Товары на исходе";

            #region ComSupVisibility
            ScarceCommoditiesButtonVisibility   = Visibility.Collapsed;
            ScarceCommoditiesVisibility         = Visibility.Visible;
            AllCommoditiesButtonVisibility      = Visibility.Visible;
            AllCommoditiesVisibility            = Visibility.Collapsed;
            AllSuppliesVisibility               = Visibility.Collapsed;
            AllSuppliesButtonVisibility         = Visibility.Visible;
            NonArrangedSuppliesVisibility       = Visibility.Visible;
            NonArrangedSuppliesButtonVisibility = Visibility.Collapsed;
            #endregion

            #region ReportVisibilitySet

            ReportByProviderVisibility           = Visibility.Collapsed;
            ReportByPeriodVisibility             = Visibility.Collapsed;
            ReportByPeriodButtonVisibility       = Visibility.Visible;
            ReportByProviderButtonVisibility     = Visibility.Visible;
            MakeReportByPeriodButtonVisibility   = Visibility.Collapsed;
            MakeReportByProviderButtonVisibility = Visibility.Collapsed;
            FinishVisibility          = Visibility.Collapsed;
            StartVisibility           = Visibility.Collapsed;
            WarehouseReportVisibility = Visibility.Collapsed;
            #endregion

            SupplyLabel = "Неоформленные поставки";

            Start  = DateTime.Now.AddDays(-10);
            Finish = DateTime.Now.AddDays(10);

            ProvidersData = DataOpers.getProviders();
        }
 public UpdateWindowViewModel(DbDataOperations DbOps, Supply sup, User CurUser)
 {
     this.DataOpers = DbOps;
     SelectedSupply = sup;
     //Lines = DataOpers.getSupplyLines(sup.Id);
     Title       = "Просмотр поставки";
     CurrentUser = CurUser;
     Applicant   = DataOpers.getUsers().Where(i => i.Id == sup.ApplicantId).FirstOrDefault().FamName + " " +
                   DataOpers.getUsers().Where(i => i.Id == sup.ApplicantId).FirstOrDefault().FirName;
     SelectArranger();
     SelectArrangementDate();
     Provider       = DataOpers.getProviders().Where(i => i.Id == sup.ProviderId).FirstOrDefault().CompanyName;
     Statuses       = DataOpers.getSupplyStatuses();
     SelectedStatus = Statuses.Where(i => i.Id == sup.StatusId).FirstOrDefault();
     StatusChanger  = 0;
     SetStatus();
     Warehouse = DataOpers.getWarehouses().Where(i => i.Id == sup.WarehouseId).FirstOrDefault().Address;
     fileMan   = new FileManager(DataOpers);
 }
Пример #3
0
        public void CreateForm(Supply sup)
        {
            try
            {
                string FileName = "Заявка на поставку №" + sup.Id + ".pdf";
                iTextSharp.text.Document doc = new iTextSharp.text.Document();
                PdfWriter.GetInstance(doc, new FileStream(FileName, FileMode.Create));

                doc.Open();

                BaseFont             baseFont          = BaseFont.CreateFont("C:/Windows/Fonts/arial.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                var                  arial_italic_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "ariali.ttf");
                BaseFont             ItalicBaseFont    = BaseFont.CreateFont(arial_italic_path, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                iTextSharp.text.Font font       = new iTextSharp.text.Font(baseFont, iTextSharp.text.Font.DEFAULTSIZE, iTextSharp.text.Font.NORMAL);
                iTextSharp.text.Font ItalicFont = new iTextSharp.text.Font(ItalicBaseFont, iTextSharp.text.Font.DEFAULTSIZE, iTextSharp.text.Font.NORMAL);

                Paragraph par = new Paragraph("Кому: " + db.getProviders().Where(i => i.Id == sup.ProviderId).Select(i => i.CompanyName).FirstOrDefault().ToString(), font);
                par.Alignment = Element.ALIGN_RIGHT;
                doc.Add(par);

                string Initials = db.getProviders().Where(i => i.Id == sup.ProviderId).Select(i => i.Initials).FirstOrDefault().ToString();
                string FamName  = db.getProviders().Where(i => i.Id == sup.ProviderId).Select(i => i.FamilyName).FirstOrDefault().ToString();
                if (FamName[FamName.Length - 1] == 'н' || FamName[FamName.Length - 1] == 'в')
                {
                    FamName = FamName + "у";
                }
                string FulName = FamName + " " + Initials;

                par           = new Paragraph("Директору " + FulName, font);
                par.Alignment = Element.ALIGN_RIGHT;
                doc.Add(par);

                par           = new Paragraph("От ООО \"Sirius Smoke\"", font);
                par.Alignment = Element.ALIGN_RIGHT;
                doc.Add(par);

                string warehousename = db.getWarehouses().Where(i => i.Id == sup.WarehouseId).Select(i => i.Address).FirstOrDefault().ToString();

                par           = new Paragraph("г. Иваново, " + warehousename, font);
                par.Alignment = Element.ALIGN_RIGHT;
                doc.Add(par);

                par           = new Paragraph("т. 8 (567) 63-87-69", font);
                par.Alignment = Element.ALIGN_RIGHT;
                doc.Add(par);

                par           = new Paragraph(DateTime.Parse(sup.ApplicationDate.ToString()).ToShortDateString(), font);
                par.Alignment = Element.ALIGN_RIGHT;
                doc.Add(par);

                par           = new Paragraph("ЗАЯВКА", font);
                par.Alignment = Element.ALIGN_CENTER;
                par.SetLeading(font.Size, 2);
                doc.Add(par);

                par           = new Paragraph("на поставку товара", font);
                par.Alignment = Element.ALIGN_CENTER;
                doc.Add(par);

                par = new Paragraph(" ", font);
                doc.Add(par);

                string str = "Прошу зарезервировать и поставить до " + DateTime.Parse(sup.DeliveryDate.ToString()).ToShortDateString() + " следующие наименования товаров:";
                par = new Paragraph(str, font);
                doc.Add(par);

                PdfPTable table = new PdfPTable(4);
                table.SpacingBefore = 20;
                PdfPCell HeaderCell = new PdfPCell(new Phrase("Наименование", font));
                HeaderCell.HorizontalAlignment = 1;
                table.AddCell(HeaderCell);
                HeaderCell = new PdfPCell(new Phrase("Количество", font));
                HeaderCell.HorizontalAlignment = 1;
                table.AddCell(HeaderCell);
                HeaderCell = new PdfPCell(new Phrase("Цена единицы товара, р", font));
                HeaderCell.HorizontalAlignment = 1;
                table.AddCell(HeaderCell);
                HeaderCell = new PdfPCell(new Phrase("Общая стоимость, р", font));
                HeaderCell.HorizontalAlignment = 1;
                table.AddCell(HeaderCell);

                decimal TotalSum      = 0;
                int     TotalQuantity = 0;

                foreach (SupplyLine item in sup.Lines)
                {
                    PdfPCell BasicCell = new PdfPCell(new Phrase(item.CommodityName.ToString(), font));
                    BasicCell.HorizontalAlignment = 1;
                    table.AddCell(BasicCell);
                    BasicCell = new PdfPCell(new Phrase(item.Quantity.ToString() + " шт.", font));
                    BasicCell.HorizontalAlignment = 1;
                    table.AddCell(BasicCell);
                    BasicCell = new PdfPCell(new Phrase((item.Cost).ToString(), font));
                    BasicCell.HorizontalAlignment = 1;
                    table.AddCell(BasicCell);
                    BasicCell = new PdfPCell(new Phrase((item.Cost * item.Quantity).ToString(), font));
                    BasicCell.HorizontalAlignment = 1;
                    table.AddCell(BasicCell);
                    TotalQuantity += item.Quantity;
                    TotalSum      += item.Cost * item.Quantity;
                }
                HeaderCell = new PdfPCell(new Phrase("Итого", font));
                HeaderCell.HorizontalAlignment = 1;
                table.AddCell(HeaderCell);
                HeaderCell = new PdfPCell(new Phrase(TotalQuantity.ToString() + " шт.", font));
                HeaderCell.HorizontalAlignment = 1;
                table.AddCell(HeaderCell);
                HeaderCell = new PdfPCell(new Phrase("", font));
                HeaderCell.HorizontalAlignment = 1;
                table.AddCell(HeaderCell);
                HeaderCell = new PdfPCell(new Phrase(TotalSum.ToString(), font));
                HeaderCell.HorizontalAlignment = 1;
                table.AddCell(HeaderCell);
                table.WidthPercentage = 95;
                doc.Add(table);

                par = new Paragraph("Директор ООО \"Sirius Smoke\"", font);
                font.SetStyle(iTextSharp.text.Font.ITALIC);
                par.Add(new Chunk("                 Воронов", ItalicFont));
                font.SetStyle(iTextSharp.text.Font.NORMAL);
                par.Add(new Chunk("                 Воронов И.С.", font));
                par.Alignment = Element.ALIGN_CENTER;
                par.SetLeading(font.Size, 2);
                doc.Add(par);
                doc.Close();
                MessageBox.Show("Файл заявки \"" + FileName + "\" создан");
            }
            catch (IOException ex)
            {
                MessageBox.Show("Возникла ошибка при записи страниц", ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Возникла ошибка", ex.Message);
            }
        }