public bool DeleteMail(int id, out string msg, Mikhailova_contracts user) { bool res = false; var mail = new Mikhailova_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); }
public Mikhailova_contracts GetContract(int id) { var res = new Mikhailova_contracts(); res = db.GetContract(id); return(res); }
public ActionResult CreateContract(string number, string path, int typeID, int contagentID, string desc, decimal summa) { var parameters = AjaxModel.GetAjaxParameters(HttpContext); int statusID = 1; var item = new Mikhailova_contracts { id = 0, number = number, date = DateTime.Now.Date, path = path, typeID = typeID, statusID = statusID, contagentID = contagentID, summa = summa, desc = desc }; mng.Contracts.SaveContract(item); return(Json(new { result = item.id > 0, savedID = item.id, }, JsonRequestBehavior.AllowGet)); }
public bool EditContractField(aspnet_Users userRol, int id, string code, string value, out string msg, Mikhailova_contracts user) { bool res = false; var document = new Mikhailova_contracts(); try { if (!_IsCanUserChange(userRol)) { msg = "Недостаточна прав для редактирования!"; } else { document = GetContract(id); if (document != null) { //TODO SaveContract(document); res = true; msg = "Успешно"; } else { msg = "Не удалось найти документ"; } } } catch (Exception ex) { _debug(ex, new { }, ""); msg = "Произошла ошибка, поле не изменено"; } return(res); }
public bool DeleteInvoice(int id, out string msg, Mikhailova_contracts user) { bool res = false; var invoice = new Mikhailova_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; }
public int SaveContract(Mikhailova_contracts item) { try { if (item.id == 0) { db.Mikhailova_contracts.Add(item); db.SaveChanges(); } else { try { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } catch (OptimisticConcurrencyException ex) { RDL.Debug.LogError(ex); } } } catch (Exception ex) { RDL.Debug.LogError(ex); } return(item.id); }
public ActionResult EditContract(Mikhailova_contracts item) { var mng = new ContractsManager(); mng.SaveContract(item); return(Json(new { result = true })); }
public bool EditContract(aspnet_Users user, int id, string name, string value, out string msg) { var res = false; var item = new Mikhailova_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); }
public void SaveContract(Mikhailova_contracts item) { try { db.SaveContract(item); } catch (Exception ex) { RDL.Debug.LogError(ex); } }
public void SaveContract(Mikhailova_contracts item) { try { _db.SaveContract(item); } catch (Exception ex) { _debug(ex, new { item }, ""); } }
public Mikhailova_contracts GetContract(int id) { var res = new Mikhailova_contracts(); try { res = _db.GetContracts().FirstOrDefault(x => x.id == id); } catch (Exception ex) { _debug(ex, new { id }, ""); } return(res); }
public int SaveContract(Mikhailova_contracts element, bool withSave = true) { if (element.id == 0) { db.Mikhailova_contracts.Add(element); } else { db.Entry(element).State = EntityState.Modified; } if (withSave) { Save(); } return(element.id); }
public bool CreateContract(string name) { var res = false; var contract = new Mikhailova_contracts(); try { contract = new Mikhailova_contracts { id = 0, desc = name }; SaveContract(contract); res = true; } catch (Exception ex) { _debug(ex, new { name }, ""); } return(res); }
public ActionResult EditContract(Mikhailova_contracts item) { mng.Contracts.SaveContract(item); return(Json(new { result = true })); }
public bool EditInvoiceField(int id, string code, string value, out string msg, Mikhailova_contracts user) { throw new NotImplementedException(); }
public bool AddInvoice(int number, Mikhailova_contracts user) { throw new NotImplementedException(); }