Example #1
0
        public bool DeleteMail(int id, out string msg, Mikhailova_contracts user)
        {
            bool res  = false;
            var  mail = new Mikhailova_mails();

            try
            {
                mail = GetMail(id);
                if (mail != null)
                {
                    if (mail.id != user.id) //
                    {
                        msg = "Нет прав на удаление письма";
                        return(res);
                    }
                    //mail.isDeleted = true; insert in db
                    SaveMail(mail);
                    res = true;
                    msg = "Письмо удалено";
                }
                else
                {
                    msg = "Не удалось найти письмо";
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
                msg = "Ошибка удаления письма";
            }
            return(res);
        }
Example #2
0
        public Mikhailova_contracts GetContract(int id)
        {
            var res = new Mikhailova_contracts();

            res = db.GetContract(id);
            return(res);
        }
Example #3
0
        public ActionResult CreateContract(string number, string path, int typeID, int contagentID, string desc, decimal summa)
        {
            var parameters = AjaxModel.GetAjaxParameters(HttpContext);
            int statusID   = 1;
            var item       = new Mikhailova_contracts
            {
                id          = 0,
                number      = number,
                date        = DateTime.Now.Date,
                path        = path,
                typeID      = typeID,
                statusID    = statusID,
                contagentID = contagentID,
                summa       = summa,
                desc        = desc
            };

            mng.Contracts.SaveContract(item);

            return(Json(new
            {
                result = item.id > 0,
                savedID = item.id,
            }, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        public bool EditContractField(aspnet_Users userRol, int id, string code, string value, out string msg, Mikhailova_contracts user)
        {
            bool res      = false;
            var  document = new Mikhailova_contracts();

            try
            {
                if (!_IsCanUserChange(userRol))
                {
                    msg = "Недостаточна прав для редактирования!";
                }
                else
                {
                    document = GetContract(id);

                    if (document != null)
                    {
                        //TODO
                        SaveContract(document);
                        res = true;
                        msg = "Успешно";
                    }
                    else
                    {
                        msg = "Не удалось найти документ";
                    }
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
                msg = "Произошла ошибка, поле не изменено";
            }
            return(res);
        }
Example #5
0
 public bool DeleteInvoice(int id, out string msg, Mikhailova_contracts user)
 {
     bool res = false;
     var invoice = new Mikhailova_contracts();
     try
     {
         //invoice = GetInvoices(id);
         //if (invoice != null)
         //{
         //    if (invoice.contagentID != user.id)
         //    {
         //        msg = "Нет прав на удаление счета";
         //        return res;
         //    }
         //    //invoice.isDeleted = true; insert in db
         //    SaveInvoice(invoice);
         //    res = true;
         //    msg = "Cчет удален";
         //}
         //else
         msg = "Не удалось найти счет";
     }
     catch (Exception ex)
     {
         _debug(ex, new { id = invoice.id }, "");
         msg = "Ошибка удаления счета";
     }
     return res;
 }
Example #6
0
 public int SaveContract(Mikhailova_contracts item)
 {
     try
     {
         if (item.id == 0)
         {
             db.Mikhailova_contracts.Add(item);
             db.SaveChanges();
         }
         else
         {
             try
             {
                 db.Entry(item).State = EntityState.Modified;
                 db.SaveChanges();
             }
             catch (OptimisticConcurrencyException ex)
             {
                 RDL.Debug.LogError(ex);
             }
         }
     }
     catch (Exception ex)
     {
         RDL.Debug.LogError(ex);
     }
     return(item.id);
 }
        public ActionResult EditContract(Mikhailova_contracts item)
        {
            var mng = new ContractsManager();

            mng.SaveContract(item);

            return(Json(new { result = true }));
        }
Example #8
0
        public bool EditContract(aspnet_Users user, int id, string name, string value, out string msg)
        {
            var res  = false;
            var item = new Mikhailova_contracts();

            msg = "";
            try
            {
                if (!_IsCanUserChange(user))
                {
                    msg = "Недостаточна прав для редактирования!";
                }

                else
                {
                    item = GetContract(id);
                    if (item != null)
                    {
                        switch (name)
                        {
                        case "desc":
                            item.desc = value;
                            break;

                        case "number":
                            item.number = value;
                            break;

                        case "statusName":
                            if (value != "")
                            {
                                item.statusID = RDL.Convert.StrToInt(value, 0);
                            }
                            break;

                        case "contagentName":
                            if (value != "")
                            {
                                item.contagentID = RDL.Convert.StrToInt(value, 0);
                            }
                            break;
                        }
                        SaveContract(item);
                        res = true;
                        msg = "Успешно";
                    }
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { id, name }, "");
                msg = "Произошла ошибка, поле не изменено";
            }
            return(res);
        }
Example #9
0
 public void SaveContract(Mikhailova_contracts item)
 {
     try
     {
         db.SaveContract(item);
     }
     catch (Exception ex)
     {
         RDL.Debug.LogError(ex);
     }
 }
Example #10
0
 public void SaveContract(Mikhailova_contracts item)
 {
     try
     {
         _db.SaveContract(item);
     }
     catch (Exception ex)
     {
         _debug(ex, new { item }, "");
     }
 }
Example #11
0
        public Mikhailova_contracts GetContract(int id)
        {
            var res = new Mikhailova_contracts();

            try
            {
                res = _db.GetContracts().FirstOrDefault(x => x.id == id);
            }
            catch (Exception ex)
            {
                _debug(ex, new { id }, "");
            }
            return(res);
        }
Example #12
0
 public int SaveContract(Mikhailova_contracts element, bool withSave = true)
 {
     if (element.id == 0)
     {
         db.Mikhailova_contracts.Add(element);
     }
     else
     {
         db.Entry(element).State = EntityState.Modified;
     }
     if (withSave)
     {
         Save();
     }
     return(element.id);
 }
Example #13
0
        public bool CreateContract(string name)
        {
            var res      = false;
            var contract = new Mikhailova_contracts();

            try
            {
                contract = new Mikhailova_contracts {
                    id = 0, desc = name
                };
                SaveContract(contract);
                res = true;
            }
            catch (Exception ex)
            {
                _debug(ex, new { name }, "");
            }
            return(res);
        }
Example #14
0
 public ActionResult EditContract(Mikhailova_contracts item)
 {
     mng.Contracts.SaveContract(item);
     return(Json(new { result = true }));
 }
Example #15
0
 public bool EditInvoiceField(int id, string code, string value, out string msg, Mikhailova_contracts user)
 {
     throw new NotImplementedException();
 }
Example #16
0
 public bool AddInvoice(int number, Mikhailova_contracts user)
 {
     throw new NotImplementedException();
 }