Beispiel #1
0
        public SearchStyleViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                Client = new CRUD_ManagerServiceClient();

                MainRowList     = new ObservableCollection <TblStyle>();
                SelectedMainRow = new TblStyle();

                Client.GetTblStyleCompleted += (s, sv) =>
                {
                    if (sv.Result != null)
                    {
                        foreach (var row in sv.Result)
                        {
                            //var newrow = new TblStyle();

                            //newrow.InjectFrom(row);
                            if (!MainRowList.Contains(row))
                            {
                                //var fabric = sv.mainFabricList.FirstOrDefault(x => x.Iserial == newrow.tbl_FabricAttriputes);

                                //if (fabric != null)
                                //{
                                //    newrow.FabricPerRow = fabric;
                                //}
                                //newrow.SeasonPerRow = new GenericTable();
                                //newrow.SizeGroupPerRow = new TblSizeGroup();

                                MainRowList.Add(row);
                            }
                        }
                    }

                    Loading   = false;
                    FullCount = sv.fullCount;
                };

                GetMaindata();
            }
        }
        public void AddNewMainRow(bool checkLastRow)
        {
            if (AllowAdd != true)
            {
                MessageBox.Show(strings.AllowAddMsg);
                return;
            }
            var currentRowIndex = (MainRowList.IndexOf(SelectedMainRow));

            if (checkLastRow)
            {
                var valiationCollection = new List <ValidationResult>();

                var isvalid = Validator.TryValidateObject(SelectedMainRow, new ValidationContext(SelectedMainRow, null, null), valiationCollection, true);

                if (!isvalid)
                {
                    return;
                }
            }

            var sizeRatioList = new ObservableCollection <TblSeasonalMasterListDetail>();

            foreach (var sizeCode in SelectedStyleViewModel.Sizes.OrderBy(x => x.Id))
            {
                sizeRatioList.Add(new TblSeasonalMasterListDetail
                {
                    Size = sizeCode.SizeCode,
                });
            }

            var style = new TblStyle();

            style.InjectFrom(SelectedStyleViewModel.SelectedMainRow);

            var prevRow = new TblSeasonalMasterListViewModel();

            if (currentRowIndex != -1)
            {
                prevRow = MainRowList.ElementAt(currentRowIndex);
            }

            var newrow = new TblSeasonalMasterListViewModel
            {
                TblStyle    = SelectedStyleViewModel.SelectedMainRow.Iserial,
                StylePerRow = style,
            };

            GenericMapper.InjectFromObCollection(newrow.SeasonalMasterListDetail,
                                                 prevRow.SeasonalMasterListDetail.Count() != 0 ? prevRow.SeasonalMasterListDetail : sizeRatioList);

            newrow.ThemePerRow = prevRow.ThemePerRow;

            foreach (var size in newrow.SeasonalMasterListDetail)
            {
                size.ProductionPerSize = 0;
            }

            MainRowList.Insert(currentRowIndex + 1, newrow);
            SelectedMainRow = newrow;
        }
Beispiel #3
0
        public int CreateRetailStyle(int userIserial, TblStyle style, TblSize size, TblColor color, int group2, int group3, int group4, int group5, int group8, int class4, int tblSupplier, int tblcolor, int tblsize, int tblsizegroup, int tblSeason, int retailBrand, string subSeason, bool post, TblSalesOrderColor tblSalesOrderColor, out decimal?price1, out float?Cost, out bool TransactionExist)
        {
            TransactionExist = false;
            price1           = 0;
            Cost             = 0;
            const char addedChar  = '0';
            var        maxiserial = GetMaxIserial("tblitemprice");

            using (var ccnewcontext = new ccnewEntities())
            {
                ccnewcontext.CommandTimeout = 0;
                var barcodeprice = style.BarcodePrice;


                var code = style.RefStyleCode + size.SizeCode.PadLeft(4, addedChar) +
                           color.Code.PadLeft(4, addedChar);
                var   row  = ccnewcontext.TBLITEMprices.FirstOrDefault(x => x.Code == code);
                float cost = 0;
                // 8/8/2017
                if (tblSalesOrderColor.LocalCost != null && tblSalesOrderColor.LocalCost != 0)
                {
                    cost = (float)tblSalesOrderColor.LocalCost;
                }
                else
                {
                    if (style.TargetCostPrice != 0)
                    {
                        cost = (float)style.TargetCostPrice;
                        tblSalesOrderColor.LocalCost = style.TargetCostPrice as decimal?;
                    }
                }
                if (barcodeprice == 0)
                {
                    barcodeprice = style.RetailTargetCostPrice;
                }
                //if (post)
                //{
                //    if (!GetExistPermByUser(userIserial, "UpdateTargetPriceForRetailPo"))
                //    {
                //        cost = 0;
                //    }
                //}
                //else
                //{
                //    if (!GetExistPermByUser(userIserial, "UpdateTargetPriceForCCPo"))
                //    {
                //        cost = 0;
                //    }
                //}
                if (row == null)
                {
                    try
                    {
                        var date = DateTime.Now.ToString("MM/dd/yyyy");
                        if (style.CreationDate != null)
                        {
                            date = style.CreationDate.Value.ToString("MM/dd/yyyy");
                        }
                        if (style.LastUpdatedDate != null)
                        {
                            date = style.LastUpdatedDate.Value.ToString("MM/dd/yyyy");
                        }
                        string referance = style.Brand + style.TblLkpBrandSection1.Code + style.TblLkpSeason1.Code +
                                           style.TblLkpDirection1.Code + (style.TblSubFamily1.Code.PadLeft(4, addedChar)) + style.SerialNo;

                        string specialfield2 = "";
                        if (style.TblFamily1.IncludeSub)
                        {
                            specialfield2 = style.TblSubFamily1.Code.PadLeft(4, addedChar) + style.TblLkpSeason1.ShortCode + style.SerialNo.PadLeft(3, addedChar) + style.TblLkpBrandSection1.TblLkpBrandSectionLinks.FirstOrDefault(w => w.TblBrand == style.Brand && w.TblLkpBrandSection == style.TblLkpBrandSection).ShortCode;
                            //replicate('0',4-len(tblsubfamily.code))+tblsubfamily.code+tbllkpseason.ShortCode+replicate('0',3-len(serialno))+serialno+TblLkpBrandSectionLink.ShortCode
                        }
                        else
                        {
                            specialfield2 = style.TblFamily1.Code.PadLeft(2, addedChar) + style.TblLkpSeason1.ShortCode + style.SerialNo.PadLeft(3, addedChar) + style.TblLkpBrandSection1.TblLkpBrandSectionLinks.FirstOrDefault(w => w.TblBrand == style.Brand && w.TblLkpBrandSection == style.TblLkpBrandSection).ShortCode;
                        }

                        var query =
                            "insert into tblitem (ISerial,Code, AName,EName, SName" +
                            ", TblClass4, TblGroup1, TblGroup2, TblGroup3, TblGroup4, TblGroup5, TblGroup6, TblGroup7" +
                            ", TblUnit, TblGroup8, TblSupplier ,tblcolor,tblsize,tblsizegroup,itemtype,actType,salesprice," +
                            " style,lastChangeDate,tblSeason ,price1," +
                            "price2,price3,price4,ItemStoreGroup,itemdiscgroup,itemcommgroup," +
                            "packcapacity,packname,hasexdate,activeflg,hassets,SpecialFld1,refrance,ItemCost,SpecialFld2) Values(" +
                            " " + maxiserial + ",'" + code + "','" + style.Description + "','" + style.Description + "','" + style.Description + "'," + class4 + "," +
                            " " + style.TblGroup1 + "," + group2 + "," + group3 + "," + group4 + "," + group5 + "," + style.TblGroup6 + ","
                            + style.TblGroup7 + "," + 1 + "," + group8 + "," + tblSupplier + "," + tblcolor + "," + tblsize + "," + tblsizegroup + "," + 4 + "," + 1 + ","
                            + 0 + ",'" + style.RefStyleCode + "'," + date + "," + tblSeason + "," + barcodeprice + "," + style.RetailTargetCostPrice + "," + style.RetailTargetCostPrice + "," + style.RetailTargetCostPrice + ","
                            + retailBrand + "," + 0 + "," + 0 + "," + 1 + "," + "''" + "," + 0 + "," + 0 + "," + 0 + ",'" + subSeason + "' ,'" + referance + "' ," + cost + ",'" + specialfield2 + "')";
                        ccnewcontext.ExecuteStoreCommand(query);

                        ccnewcontext.TblMultipleBcs.AddObject(new TblMultipleBc
                        {
                            tblitem        = maxiserial,
                            TblItemCode    = style.RefStyleCode,
                            barcode        = maxiserial.ToString(),
                            DefaultBarCode = 1
                        });
                        ccnewcontext.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else
                {
                    var storetransrow = ccnewcontext.TBLSTORETRANS.FirstOrDefault(w => w.Tblitem == row.ISerial);
                    if (storetransrow == null)
                    {
                        if (cost != 0)
                        {
                            var query = "UPDATE  tblitem set ItemCost='" + (float?)cost + "' where iserial= '" + row.ISerial + "'";
                            ccnewcontext.ExecuteStoreCommand(query);
                        }

                        row.Price2 = row.Price3 = row.Price4 = (decimal?)style.RetailTargetCostPrice;
                        row.Price1 = (decimal?)barcodeprice;

                        Cost = cost;
                    }
                    else
                    {
                        TransactionExist = true;
                    }
                    row.TblGroup8 = group8;
                    maxiserial    = row.ISerial;
                    ccnewcontext.SaveChanges();
                }
            }
            return(maxiserial);
        }
Beispiel #4
0
 public void PostRetailPoDetail(TblStyle style, TblSalesOrder salesOrder, int retailbrand, int styleIserial, TblSalesOrderSizeRatio size, int poheader, int Dserial, DateTime?deliveryDate, TblSalesOrderColor color)
 {
     using (var ccnewcontext = new ccnewEntities())
     {
         var poheaderMaindetail =
             ccnewcontext.TblPO1MainDetail.FirstOrDefault(
                 x => x.glserial == poheader && x.Dserial == Dserial);
         if (poheaderMaindetail == null)
         {
             poheaderMaindetail = (new TblPO1MainDetail
             {
                 glserial = poheader,
                 Dserial = Dserial,
                 tblitem = styleIserial,
                 Quantity = size.ProductionPerSize,
                 ucostwot = color.LocalCost,
                 totwot = 0,
                 unitvat = 0,
                 ucostwvat = 0,
                 totvat = 0,
                 totpricewvat = 0,
                 AddExp = 0,
                 ItmDis = 0,
                 barcode = "0",
                 QtyRec = 0,
                 ItmCommericalDisc = 0,
                 ItemSalesTax = 0,
                 DeliveryDate = deliveryDate,
             }
                                   );
             ccnewcontext.TblPO1MainDetail.AddObject(poheaderMaindetail);
             ccnewcontext.SaveChanges();
         }
         var poDetail =
             ccnewcontext.TblPO1Detail.FirstOrDefault(
                 x => x.glserial == poheader && x.Dserial == Dserial);
         if (poDetail == null)
         {
             poDetail = (new TblPO1Detail
             {
                 glserial = poheader,
                 Dserial = Dserial,
                 Dserial1 = Dserial,
                 tblitem = styleIserial,
                 Quantity = size.ProductionPerSize,
                 ucostwot = color.LocalCost,
                 totwot = 0,
                 unitvat = 0,
                 ucostwvat = 0,
                 totvat = 0,
                 totpricewvat = 0,
                 AddExp = 0,
                 ItmDis = 0,
                 barcode = "0",
                 QtyRec = 0,
                 ItmCommericalDisc = 0,
                 ItemSalesTax = 0,
                 ItmAdditionalTax = 0,
                 ItmMiscDisc = 0,
                 ItmMiscExp = 0,
                 CashDiscOnVouch = 0,
             }
                         );
             ccnewcontext.TblPO1Detail.AddObject(poDetail);
             ccnewcontext.SaveChanges();
         }
     }
 }