public void SaveInvoice(Shtoda_invoices item) { try { _db.SaveInvoice(item); } catch (Exception ex) { _debug(ex, new object { }, ""); } }
public Shtoda_invoices GetInvoice(int id) { var res = new Shtoda_invoices(); try { res = _db.GetInvoices().FirstOrDefault(x => x.id == id); } catch (Exception ex) { _debug(ex, new { }, ""); } return(res); }
public int SaveInvoice(Shtoda_invoices element, bool withSave = true) { if (element.id == 0) { db.Shtoda_invoices.Add(element); } else { db.Entry(element).State = EntityState.Modified; } if (withSave) { Save(); } return(element.id); }
public bool EditInvoiceField(int id, string code, string value, out string msg, Shtoda_invoices user) { bool res = false; var invoice = new Shtoda_invoices(); try { invoice = GetInvoice(id); if (invoice.contagentID != user.id) { msg = "Нет прав для редактирования счета"; return(res); } if (invoice != null) { switch (code) { case "number": invoice.number = value; break; case "contractorID": invoice.contagentID = RDL.Convert.StrToInt(value, 0); break; case "comment": invoice.desc = value; break; case "InvoiceStatus": invoice.statusID = RDL.Convert.StrToInt(value, 0); break; } SaveInvoice(invoice); res = true; msg = "Успешно"; } else { msg = "Не удалось найти счет"; } } catch (Exception ex) { _debug(ex, new object { }, ""); msg = "Ошибка редатирования"; } return(res); }
public bool AddInvoice(int number, Shtoda_invoices user) { bool res = false; var invoice = new Shtoda_invoices(); try { invoice = new Shtoda_invoices { id = 0, number = number.ToString(), contagentID = user.id, date = DateTime.Now, }; SaveInvoice(invoice); } catch (Exception ex) { _debug(ex, new object { }, ""); } return(res); }