Exemple #1
0
        private TblSize UpdateOrInsertTblSizeCode(TblSize newRow, int index, out int outindex)
        {
            outindex = index;
            using (var context = new WorkFlowManagerDBEntities())
            {
                var sizeGroupInStyles = context.TblStyles.Any(w => w.TblSizeGroup == newRow.TblSizeGroup);
                if (sizeGroupInStyles)
                {
                    return(newRow);
                }

                var oldRow = (from e in context.TblSizes
                              where e.Iserial == newRow.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    GenericUpdate(oldRow, newRow, context);
                }
                else
                {
                    context.TblSizes.AddObject(newRow);
                }

                context.SaveChanges();
                return(newRow);
            }
        }
Exemple #2
0
 public static MeterPerSize MapToMeterPerSize(TblSize sizeCode)
 {
     return(new MeterPerSize
     {
         Iserial = 0,
         MeterPerSizeCode = sizeCode.SizeCode,
         MeterPerSizeValue = 0,
         SizecodeId = Convert.ToInt32(sizeCode.Id)
     });
 }
Exemple #3
0
        private TblSize DeleteTblSizeCode(TblSize row)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var oldRow = (from e in context.TblSizes
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row);
        }
Exemple #4
0
        public void SaveDetailRow()
        {
            if (SelectedDetailRow != null)
            {
                var valiationCollection = new List <ValidationResult>();

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

                if (isvalid)
                {
                    var rowToSave = new TblSize();
                    rowToSave.InjectFrom(SelectedDetailRow);
                    Client.UpdateOrInsertTblSizeCodeAsync(rowToSave, SelectedMainRow.DetailsList.IndexOf(SelectedDetailRow));
                }
            }
        }
Exemple #5
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);
        }