public StyleAttachmentChildWindow(TblStyleViewModel style)
        {
            InitializeComponent();

            _viewModel  = new StyleAttachmentViewModel(style);
            DataContext = _viewModel;
        }
예제 #2
0
 public BarcodePrintPreview(TblSalesOrderColorViewModel salesOrderColor, TblStyleViewModel tblStyle, int operation, string printingCode, bool Print)
 {
     InitializeComponent();
     PrintingFlag   = Print;
     PrintingList   = new ObservableCollection <PrintingFabricDefectslist>();
     LayoutSettings = new ObservableCollection <BarcodeLayoutSettings>();
     if (Print)
     {
         webService.BarCodePrintLayoutOperationAsync(operation, printingCode);
         webService.BarCodePrintLayoutOperationCompleted += (s, sv) =>
         {
             foreach (var item in sv.Result)
             {
                 LayoutSettings.Add(MapToLayoutSettings(item));
             }
             DataContext = LayoutSettings.OrderByDescending(x => x.PageHeightProperty).FirstOrDefault();
             LoadThingsPoBarcode(salesOrderColor, tblStyle);
             DialogResult = true;
             Application.Current.RootVisual.SetValue(IsEnabledProperty, true);
         };
     }
 }
예제 #3
0
        public StyleImageViewModel(TblStyleViewModel style)
        {
            Style       = style;
            MainRowList = new SortableCollectionView <TblStyleImageViewModel>();

            GetColors();
            MainRowList.CollectionChanged += MainRowList_CollectionChanged;
            SelectedMainRow = new TblStyleImageViewModel();

            Client.GetTblStyleImageCompleted += (s, sv) =>
            {
                MainRowList.Clear();
                foreach (var row in sv.Result)
                {
                    var newrow = new TblStyleImageViewModel();
                    newrow.InjectFrom(row);
                    newrow.ColorPerRow = row.TblColor1;
                    MainRowList.Add(newrow);
                }
                Loading = false;
            };

            Client.GetTblColorLinkCompleted += (s, sv) =>
            {
                ColorList = new ObservableCollection <TblColor>();
                foreach (var row in sv.Result)
                {
                    ColorList.Add(row.TblColor1);
                }
            };

            Client.MaxIserialOfStyleCompleted += (s, sv) =>
            {
                FolderPath = "Uploads" + "/" + sv.imagePath;

                string folderName = FolderPath + "/" + Style.SeasonPerRow.Ename + "_" + Style.Brand + "_" +
                                    Style.SectionPerRow.Ename;

                var counter = 0;
                foreach (var item in MainRowList)
                {
                    if (item.Iserial == 0)
                    {
                        var maxIserial = sv.Result;

                        item.ImagePath  = folderName + "/" + style.StyleCode + maxIserial + counter + ".png";
                        item.FolderPath = folderName;
                        item.UploadFile(item.ImagePerRow);

                        counter++;
                    }
                }

                var isvalid = false;

                foreach (var tblStyleImageViewModel in MainRowList)
                {
                    isvalid = Validator.TryValidateObject(tblStyleImageViewModel, new ValidationContext(tblStyleImageViewModel, null, null), null, true);

                    if (!isvalid)
                    {
                        return;
                    }
                }

                if (isvalid)
                {
                    var savelist = new ObservableCollection <TblStyleImage>();
                    GenericMapper.InjectFromObCollection(savelist, MainRowList);

                    Client.UpdateOrInsertTblStyleImageAsync(savelist);
                }
            };
            Client.GetTblStyleImageAsync(style.Iserial);
            Client.UpdateOrInsertTblStyleImageCompleted += (s, x) => Client.GetTblStyleImageAsync(style.Iserial);

            Client.DeleteTblStyleImageCompleted += (s, ev) =>
            {
                if (ev.Error != null)
                {
                    throw ev.Error;
                }

                var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                if (oldrow != null)
                {
                    MainRowList.Remove(oldrow);
                }
            };
        }
예제 #4
0
        private void LoadThingsPoBarcode(TblSalesOrderColorViewModel salesOrderColor, TblStyleViewModel tblStyle)
        {
            DisplayBarcodeUsercontrol = new ObservableCollection <DisplayingBarcodeToPrintUserControl>();

            var styleColorSizeLayout = LayoutSettings.SingleOrDefault(x => x.printingPropertiesIserial == 10);
            var colorThemeLayout     = LayoutSettings.SingleOrDefault(x => x.printingPropertiesIserial == 11);
            var deliveryDateLayout   = LayoutSettings.SingleOrDefault(x => x.printingPropertiesIserial == 12);
            var sizeStr = "";

            foreach (var size in salesOrderColor.SalesOrderSizeRatiosList.Where(x => x.ProductionPerSize > 0))
            {
                sizeStr = sizeStr + "_" + size.Size;
            }

            var styleColorSizesStr = tblStyle.StyleCode + "_" +
                                     salesOrderColor.ColorPerRow.Code + "_"
                                     //+ salesOrderColor.SalesOrderSizeRatiosList.Where(x => x.ProductionPerSize > 0).Min(x => x.ProductionPerSize)
                                     + 1
                                     + sizeStr;

            DisplayBarcodeUsercontrol.Add(new DisplayingBarcodeToPrintUserControl(styleColorSizesStr, styleColorSizeLayout, LayoutSettings, null));
            DisplayBarcodeUsercontrol.Add(new DisplayingBarcodeToPrintUserControl(salesOrderColor.ThemePerRow.Ename, colorThemeLayout, LayoutSettings, null));
            DisplayBarcodeUsercontrol.Add(new DisplayingBarcodeToPrintUserControl(salesOrderColor.DeliveryDate.Value.Date.ToShortDateString(), deliveryDateLayout, LayoutSettings, null));

            var newcan = new Canvas();

            foreach (var barcodes in DisplayBarcodeUsercontrol)
            {
                if (PrintingFlag)
                {
                    newcan.Children.Add(barcodes);
                }
                if (!PrintingFlag)
                {
                    CanvasPreview.Children.Add(barcodes);
                }
            }

            if (PrintingFlag)
            {
                print(newcan);
                //     CanvasList.Add(Newcan);
            }
        }
예제 #5
0
        public StyleAttachmentViewModel(TblStyleViewModel style)
        {
            Style           = style;
            MainRowList     = new SortableCollectionView <TblStyleAttachmentViewModel>();
            SelectedMainRow = new TblStyleAttachmentViewModel();

            Client.GetTblStyleAttachmentCompleted += (s, sv) =>
            {
                MainRowList.Clear();
                foreach (var row in sv.Result)
                {
                    var newrow = new TblStyleAttachmentViewModel();
                    newrow.InjectFrom(row);
                    MainRowList.Add(newrow);
                }
                Loading = false;
            };

            Client.MaxIserialOfStyleForAttachmentCompleted += (s, sv) =>
            {
                FolderPath = "Uploads" + "/" + sv.attachmentPath;
                var folderName = FolderPath + "/" + Style.SeasonPerRow.Ename + "_" + Style.Brand + "_" +
                                 Style.SectionPerRow.Ename;

                var counter = 0;
                foreach (var item in MainRowList)
                {
                    if (item.Iserial == 0)
                    {
                        var maxIserial = sv.Result;

                        item.AttachmentPath = folderName + "/" + style.StyleCode + maxIserial + counter + item.AttachmentPerRow.Extension;
                        item.FolderPath     = folderName;
                        item.UploadFile(item.AttachmentPerRow);

                        //using (FileStream fs = File.Create("binary.dat", 2048, FileOptions.None))
                        //{
                        //    BinaryFormatter formatter = new BinaryFormatter();
                        //    string s = "this is a test";
                        //    formatter.Serialize(fs, Encoding.Unicode.GetBytes(s));
                        //}

                        //using (var stream = File.Create(item.AttachmentPathThumbnail))
                        //{
                        //    stream.Write(buffer, 0, buffer.Length);
                        //    stream.Flush();
                        //    stream.Close();

                        //}
                        //var temp = new FileInfo(item.AttachmentPathThumbnail);
                        //item.UploadFile(temp);

                        counter++;
                    }
                }

                var isvalid = false;

                foreach (var tblStyleAttachmentViewModel in MainRowList)
                {
                    isvalid = Validator.TryValidateObject(tblStyleAttachmentViewModel, new ValidationContext(tblStyleAttachmentViewModel, null, null), null, true);

                    if (!isvalid)
                    {
                        return;
                    }
                }

                if (isvalid)
                {
                    var savelist = new ObservableCollection <TblStyleAttachment>();
                    GenericMapper.InjectFromObCollection(savelist, MainRowList);

                    Client.UpdateOrInsertTblStyleAttachmentAsync(savelist);
                }
            };
            Client.GetTblStyleAttachmentAsync(style.Iserial);
            Client.UpdateOrInsertTblStyleAttachmentCompleted += (s, x) => Client.GetTblStyleAttachmentAsync(style.Iserial);

            Client.DeleteTblStyleAttachmentCompleted += (s, ev) =>
            {
                if (ev.Error != null)
                {
                    throw ev.Error;
                }

                var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                if (oldrow != null)
                {
                    MainRowList.Remove(oldrow);
                }
            };
        }