Пример #1
0
        public bool EditContractorsField(int id, string code, string value, out string msg)
        {
            bool res        = false;
            var  contractor = new pdv_contractors();

            try
            {
                contractor = GetContractor(id);

                if (contractor != null)
                {
                    switch (code)
                    {
                    case "name": contractor.name = value;
                        break;
                    }
                    SaveContractor(contractor);
                    res = true;
                    msg = "Успешно";
                }
                else
                {
                    msg = "Не удалось найти контрагента";
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
                msg = "Произошла ошибка, поле не изменено";
            }
            return(res);
        }
Пример #2
0
        public bool DeleteMail(int id, out string msg, pdv_contractors user)
        {
            bool res  = false;
            var  mail = new pdv_mails();

            try
            {
                mail = GetMail(id);
                if (mail != null)
                {
                    if (mail.contractorFromID != user.id)
                    {
                        msg = "Нет прав на удаление письма";
                        return(res);
                    }
                    mail.isDeleted = true;
                    SaveMail(mail);
                    res = true;
                    msg = "Письмо удалено";
                }
                else
                {
                    msg = "Не удалось найти письмо";
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
                msg = "Ошибка удаления письма";
            }
            return(res);
        }
Пример #3
0
        public bool DeleteInvoice(int id, out string msg, pdv_contractors user)
        {
            bool res     = false;
            var  invoice = new pdv_invoices();

            try
            {
                invoice = GetInvoice(id);
                if (invoice != null)
                {
                    if (invoice.contractorID != user.id)
                    {
                        msg = "Нет прав на удаление счета";
                        return(res);
                    }
                    invoice.isDeleted = true;
                    SaveInvoice(invoice);
                    res = true;
                    msg = "Cчет удален";
                }
                else
                {
                    msg = "Ну удалось найти счет";
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { id = invoice.id }, "");
                msg = "Ошибка удаления счета";
            }
            return(res);
        }
Пример #4
0
        public ActionResult Contractors_save()
        {
            var parameters = AjaxModel.GetAjaxParameters(HttpContext);

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

                mng.Contractors.SaveContractor(newContractor);
                return(Json(new
                {
                    result = true,
                    id = newContractor.id,
                    msg = "Операция успешна"
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                RDL.Debug.LogError(ex);
                return(Json(new
                {
                    result = false,
                    id = 0,
                    msg = "Ошибка"
                }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #5
0
 public void SaveContractor(pdv_contractors item)
 {
     try
     {
         db.SaveContractor(item);
     }
     catch (Exception ex)
     {
         _debug(ex, item, "");
     }
 }
Пример #6
0
        public pdv_contractors GetContractor(int id)
        {
            var res = new pdv_contractors();

            try
            {
                res = db.GetContractors().FirstOrDefault(x => x.id == id);
            }
            catch (Exception ex)
            {
                _debug(ex, new { contractorID = id }, "");
            }
            return(res);
        }
Пример #7
0
 public int SaveContractor(pdv_contractors element, bool withSave = true)
 {
     if (element.id == 0)
     {
         db.pdv_contractors.Add(element);
     }
     else
     {
         db.Entry(element).State = EntityState.Modified;
     }
     if (withSave)
     {
         Save();
     }
     return(element.id);
 }
Пример #8
0
        public bool CreateContractor(string name)
        {
            var res        = false;
            var contractor = new pdv_contractors();

            try
            {
                contractor = new pdv_contractors {
                    id = 0, name = name
                };
                SaveContractor(contractor);
                res = true;
            }
            catch (Exception ex)
            {
                _debug(ex, contractor, "");
            }
            return(res);
        }
Пример #9
0
        public bool DeleteContractor(int id, out string msg)
        {
            bool res        = false;
            var  contractor = new pdv_contractors();

            try
            {
                contractor           = GetContractor(id);
                contractor.isDeleted = true;
                SaveContractor(contractor);
                msg = "Контрагент удален";
                res = true;
            }
            catch (Exception ex)
            {
                _debug(ex, new { contractorId = id }, "");
                msg = "Не удалось удалить контрагента";
            }
            return(res);
        }
Пример #10
0
        public bool AddInvoice(int number, pdv_contractors user)
        {
            bool res     = false;
            var  invoice = new pdv_invoices();

            try
            {
                invoice = new pdv_invoices
                {
                    id           = 0,
                    number       = number,
                    contractorID = user.id,
                    createDate   = DateTime.Now,
                };
                SaveInvoice(invoice);
            }
            catch (Exception ex)
            {
                _debug(ex, new object { }, "");
            }
            return(res);
        }
Пример #11
0
        public bool EditInvoiceField(int id, string code, string value, out string msg, pdv_contractors user)
        {
            bool res     = false;
            var  invoice = new pdv_invoices();

            try
            {
                invoice = GetInvoice(id);
                if (invoice.contractorID != user.id)
                {
                    msg = "Нет прав для редактирования счета";
                    return(res);
                }
                if (invoice != null)
                {
                    switch (code)
                    {
                    case "number": invoice.number = RDL.Convert.StrToInt(value, 0);
                        break;

                    // case "contractorID": invoice.contractorID = RDL.Convert.StrToInt(value, 0);
                    //    break;
                    case "comment": invoice.comment = value;
                        break;

                    case "documentID": invoice.documentID = RDL.Convert.StrToInt(value, 0);
                        break;

                    case "InvoiceStatus": invoice.invoiceStatusID = RDL.Convert.StrToInt(value, 0);
                        break;
                    }
                    SaveInvoice(invoice);
                    res = true;
                    msg = "Успешно";
                }
                else
                {
                    msg = "Не удалось найти счет";
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new object { }, "");
                msg = "Ошибка редатирования";
            }
            return(res);
        }