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

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

                Client.SearchSalesOrderColorCompleted += (s, sv) =>
                {
                    if (sv.Result != null)
                    {
                        foreach (var row in sv.Result)
                        {
                            if (!MainRowList.Contains(row))
                            {
                                MainRowList.Add(row);
                            }
                        }
                    }

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

                GetMaindata();
            }
        }
Beispiel #2
0
        private int DeleteTblSalesOrderColor(TblSalesOrderColor row)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var oldRow = (from e in context.TblSalesOrderColors
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }
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();
         }
     }
 }
Beispiel #5
0
        private TblSalesOrderColor UpdateOrInsertTblSalesOrderColor(TblSalesOrderColor newRow, bool save, int index, out int outindex)
        {
            outindex = index;
            using (var context = new WorkFlowManagerDBEntities())
            {
                if (save)
                {
                    context.TblSalesOrderColors.AddObject(newRow);
                    // var SalesOrder= context.TblSalesOrders.FirstOrDefault(x => x.Iserial == newRow.TblSalesOrder);
                    // var PaymentScheduleDetail = context.TblPaymentScheduleDetails.Where(x => x.tbl.TblPaymentSchedule == SalesOrder.TblPaymentSchedule);
                }
                else
                {
                    var oldRow = (from e in context.TblSalesOrderColors.Include("TblColor1").Include("TblSalesOrder1").Include("TblSalesOrder1.TblStyle1.TblLkpSeason1")
                                  where e.Iserial == newRow.Iserial
                                  select e).SingleOrDefault();
                    if (oldRow != null)
                    {
                        GenericUpdate(oldRow, newRow, context);
                        foreach (var row in newRow.TblSalesOrderSizeRatios.ToList())
                        {
                            var oldColorRow = (from e in context.TblSalesOrderSizeRatios
                                               where e.Iserial == row.Iserial || (e.Size == row.Size && e.TblSalesOrderColor == row.TblSalesOrderColor)
                                               select e).SingleOrDefault();
                            if (oldColorRow != null)
                            {
                                row.TblSalesOrderColor = newRow.Iserial;

                                row.TblSalesOrderColor1 = null;
                                GenericUpdate(oldColorRow, row, context);

                                if (oldRow.TblSalesOrder1.Status == 1 && oldRow.TblSalesOrder1.SalesOrderType == 1)
                                {
                                    var group4 = FindOrCreate("TblGroup4",
                                                              new GenericTable
                                    {
                                        Iserial = 0,
                                        Aname   = oldRow.TblSalesOrder1.TblStyle1.TblLkpSeason1.Aname,
                                        Code    = oldRow.TblSalesOrder1.TblStyle1.TblLkpSeason1.Code,
                                        Ename   = oldRow.TblSalesOrder1.TblStyle1.TblLkpSeason1.Ename
                                    });
                                    using (var ccnewcontext = new ccnewEntities())
                                    {
                                        var brandSectionLink =
                                            context.TblLkpBrandSectionLinks.FirstOrDefault(x => x.TblBrand == oldRow.TblSalesOrder1.TblStyle1.Brand && x.TblLkpBrandSection == oldRow.TblSalesOrder1.TblStyle1.TblLkpBrandSection);

                                        var tblitemdownloadDef = ccnewcontext.TblItemDownLoadDefs.FirstOrDefault(
                                            x => x.Code == brandSectionLink.TblItemDownLoadDef);

                                        var salesordertheme =
                                            context.TblSalesOrderColorThemes.FirstOrDefault(
                                                x => x.Iserial == newRow.TblSalesOrderColorTheme);

                                        var tblstylecolorgroup1 =
                                            ccnewcontext.TblStyleColorGroup1.FirstOrDefault(
                                                x =>
                                                x.CODE == salesordertheme.Code &&
                                                x.TblGroup4 == group4 &&
                                                tblitemdownloadDef.iserial == x.TblItemDownloadDef);
                                        if (tblstylecolorgroup1 == null)
                                        {
                                            tblstylecolorgroup1 = new TblStyleColorGroup1
                                            {
                                                ISERIAL            = salesordertheme.Iserial,
                                                CODE               = salesordertheme.Code,
                                                ANAME              = salesordertheme.Aname,
                                                ENAME              = salesordertheme.Ename,
                                                TblGroup4          = group4,
                                                TblItemDownloadDef = tblitemdownloadDef.iserial,
                                            };
                                            ccnewcontext.TblStyleColorGroup1.AddObject(tblstylecolorgroup1);
                                            ccnewcontext.SaveChanges();
                                        }
                                        var retailcolor = FindOrCreate("tblcolor",
                                                                       new GenericTable
                                        {
                                            Iserial = 0,
                                            Aname   = oldRow.TblColor1.Aname,
                                            Code    = oldRow.TblColor1.Code,
                                            Ename   = oldRow.TblColor1.Ename
                                        });
                                        var tblStyleColorGroupLinks = ccnewcontext.TblStyleColorGroupLinks.FirstOrDefault(x => x.Style == oldRow.TblSalesOrder1.TblStyle1.RefStyleCode && x.TblColor == retailcolor);

                                        if (tblStyleColorGroupLinks == null)
                                        {
                                            tblStyleColorGroupLinks = new TblStyleColorGroupLink
                                            {
                                                Style               = oldRow.TblSalesOrder1.TblStyle1.RefStyleCode,
                                                TblColor            = retailcolor,
                                                TblStyleColorGroup1 = tblstylecolorgroup1.ISERIAL,
                                                Notes               = newRow.Notes
                                            };
                                            ccnewcontext.TblStyleColorGroupLinks.AddObject(tblStyleColorGroupLinks);
                                            ccnewcontext.SaveChanges();
                                        }
                                        else
                                        {
                                            tblStyleColorGroupLinks.TblStyleColorGroup1 = tblstylecolorgroup1.ISERIAL;
                                            tblStyleColorGroupLinks.Notes = newRow.Notes;
                                        }
                                        ccnewcontext.SaveChanges();
                                    }
                                }
                            }
                            else
                            {
                                row.TblSalesOrderColor = newRow.Iserial;

                                row.TblSalesOrderColor1 = null;
                                context.TblSalesOrderSizeRatios.AddObject(row);
                            }
                        }
                    }
                }

                context.SaveChanges();
                return(newRow);
            }
        }