public ActionResult Edit(MrpExPlanItemRate MrpExPlanItemRate)
        {
            if (ModelState.IsValid)
            {
                this.genericMgr.UpdateWithTrim(MrpExPlanItemRate);
                SaveSuccessMessage(Resources.MRP.MrpExPlanItemRate.MrpExPlanItemRate_Updated);
            }

            return View(MrpExPlanItemRate);
        }
 public ActionResult Edit(string section)
 {
     if (string.IsNullOrEmpty(section))
     {
         return HttpNotFound();
     }
     else
     {
         MrpExPlanItemRate MrpExPlanItemRate = new MrpExPlanItemRate();
         MrpExPlanItemRate.Section = section;
         MrpExPlanItemRate.SectionDesc = itemMgr.GetCacheItem(section).Description;
         @ViewBag.Section = section;
         return View(MrpExPlanItemRate);
     }
 }
        public JsonResult SaveItemRates(string section, decimal[] ItemRates, string[] Items)
        {
            try
            {
                if (Items == null || Items.Length == 0)
                {
                    SaveErrorMessage(Resources.EXT.ControllerLan.Con_LackDetailCanNotUpdatedRate);
                    return Json(null);
                }
                IList<MrpExPlanItemRate> MrpExPlanItemRates = this.genericMgr.FindAll<MrpExPlanItemRate>(" from MrpExPlanItemRate as i where i.Section=? ", section);

                IList<BomDetail> SectionItemLists = this.genericMgr.FindAll<BomDetail>(" from BomDetail as i where i.Item=? ", section);
                IList<SectionItems> groupProdLineExList = (from l in SectionItemLists
                                                           group l by new { l.Bom, l.Item }
                                                               into g
                                                               select new SectionItems
                                                               {
                                                                   Section = g.Key.Item,
                                                                   Item = g.Key.Bom
                                                               }).ToList();
                var quey = from c in groupProdLineExList where !(from o in MrpExPlanItemRates select o.Item).Contains(c.Item) select c;
                if (quey.ToList().Count() > 0)
                {
                    foreach (var groupProdLineEx in quey)
                    {
                        MrpExPlanItemRate MrpExPlanItemRateNew = new MrpExPlanItemRate();
                        MrpExPlanItemRateNew.Item = groupProdLineEx.Item;
                        MrpExPlanItemRateNew.Section = groupProdLineEx.Section;
                        MrpExPlanItemRateNew.ItemRate = 0;
                        MrpExPlanItemRateNew.IsNew = true;

                        MrpExPlanItemRates.Add(MrpExPlanItemRateNew);
                    }
                }

                for (int i = 0; i < Items.Length; i++)
                {
                    MrpExPlanItemRate MrpExPlanItemRate = MrpExPlanItemRates.Where(o => o.Item == Items[i]).FirstOrDefault() ?? new MrpExPlanItemRate();
                    if (!string.IsNullOrWhiteSpace(MrpExPlanItemRate.Item))
                    {
                        MrpExPlanItemRate.ItemRate = ItemRates[i];
                    }
                    if (ModelState.IsValid)
                    {
                        if (!MrpExPlanItemRate.IsNew)
                        {
                            this.genericMgr.UpdateWithTrim(MrpExPlanItemRate);
                            //SaveSuccessMessage(MrpExPlanItemRate.Item+"," +Resources.MRP.MrpExPlanItemRate.MrpExPlanItemRate_Updated);
                        }
                        else
                        {
                            this.genericMgr.CreateWithTrim(MrpExPlanItemRate);
                        }

                    }
                }
                //object obj = new { newOrder.OrderNo };
                return Json(new { SuccessMessages = Resources.EXT.ControllerLan.Con_RateEditSuccessfully });
            }
            catch (Exception ex)
            {
                SaveErrorMessage(ex);
                return Json(null);
            }
        }
        public ActionResult _SelectSectionDet(string section)
        {
            IList<MrpExPlanItemRate> MrpExPlanItemRates = this.genericMgr.FindAll<MrpExPlanItemRate>(" from MrpExPlanItemRate as i where i.Section=? ", section);

            IList<BomDetail> SectionItemLists = this.genericMgr.FindAll<BomDetail>(" from BomDetail as i where i.Item=? ", section);
            IList<SectionItems> groupProdLineExList = (from l in SectionItemLists
                                                       group l by new { l.Bom, l.Item }
                                                           into g
                                                           select new SectionItems
                                                           {
                                                               Section = g.Key.Item,
                                                               Item = g.Key.Bom
                                                           }).ToList();
            var quey = from c in MrpExPlanItemRates where !(from o in groupProdLineExList select o.Item).Contains(c.Item) select c;
            if (quey.ToList().Count() > 0)
            {
                foreach (var MrpExPlanItemRate in quey)
                {
                    this.genericMgr.DeleteById<MrpExPlanItemRate>(MrpExPlanItemRate.Id);
                    MrpExPlanItemRate.IsDeleted = true;
                }
            }
            var quey1 = from c in groupProdLineExList where !(from o in MrpExPlanItemRates select o.Item).Contains(c.Item) select c;
            if (quey1.ToList().Count() > 0)
            {
                foreach (var groupProdLineEx in quey1)
                {
                    MrpExPlanItemRate MrpExPlanItemRateNew = new MrpExPlanItemRate();
                    MrpExPlanItemRateNew.Item = groupProdLineEx.Item;
                    MrpExPlanItemRateNew.Section = groupProdLineEx.Section;
                    MrpExPlanItemRateNew.ItemRate = 0;
                    //this.genericMgr.CreateWithTrim(MrpExPlanItemRateNew);
                    MrpExPlanItemRates.Add(MrpExPlanItemRateNew);
                }
            }
            foreach (var MrpExPlanItemRate in MrpExPlanItemRates)
            {
                MrpExPlanItemRate.SectionDesc = itemMgr.GetCacheItem(MrpExPlanItemRate.Section).Description;
                MrpExPlanItemRate.ItemDesc = itemMgr.GetCacheItem(MrpExPlanItemRate.Item).Description;
            }
            return View(new GridModel(MrpExPlanItemRates.Where(o => o.IsDeleted == false).OrderBy(p => p.Item)));
        }