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); }
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); }
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); }
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)); } }
public void SaveContractor(pdv_contractors item) { try { db.SaveContractor(item); } catch (Exception ex) { _debug(ex, item, ""); } }
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); }
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); }
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); }
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); }
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); }
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); }