Exemple #1
0
        public bool EditDocumentTypesField(int id, string code, string value, out string msg)
        {
            bool res           = false;
            var  documentTypes = new pdv_documentType();

            try
            {
                documentTypes = GetDocumentType(id);

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

                    case "code": documentTypes.code = value;
                        break;
                    }
                    SaveDocumentTypes(documentTypes);
                    res = true;
                    msg = "Успешно";
                }
                else
                {
                    msg = "Не удалось найти статус документ";
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
                msg = "Произошла ошибка, поле не изменено";
            }
            return(res);
        }
Exemple #2
0
        public ActionResult DocTypes_save()
        {
            var parameters = AjaxModel.GetAjaxParameters(HttpContext);

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

                mng.Documents.SaveDocumentTypes(newDocType);
                return(Json(new
                {
                    result = true,
                    id = newDocType.id,
                    msg = "Операция успешна"
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                RDL.Debug.LogError(ex);
                return(Json(new
                {
                    result = false,
                    id = 0,
                    msg = "Ошибка"
                }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #3
0
        public int SaveDocumentTypes(pdv_documentType item, bool withSave = true)
        {
            var res = 0;

            try
            {
                res = _db.SaveDocumentType(item);
            }
            catch (Exception ex)
            {
                _debug(ex, new { item }, "item");
            }
            return(res);
        }
Exemple #4
0
        public pdv_documentType GetDocumentType(int id)
        {
            var res = new pdv_documentType();

            try
            {
                res = _db.GetDocumentType().FirstOrDefault(x => x.id == id);
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
            }
            return(res);
        }
Exemple #5
0
 public int SaveDocumentType(pdv_documentType element, bool withSave = true)
 {
     if (element.id == 0)
     {
         db.pdv_documentType.Add(element);
     }
     else
     {
         db.Entry(element).State = EntityState.Modified;
     }
     if (withSave)
     {
         Save();
     }
     return(element.id);
 }