public ActionResult InstanceNew(ProdLineExInstance prodLineExInstance)
        {
            try
            {
                if (prodLineExInstance.DateType == com.Sconit.CodeMaster.TimeUnit.Day)
                {
                    ModelState.Remove("DateIndex");
                }
                if (ModelState.IsValid)
                {

                    if (prodLineExInstance.DateType == com.Sconit.CodeMaster.TimeUnit.Day)
                    {
                        prodLineExInstance.DateIndex = Convert.ToDateTime(prodLineExInstance.DateIndex).ToString("yyyy-MM-dd");
                    }
                    if (this.genericMgr.FindAll<long>("select count(*)  from ProdLineExInstance as p where p.ProductLine=? and p.Item=? and p.DateIndex=? and  p.DateType=? ",
                        new object[] { prodLineExInstance.ProductLine, prodLineExInstance.Item, prodLineExInstance.DateIndex, prodLineExInstance.DateType })[0] > 0)
                    {
                        base.SaveErrorMessage(string.Format(Resources.EXT.ControllerLan.Con_AlreadyExistsSameFlowItemCodePlanTypeTypeTimeIndex, prodLineExInstance.ProductLine, prodLineExInstance.Item, prodLineExInstance.DateType, prodLineExInstance.DateIndex));
                        return View(prodLineExInstance);
                    }
                    prodLineExInstance.Region = genericMgr.FindById<FlowMaster>(prodLineExInstance.ProductLine).PartyFrom;
                    prodLineExInstance.IsManualCreate = true;
                    this.genericMgr.CreateWithTrim(prodLineExInstance);
                    SaveSuccessMessage(Resources.MRP.ProdLineExInstance.ProdLineExInstance_Added);
                    string productLine = prodLineExInstance.ProductLine;
                    string item = prodLineExInstance.Item;
                    string dateIndex = prodLineExInstance.DateIndex;
                    int dateType = (int)prodLineExInstance.DateType;
                    return new RedirectToRouteResult(new RouteValueDictionary { { "action", "InstanceEdit" }, { "controller", "ProdLineEx" },
                     { "productLine", productLine },{"item",item}, { "dateIndex", dateIndex },{"dateType",dateType}});
                }
            }
            catch (Exception e)
            {
                if (e is CommitResourceException)
                {
                    SaveErrorMessage(Resources.EXT.ControllerLan.Con_AlreadyExitsSameData);
                }

            }

            return View(prodLineExInstance);
        }
 public ActionResult _WebMrpExSectionPlan(string flow, string itemCode, string dateIndex, DateTime planVersion)
 {
     if (!string.IsNullOrEmpty(flow) && !string.IsNullOrEmpty(itemCode))
     {
         var prodLineEx = new ProdLineExInstance();
         if (itemCode == BusinessConstants.VIRTUALSECTION)
         {
             prodLineEx = mrpMgr.LoadVirtualProdLineExInstance();
         }
         else
         {
             prodLineEx = this.genericMgr.FindAll<ProdLineExInstance>
               (" from ProdLineExInstance where ProductLine =? and Item =? and DateIndex=? and DateType=? ",
               new object[] { flow, itemCode, dateIndex, CodeMaster.TimeUnit.Week })
               .FirstOrDefault();
             if (prodLineEx == null)
             {
                 SaveErrorMessage(Resources.EXT.ControllerLan.Con_TheProductionLineLackTheSection, itemCode);
                 return null;
             }
         }
         var plan = Mapper.Map<ProdLineExInstance, MrpExSectionPlan>(prodLineEx);
         //var item = itemMgr.GetCacheItem(itemCode);
         plan.Section = itemCode;
         //plan.SectionDescription = item.Description;
         plan.ProductLine = flow;
         plan.PlanVersion = planVersion;
         plan.StartTime = DateTime.Now;
         plan.WindowTime = DateTime.Now;
         plan.Remark = plan.ProductType.ToString();
         plan.DateIndex = dateIndex;
         plan.PlanNo = mrpMgr.GetExPlanNo(plan, "x");
         return this.Json(plan);
     }
     return null;
 }
        public ActionResult InstanceEdit(ProdLineExInstance prodLineExInstance)
        {
            if (ModelState.IsValid)
            {
                prodLineExInstance.Region = genericMgr.FindById<FlowMaster>(prodLineExInstance.ProductLine).PartyFrom;
                this.genericMgr.UpdateWithTrim(prodLineExInstance);
                SaveSuccessMessage(Resources.MRP.ProdLineExInstance.ProdLineExInstance_Updated);
            }

            return View(prodLineExInstance);
        }