Ejemplo n.º 1
0
 public ActionResult EditDocument(pdv_documents item)
 {
     mng.Documents.SaveDocument(item);
     return(Json(new
     {
         result = true
     }));
 }
Ejemplo n.º 2
0
 public void SaveDocument(pdv_documents item)
 {
     try
     {
         _db.SaveDocument(item);
     }
     catch (Exception ex)
     {
         _debug(ex, new { id = item.id }, "");
     }
 }
Ejemplo n.º 3
0
        public pdv_documents GetDocument(int id)
        {
            var res = new pdv_documents();

            try
            {
                res = _db.GetDocuments().FirstOrDefault(x => x.id == id);
            }
            catch (Exception ex)
            {
                _debug(ex, new { id = id }, "");
            }
            return(res);
        }
Ejemplo n.º 4
0
        public bool EditDocumentField(int id, string code, string value, aspnet_Users user, out string msg)
        {
            bool res      = false;
            var  document = new pdv_documents();

            try
            {
                document = GetDocument(id);
                //if(document.contractorID != user.id)
                //{
                //    msg = "Нет прав для редактирования документа";
                //    return res;
                //}
                if (document != null)
                {
                    switch (code)
                    {
                    case "number": document.number = value;
                        break;

                    case "statusName": document.documentStatusID = RDL.Convert.StrToInt(value, 0);
                        _logDocStatusChange(document, "Статус изменен " + user.UserName);
                        break;

                    case "name": document.name = value;
                        break;

                    case "typeName": document.documentTypeID = RDL.Convert.StrToInt(value, 0);
                        break;

                    case "contractorName":
                        document.contractorID = RDL.Convert.StrToInt(value, 0);
                        break;
                    }
                    SaveDocument(document);
                    res = true;
                    msg = "Успешно";
                }
                else
                {
                    msg = "Не удалось найти документ";
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
                msg = "Произошла ошибка, поле не изменено";
            }
            return(res);
        }
Ejemplo n.º 5
0
 public int SaveDocument(pdv_documents element, bool withSave = true)
 {
     if (element.id == 0)
     {
         db.pdv_documents.Add(element);
     }
     else
     {
         db.Entry(element).State = EntityState.Modified;
     }
     if (withSave)
     {
         Save();
     }
     return(element.id);
 }
Ejemplo n.º 6
0
        public bool DeleteDocument(int id, out string msg)
        {
            bool res      = false;
            var  document = new pdv_documents();

            try
            {
                document = GetDocument(id);
                res      = _db.DeleteDocument(id);
                msg      = "Докумнт удален";
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
                msg = "Не удалось удалить документ";
            }
            return(res);
        }
Ejemplo n.º 7
0
        public bool AddDocument(string number)
        {
            bool res      = false;
            var  document = new pdv_documents();

            try
            {
                document = new pdv_documents
                {
                    id          = 0,
                    number      = number,
                    createdDate = DateTime.Now,
                };
                SaveDocument(document);
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
            }
            return(res);
        }
Ejemplo n.º 8
0
        private bool _logDocStatusChange(pdv_documents document, string note = "")
        {
            var res = false;

            try
            {
                _db.SaveDocStatusLog(new pdv_documentStatusesLog
                {
                    id         = 0,
                    created    = DateTime.Now,
                    statusID   = document.documentStatusID,
                    documentID = document.id,
                    note       = note
                });
                res = true;
            }
            catch (Exception ex)
            {
                _debug(ex, new { documentID = document.id, statusID = document.documentStatusID, note });
            }
            return(res);
        }
Ejemplo n.º 9
0
        public ActionResult CreateDocument(string name, string number, string link, int documentTypeID, int contractorID)
        {
            int statusID = mng.Documents.GetDocumentStatusCodeId("CREATED");
            var item     = new pdv_documents
            {
                id               = 0,
                name             = name,
                number           = number,
                documentTypeID   = documentTypeID,
                documentStatusID = documentTypeID,
                contractorID     = contractorID,
                createdDate      = DateTime.Now.Date,
                createdBy        = new CoreManager().GetUserGuid(),
                documentID       = null
            };

            mng.Documents.SaveDocument(item);
            return(Json(new
            {
                result = item.id > 0,
                savedID = item.id,
            }, JsonRequestBehavior.AllowGet));
        }