Beispiel #1
0
        public ActionResult SaveExpectedReport(LMIS_ExpectedReport value, string fc, string productcategory, string startdate, string enddate)
        {
            DateTime sDate    = DateTime.ParseExact(startdate, "dd/MM/yyyy", null);
            DateTime eDate    = DateTime.ParseExact(enddate, "dd/MM/yyyy", null);
            int      facility = int.Parse(fc);
            int      pc       = int.Parse(productcategory);

            context.Configuration.ProxyCreationEnabled = false;
            mascisEntities      db_master = new mascisEntities();
            LMIS_ExpectedReport table     = db_master.LMIS_ExpectedReport.FirstOrDefault(o => o.facility_code == facility && o.product_category == pc && o.start_date == sDate && o.end_date == eDate);
            ExpectedReports     obj       = new ExpectedReports();

            if (table == null)
            {
                //db.Entry(table).CurrentValues.SetValues(value);
                obj.facility_code    = facility;
                obj.product_category = pc;
                obj.start_date       = sDate;
                obj.end_date         = eDate;
                //db_master.SaveChanges();
            }
            else
            {
                //db.Entry(table).CurrentValues.SetValues(value);
                obj.facility_code            = facility;
                obj.product_category         = pc;
                obj.start_date               = sDate;
                obj.end_date                 = eDate;
                db_master.Entry(table).State = EntityState.Modified;
                context.Entry(table).CurrentValues.SetValues(table);
            }
            obj.Update();
            return(Json(value, JsonRequestBehavior.AllowGet));
            //return RedirectToAction("DataSourceRFSO");
        }
Beispiel #2
0
 public Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mfacility_code, mproduct_category, mstart_date, mend_date) == null)
         {
             var x = new LMIS_ExpectedReport
             {
                 facility_code    = mfacility_code,
                 start_date       = mstart_date,
                 end_date         = mend_date,
                 product_category = mproduct_category
             };
             context.LMIS_ExpectedReport.Add(x);
             context.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }