//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));
        }
        public ActionResult DialogUpdateHSIP(Order_SMC_SLM_Header value)
        {
            EmailJob email = new EmailJob();

            context.Configuration.ProxyCreationEnabled = false;
            mascisEntities       db_master = new mascisEntities();
            Order_SMC_SLM_Header table     = db_master.Order_SMC_SLM_Header.FirstOrDefault(o => o.OrderNumber == value.OrderNumber);

            TempData["OrderNumber"] = value.OrderNumber;
            value.OrderTypeId       = 2;
            value.OrderStatusId     = 1;
            value.EditedDate        = DateTime.Now;
            value.EditedBy          = new UserManagement().getCurrentuser();
            db_master.Entry(table).CurrentValues.SetValues(value);
            db_master.Entry(table).State = EntityState.Modified;
            db_master.SaveChanges();
            if (value.FinalSubmission == true && value.RFSO_SentBackTofacility == false)
            {
                email.OrderSentToScto(value.FacilityCode, value.OrderNumber, "SMC");
            }
            if (value.FinalSubmission == true && value.RFSO_SentBackTofacility == true)
            {
                email.OrderReSentToScto(value.FacilityCode, value.OrderNumber, "SMC");
            }
            return(Json(value, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
 public Boolean SaveLog(Order_SMC_SLM_Header record)
 {
     try
     {
         var log = new Order_SMC_SLM_Header_Log
         {
             OrderNumber            = record.OrderNumber,
             FacilityCode           = record.FacilityCode,
             OrderStatusId          = System.Convert.ToInt32(record.OrderStatusId),
             OrderStatusChangedBy   = new UserManagement().getCurrentuser(),
             OrderStatusDateChanged = DateTime.Now,
             StartDate         = record.StartDate,
             EndDate           = record.EndDate,
             DatePrepared      = record.DatePrepared,
             OrderTypeId       = record.OrderTypeId,
             ProductCategoryId = 10
         };
         context.Order_SMC_SLM_Header_Log.Add(log);
         context.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         throw (e);
     }
 }
Ejemplo n.º 5
0
 public Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber) == null)
         {
             var x = new Order_SMC_SLM_Header
             {
                 OrderNumber  = mOrderNumber,
                 FacilityCode = mFacilityCode,
                 StartDate    = mStartDate,
                 EndDate      = mEndDate,
                 DatePrepared = mDatePrepared,
                 EditedBy     = new UserManagement().getCurrentuser(),
                 EditedDate   = DateTime.Now,
                 //EmergencyOrder = mEmergencyOrder,
                 FinalSubmission          = mFinalSubmission,
                 OrderTypeId              = mOrderTypeId,
                 OrderStatusId            = mOrderStatusId,
                 OrderStatusIdChangedBy   = mOrderStatusIdChangedBy,
                 OrderStatusIdDateChanged = mOrderStatusIdDateChanged,
                 RFSO_SentBackTofacility  = mRFSO_SentBackTofacility
             };
             context.Order_SMC_SLM_Header.Add(x);
             context.SaveChanges();
             ////SaveLog(x);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
Ejemplo n.º 6
0
        public Boolean SaveSMC(string OrderNo)
        {
            try
            {
                var allocated = context.Order_SMC_SLM.Where(o => o.OrderNumber == OrderNo && o.QuantityAllocated > 0).ToList().Count;
                if (allocated > 0)
                {
                    if (GetRecordByKeySMC(OrderNo) != null)
                    {
                        Order_SMC_SLM_Header t = new Order_SMC_SLM_Header();
                        t = GetRecordByKeySMC(OrderNo);
                        //DateTime eDate  = t.EndDate;
                        DateTime pDate    = System.Convert.ToDateTime(t.DatePrepared);
                        int      facility = t.FacilityCode;
                        var      sapcode  = context.A_Facilities.FirstOrDefault(a => a.FacilityCode == facility).SAP_Code;
                        var      x        = new SAP_ExportHeader
                        {
                            OrderNumber     = t.OrderNumber,
                            AddedDate       = System.DateTime.Now,
                            AddedBy         = new UserManagement().getCurrentuser(),
                            CurrentReccord  = true,
                            RecordReadBySAP = false,
                            DocNum          = System.Convert.ToString(System.Convert.ToDateTime(pDate).Day + "" + System.Convert.ToDateTime(pDate).Month + "" + System.Convert.ToDateTime(pDate).Year + "" + facility),
                            DocDate         = System.Convert.ToDateTime(pDate),
                            DocDueDate      = System.Convert.ToDateTime(pDate),
                            CardCode        = sapcode,// t.A_Facilities.SAP_Code,
                            DocEntry        = mDocEntry,
                            ProductCategory = 10,
                        };
                        var order = context.SAP_ExportHeader.FirstOrDefault(o => o.OrderNumber == OrderNo);
                        if (order == null)
                        {
                            context.SAP_ExportHeader.Add(x);
                            context.SaveChanges();
                        }

                        SAPExportDetails details = new SAPExportDetails();
                        details.SaveSMC(OrderNo);
                        //var update = t;
                        //update.OrderStatusId = 4;
                        //context.Entry(t).CurrentValues.SetValues(update);
                        //context.Entry(t).State = EntityState.Modified;
                        //context.SaveChanges();
                        //context.SAP_ExportHeader.Add(x);
                        //context.SaveChanges();

                        //SAPExportDetails details = new SAPExportDetails();
                        //details.SaveSMC(OrderNo);

                        // to update the order status of the record
                        //OrderSMCHeaderModels sap = new OrderSMCHeaderModels();
                        //sap.UpdateSAP(OrderNo);

                        return(true);
                    }
                    else
                    {
                        // existing_records = true;
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception x)
            {
                throw (x);
            }
        }