Beispiel #1
0
        private TblColor UpdateOrInsertTblColor(TblColor newRow, bool save, int index, out int outindex)
        {
            outindex = index;
            using (var context = new WorkFlowManagerDBEntities())
            {
                var colorgroup = context.TblLkpColorGroups.FirstOrDefault(w => w.Iserial == newRow.TblLkpColorGroup);
                newRow.ColorItemType = colorgroup.ColorItemType;

                if (save)
                {
                    context.TblColors.AddObject(newRow);
                }
                else
                {
                    var oldRow = (from e in context.TblColors
                                  where e.Iserial == newRow.Iserial
                                  select e).SingleOrDefault();
                    if (oldRow != null)
                    {
                        GenericUpdate(oldRow, newRow, context);
                    }
                }
                context.SaveChanges();
                return(newRow);
            }
        }
Beispiel #2
0
        public async Task <ApiResponse> ColorById(TblColor tblcolor)
        {
            var items = await _context.TblColor.Where(i => i.Id == tblcolor.Id).ToListAsync();

            var ApiResponse = await response.ApiResult("OK", items, "Record Found");

            return(ApiResponse);
        }
Beispiel #3
0
        public async Task <ApiResponse> AddColor(TblColor tblColor)
        {
            _context.TblColor.Add(tblColor);
            await _context.SaveChangesAsync();

            var ApiResponse = await response.ApiResult("OK", new { id = tblColor.Id }, "Add Record");

            return(ApiResponse);
        }
Beispiel #4
0
        private int DeleteTblColor(TblColor row)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var oldRow = (from e in context.TblColors
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }
Beispiel #5
0
        public async Task <ApiResponse> updateColor(TblColor tblColor)
        {
            _context.Entry(tblColor).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                var ApiResponse = await response.ApiResult("OK", new { id = tblColor.Id }, "Update Record");

                return(ApiResponse);
            }
            catch (DbUpdateConcurrencyException ex)
            {
                var ApiResponse = await response.ApiResult("FAILED", new { error = ex }, "Error");

                return(ApiResponse);
            }
        }
Beispiel #6
0
        public SearchColorViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                Client = new CRUD_ManagerServiceClient();

                MainRowList     = new SortableCollectionView <TblColor>();
                SelectedMainRow = new TblColor();

                Client.GetTblColorCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        MainRowList.Add(row);
                    }

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

                GetMaindata();
            }
        }
Beispiel #7
0
        public void SaveMainRow()
        {
            if (AllowAdd != true)
            {
                MessageBox.Show(strings.AllowAddMsg);
                return;
            }

            if (SelectedMainRow != null)
            {
                var valiationCollection = new List <ValidationResult>();

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

                if (isvalid)
                {
                    var save    = SelectedMainRow.Iserial == 0;
                    var saveRow = new TblColor();
                    saveRow.InjectFrom(SelectedMainRow);
                    Loading = true;
                    Client.UpdateOrInsertTblColorAsync(saveRow, save, MainRowList.IndexOf(SelectedMainRow));
                }
            }
        }
Beispiel #8
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 #9
0
        public ColorLinkViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                Client.GetAllBrandsCompleted += (s, sv) =>
                {
                    BrandsList = sv.Result;
                };
                Client.GetAllBrandsAsync(LoggedUserInfo.Iserial);

                var seasonClient = new CRUD_ManagerServiceClient();
                seasonClient.GetGenericCompleted += (s, sv) =>
                {
                    SeasonList = sv.Result;
                };
                seasonClient.GetGenericAsync("TblLkpSeason", "%%", "%%", "%%", "Iserial", "ASC");

                Client.GetTblColorCompleted += (s, sv) =>
                {
                    // ColorsList.Clear();
                    //  GenericMapper.InjectFromObCollection(ColorsList, sv.Result);

                    foreach (var row in sv.Result)
                    {
                        ColorsList.Add(new TblColor().InjectFrom(row) as TblColor);
                    }

                    Loading         = false;
                    DetailFullCount = sv.fullCount;
                };
                Client.GetTblColorLinkCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        //if (!MainRowList.Contains(row.TblColor1))
                        //{
                        TblColor col = new TblColor();
                        col.Iserial    = row.TblColor1.Iserial;
                        col.Code       = row.TblColor1.Code;
                        col.Ename      = row.TblColor1.Ename;
                        col.Aname      = row.TblColor1.Aname;
                        col.PantonCode = row.PantonCode;

                        MainRowList.Add(col);
                        // }
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                };

                lkpClient.GetTblBrandSectionLinkCompleted += (s, sv) =>
                {
                    if (Copy)
                    {
                        BrandSectionListCopy.Clear();
                        foreach (var row in sv.Result)
                        {
                            BrandSectionListCopy.Add(row.TblLkpBrandSection1);
                        }
                        Copy = false;
                    }
                    else
                    {
                        BrandSectionList.Clear();
                        foreach (var row in sv.Result)
                        {
                            BrandSectionList.Add(row.TblLkpBrandSection1);
                        }
                    }
                    Loading = false;
                };

                Client.UpdateOrDeleteTblColorLinkCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                    }
                    else
                    {
                        MainRowList.Clear();
                        GetMaindata();
                    }
                    Loading = false;
                };

                Client.CopyColorLinkCompleted += (s, sv) =>
                {
                    Loading = false;
                };
            }
        }