//public ActionResult DialogInsertHSIPCustom(Order_SMC_SLM_Header value)
        //{
        //    string OrderNumber = new OrderNumber().GetOrderNumber(System.Convert.ToDateTime(value.DatePrepared), value.FacilityCode, "10", "02");
        //    OrderSMCHeaderModels obj = new OrderSMCHeaderModels();
        //    obj.OrderNumber = OrderNumber;
        //    TempData["OrderNumber"] = OrderNumber;
        //    obj.DatePrepared = System.Convert.ToDateTime(value.DatePrepared);
        //    obj.FacilityCode = value.FacilityCode;
        //    obj.StartDate = System.Convert.ToDateTime(value.DatePrepared);
        //    obj.EndDate = System.Convert.ToDateTime(value.DatePrepared);
        //    obj.OrderTypeId = 1;
        //    obj.OrderStatusId = 1;
        //    obj.FinalSubmission = System.Convert.ToBoolean(value.FinalSubmission);
        //    obj.EditedBy = new UserManagement().getCurrentuser();
        //    obj.EditedDate = DateTime.Now;
        //    obj.Save();
        //    return Json(value, JsonRequestBehavior.AllowGet);
        //}

        public ActionResult DialogInsertHSIPCustom(Order_SMC_SLM_Header value)
        {
            //EmailJob obx = new EmailJob();
            context.Configuration.ProxyCreationEnabled = false;
            mascisEntities       db_hv = new mascisEntities();
            OrderSMCHeaderModels obj   = new OrderSMCHeaderModels();
            string OrderNumber         = new OrderNumber().GetOrderNumber(System.Convert.ToDateTime(value.DatePrepared), value.FacilityCode, "10", "02");

            db_hv.Order_SMC_SLM_Header.Add(value);
            value.OrderNumber       = OrderNumber;
            TempData["OrderNumber"] = OrderNumber;
            value.OrderTypeId       = 1;
            value.OrderStatusId     = 1;
            //value.DateExpected= DateTime.Now;
            value.StartDate  = DateTime.Now;
            value.EndDate    = DateTime.Now;
            value.EditedDate = DateTime.Now;
            value.EditedBy   = new UserManagement().getCurrentuser();
            db_hv.SaveChanges();
            //obj.SaveLog(value);
            //obx.SendEmail(value.FacilityCode, value.OrderNumber);
            //if (value.FinalSubmission == true)
            //{
            //    obx.SendEmail(value.FacilityCode, value.OrderNumber);
            //}
            return(Json(value, JsonRequestBehavior.AllowGet));
        }
        //public ActionResult DialogUpdateHSIP(Order_SMC_SLM_Header value)
        //{
        //    OrderSMCHeaderModels obj = new OrderSMCHeaderModels();
        //    obj.OrderNumber = value.OrderNumber;
        //    TempData["OrderNumber"] = value.OrderNumber;
        //    obj.DatePrepared = System.Convert.ToDateTime(value.DatePrepared);
        //    obj.FacilityCode = value.FacilityCode;
        //    obj.StartDate = value.StartDate;
        //    obj.EndDate = value.EndDate;
        //    obj.OrderTypeId = 2;
        //    obj.OrderStatusId = 1;
        //    obj.FinalSubmission = System.Convert.ToBoolean(value.FinalSubmission);
        //    obj.EditedBy = new UserManagement().getCurrentuser();
        //    obj.EditedDate = DateTime.Now;
        //    obj.Update();
        //    return Json(value, JsonRequestBehavior.AllowGet);
        //}
        public ActionResult DialogInsertHSIP(Order_SMC_SLM_Header value)
        {
            EmailJob email = new EmailJob();

            context.Configuration.ProxyCreationEnabled = false;
            mascisEntities       db_hv = new mascisEntities();
            OrderSMCHeaderModels obj   = new OrderSMCHeaderModels();
            string OrderNumber         = new OrderNumber().GetOrderNumber(System.Convert.ToDateTime(value.DatePrepared), value.FacilityCode, "10", "02");

            db_hv.Order_SMC_SLM_Header.Add(value);
            value.OrderNumber        = OrderNumber;
            TempData["OrderNumber"]  = OrderNumber;
            TempData["FacilityCode"] = value.FacilityCode;
            TempData["StartDate"]    = value.StartDate;
            TempData["EndDate"]      = value.EndDate;
            value.OrderTypeId        = 2;
            value.OrderStatusId      = 1;
            value.EditedDate         = DateTime.Now;
            value.EditedBy           = new UserManagement().getCurrentuser();
            db_hv.SaveChanges();
            //obj.SaveLog(value);
            if (value.FinalSubmission == true && value.RFSO_SentBackTofacility == false)
            {
                email.OrderSentToScto(value.FacilityCode, value.OrderNumber, "SMC");
            }
            return(Json(value, JsonRequestBehavior.AllowGet));
        }