Esempio n. 1
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);
        }
Esempio n. 2
0
 public void SaveInvoice(pdv_invoices item)
 {
     try
     {
         _db.SaveInvoice(item);
     }
     catch (Exception ex)
     {
         _debug(ex, new object { }, "");
     }
 }
Esempio n. 3
0
        public pdv_invoices GetInvoice(int id)
        {
            var res = new pdv_invoices();

            try
            {
                res = _db.GetInvoices().FirstOrDefault(x => x.id == id);
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
            }
            return(res);
        }
Esempio n. 4
0
 public int SaveInvoice(pdv_invoices element, bool withSave = true)
 {
     if (element.id == 0)
     {
         db.pdv_invoices.Add(element);
     }
     else
     {
         db.Entry(element).State = EntityState.Modified;
     }
     if (withSave)
     {
         Save();
     }
     return(element.id);
 }
Esempio n. 5
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);
        }
Esempio n. 6
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);
        }