public string InitSysPara(string fieldSysPara, string defaultValueSysPara)
        {
            string ret = "";
            try
            {
                var _ret = (from ite in _context.SysParas
                            where ite.Field == fieldSysPara
                            select ite).FirstOrDefault();
                if (_ret != null)
                {
                    ret = _ret.Value;
                }
                else
                {
                    SysPara sys = new SysPara();
                    sys.Field = fieldSysPara;
                    sys.Value = defaultValueSysPara;
                    sys.DefaultValue = defaultValueSysPara;

                    _context.SysParas.Add(sys);
                    if (_context.SaveChanges() > 0)
                    {
                        ret = defaultValueSysPara;
                    }
                }
            }
            catch (Exception e)
            {
                ErrorHandle.WriteError("GetAllCategory", e.Message);
            }
            return ret;
        }
 public SysPara GetSysPara(string fieldSysPara)
 {
     SysPara ret = new SysPara();
     ret.Field = fieldSysPara;
     ret.Value = "";
     ret.DefaultValue = "";
     try
     {
         var _ret = (from ite in _context.SysParas
                     where ite.Field == fieldSysPara
                     select ite).FirstOrDefault();
         if (_ret != null)
         {
             ret = _ret;
         }
     }
     catch (Exception e)
     {
         ErrorHandle.WriteError("GetAllCategory", e.Message);
     }
     return ret;
 }
        public JsonResult EditSysPara(SysPara editSysPara)
        {
            JsonResult jResult = new JsonResult();
            try
            {

                jResult = Json(new { success = adminPageProvider.EditSysPara(editSysPara) }, JsonRequestBehavior.AllowGet);

            }
            catch (Exception)
            {


            }

            return jResult;
        }
        public bool EditSysPara(SysPara editSysPara)
        {
            bool ret = false;
            try
            {
                SysPara oldItem = (from ite in _context.SysParas
                                   where ite.Field == editSysPara.Field
                                   select ite).FirstOrDefault();

                if (oldItem != null)
                {
                    oldItem.Value = editSysPara.Value == null ? "" : editSysPara.Value;

                    oldItem.DefaultValue = editSysPara.DefaultValue == null ? "" : editSysPara.DefaultValue;

                    if (_context.SaveChanges() > 0)
                    {
                        ret = true;
                    }

                }
                else
                {
                    _context.SysParas.Add(editSysPara);
                    if (_context.SaveChanges() > 0)
                    {
                        ret = true;
                    }
                }

            }
            catch (Exception e)
            {
                ErrorHandle.WriteError("GetAllCategory", e.Message);
            }
            return ret;
        }
        public JsonResult UpdateSysParam(string lstSysparam)
        {
            string Mes = string.Empty;
            JsonResult jsonResult = new JsonResult();
            try
            {
                if (Session["LoginID"] != null)
                {

                    var arrItem = JArray.Parse(lstSysparam);
                    List<SysPara> lst = new List<SysPara>();
                    foreach (var item in arrItem)
                    {
                        SysPara oSysPara = new SysPara();
                         
                        oSysPara.Field = item["Field"].ToString();
                        oSysPara.Value = item["Value"] == null ? "" : item["Value"].ToString();
                        oSysPara.DefaultValue = item["DefaultValue"] == null ? "" : item["DefaultValue"].ToString();
                        adminPageProvider.EditSysPara(oSysPara);
                    }
                    adminPageProvider.SetSysPara();
                    jsonResult = Json(new { success = true, msgError = Mes }, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    jsonResult = Json(new { success = false, msgError = Mes }, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception ex)
            {
                jsonResult = Json(new { success = false, msgError = Mes }, JsonRequestBehavior.AllowGet);
             
            }
            return jsonResult;

        }