Esempio n. 1
0
        public bool EditDocumentStatusField(int id, string code, string value, out string msg)
        {
            bool res            = false;
            var  documentStatus = new gl_docStatuses();

            try
            {
                documentStatus = GetDocumentStatus(id);

                if (documentStatus != null)
                {
                    switch (code)
                    {
                    case "name": documentStatus.name = value;
                        break;

                    case "code": documentStatus.code = value;
                        break;
                    }
                    SaveDocumentStatus(documentStatus);
                    res = true;
                    msg = "Успешно";
                }
                else
                {
                    msg = "Не удалось найти статус документ";
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
                msg = "Произошла ошибка, поле не изменено";
            }
            return(res);
        }
Esempio n. 2
0
        public int SaveDocumentStatus(gl_docStatuses item, bool withSave = true)
        {
            var res = 0;

            try
            {
                res = _db.SaveDocumentStatus(item);
            }
            catch (Exception ex)
            {
                _debug(ex, new { item }, "item");
            }
            return(res);
        }
Esempio n. 3
0
 public int SaveDocumentStatus(gl_docStatuses element, bool withSave = true)
 {
     if (element.id == 0)
     {
         db.gl_docStatuses.Add(element);
         if (withSave)
         {
             Save();
         }
     }
     else
     {
         db.Entry(element).State = EntityState.Modified;
         if (withSave)
         {
             Save();
         }
     }
     return(element.id);
 }
Esempio n. 4
0
        public ActionResult DocStatuses_save()
        {
            var parameters = AjaxModel.GetAjaxParameters(HttpContext);

            var fields     = (parameters["fields"] as ArrayList).ToArray().ToList().Select(x => x as Dictionary <string, object>).ToList();
            var newDocType = new gl_docStatuses
            {
                id   = (AjaxModel.GetValueFromSaveField("id", fields) == "") ? 0 : int.Parse(AjaxModel.GetValueFromSaveField("id", fields)),
                name = AjaxModel.GetValueFromSaveField("name", fields),
                code = AjaxModel.GetValueFromSaveField("code", fields)
            };

            mng.Documents.SaveDocumentStatus(newDocType);
            return(Json(new
            {
                result = true,
                id = newDocType.id,
                msg = "Операция успешна"
            }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
        public gl_docStatuses GetDocumentStatus(int id)
        {
            var res = new gl_docStatuses();
            var key = "gl_docStatuses" + id;

            if (CacheManager.EnableCaching && CacheManager.Cache[key] != null)
            {
                res = (gl_docStatuses)CacheManager.Cache[key];
            }
            else
            {
                try
                {
                    res = _db.GetDocumentStatuses().FirstOrDefault(x => x.id == id);
                    CacheManager.CacheData(key, res);
                }
                catch (Exception ex)
                {
                    _debug(ex, new { id }, "id");
                }
            }
            return(res);
        }