Esempio n. 1
0
        public bool EditContractField(aspnet_Users userRol, int id, string code, string value, out string msg, Shtoda_contracts user)
        {
            bool res      = false;
            var  document = new Shtoda_contracts();

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

                    if (document != null)
                    {
                        SaveContract(document);
                        res = true;
                        msg = "Успешно";
                    }
                    else
                    {
                        msg = "Не удалось найти документ";
                    }
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
                msg = "Произошла ошибка, поле не изменено";
            }
            return(res);
        }
Esempio n. 2
0
        public ActionResult CreateContract(string number, string path, int typeID, int contagentID, string description, decimal total)
        {
            var parameters = AjaxModel.GetAjaxParameters(HttpContext);
            int status     = 1;
            var item       = new Shtoda_contracts
            {
                id          = 0,
                number      = number,
                date        = DateTime.Now.Date,
                path        = path,
                typeID      = typeID,
                status      = status,
                contagentID = contagentID,
                total       = total,
                description = description
            };

            mng.Contracts.SaveContract(item);

            return(Json(new
            {
                result = item.id > 0,
                savedID = item.id,
            }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public bool DeleteInvoice(int id, out string msg, Shtoda_contracts user)
        {
            bool res     = false;
            var  invoice = new Shtoda_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);
        }
Esempio n. 4
0
        public bool DeleteMail(int id, out string msg, Shtoda_contracts user)
        {
            bool res  = false;
            var  mail = new Shtoda_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);
        }
Esempio n. 5
0
        public bool DeleteAddon(int id, out string msg, Shtoda_contracts user)
        {
            bool res   = false;
            var  addon = new Shtoda_contracts();

            try
            {
                addon = GetAddons(id);
                if (addon != null)
                {
                    if (addon.contagentID != user.id)
                    {
                        msg = "Нет прав на удаление счета";
                        return(res);
                    }
                    addon.isDeleted = true; insert in db
                    Saveaddon(addon);

                    res = true;
                    msg = "Cчет удален";
                }
                else
                {
                    msg = "Не удалось найти счет";
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { id = addon.id }, "");
                msg = "Ошибка удаления счета";
            }
            return(res);
        }
Esempio n. 6
0
        public bool EditContract(aspnet_Users user, int id, string name, string value, out string msg)
        {
            var res  = false;
            var item = new Shtoda_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);
        }
Esempio n. 7
0
 public void SaveContract(Shtoda_contracts item)
 {
     try
     {
         _db.SaveContract(item);
     }
     catch (Exception ex)
     {
         _debug(ex, new { item }, "");
     }
 }
Esempio n. 8
0
        public Shtoda_contracts GetContract(int id)
        {
            var res = new Shtoda_contracts();

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

            try
            {
                contract = new Shtoda_contracts {
                    id = 0, desc = name
                };
                SaveContract(contract);
                res = true;
            }
            catch (Exception ex)
            {
                _debug(ex, new { name }, "");
            }
            return(res);
        }
Esempio n. 11
0
 public ActionResult EditContract(Shtoda_contracts item)
 {
     mng.Contracts.SaveContract(item);
     return(Json(new { result = true }));
 }
Esempio n. 12
0
 public bool EditInvoiceField(int id, string code, string value, out string msg, Shtoda_contracts user)
 {
     throw new NotImplementedException();
 }
Esempio n. 13
0
 public bool AddInvoice(int number, Shtoda_contracts user)
 {
     throw new NotImplementedException();
 }