Пример #1
0
        public ActionResult DialogUpdateHSIP(Order_RUTF_Header value)
        {
            EmailJob email = new EmailJob();

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

            TempData["OrderNumber"]  = value.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_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, "RUTF");
            }
            if (value.FinalSubmission == true && value.RFSO_SentBackTofacility == true)
            {
                email.OrderReSentToScto(value.FacilityCode, value.OrderNumber, "RUTF");
            }
            return(Json(value, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public ActionResult DialogInsertHSIP(Order_RUTF_Header value)
        {
            EmailJob email = new EmailJob();

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

            db_hv.Order_RUTF_Header.Add(value);
            value.OrderNumber       = OrderNumber;
            TempData["OrderNumber"] = OrderNumber;
            //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)
            {
                email.OrderSentToScto(value.FacilityCode, value.OrderNumber, "RUTF");
            }
            return(Json(value, JsonRequestBehavior.AllowGet));
        }
 public Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber) == null)
         {
             var x = new Order_RUTF_Header
             {
                 OrderNumber  = mOrderNumber,
                 FacilityCode = mFacilityCode,
                 StartDate    = mStartDate,
                 EndDate      = mEndDate,
                 DatePrepared = mDatePrepared,
                 //AddedBy = mAddedBy,
                 //AddedDate = mAddedDate,
                 EditedBy   = new UserManagement().getCurrentuser(),
                 EditedDate = DateTime.Now,
                 //RecordStatus = mRecordStatus,
                 //EmergencyOrder = mEmergencyOrder,
                 FinalSubmission = mFinalSubmission,
                 //ExportedToSAP = mExportedToSAP,
                 OrderTypeId             = mOrderTypeId,
                 OrderStatusId           = mOrderStatusId,
                 RFSO_SentBackTofacility = mRFSO_SentBackTofacility
                                           //OrderApproved = mOrderApproved,
                                           //OrderApprovedBy = mOrderApprovedBy,
                                           //OrderDateOfApproval = mOrderDateOfApproval
             };
             context.Order_RUTF_Header.Add(x);
             context.SaveChanges();
             //////SaveLog(x);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
Пример #4
0
        public Boolean SaveRutf(string OrderNo)
        {
            try
            {
                var allocated = context.Order_RUTF_Details.Where(o => o.OrderNumber == OrderNo && o.Quantity_Allocated > 0).ToList().Count;
                if (allocated > 0)
                {
                    if (GetRecordByKeyRutf(OrderNo) != null)
                    {
                        Order_RUTF_Header t = new Order_RUTF_Header();
                        t = GetRecordByKeyRutf(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 = 12,
                        };
                        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.SaveRutf(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.SaveRutf(OrderNo);

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

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