public ActionResult Index() { if(Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 1 || Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 2) { try { var dbPomocnik = new MySqlPomocnik(); var materijali = dbPomocnik.IzvrsiProceduru<Materijal, Materijal>(Konstante.StoredProcedures.DAJ_MATERIJALE, new Materijal()); if(materijali.Any(m => m.Kolicina < 10)) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.AppendLine("Sljedeći materijali će uskoro biti istrošeni:"); foreach(var m in materijali.Where(m1 => m1.Kolicina < 10)) sb.AppendFormat("\t{0} : {1}{2}", m.Naziv, m.Kolicina, Environment.NewLine); if(TempData["Error"] != null) TempData["Error"] += "\n\n"; TempData["Error"] += sb.ToString(); StandardniUiElementi.glavnaDugmad.FirstOrDefault(x => x.ImageUrl == "/Images/appbar.brick.png").Upozorenje = true; } else { StandardniUiElementi.glavnaDugmad.FirstOrDefault(x => x.ImageUrl == "/Images/appbar.brick.png").Upozorenje = false; } } catch(Exception ex) { TempData["Error"] = ex.Message; } } return View(); }
public ActionResult CreateJson([System.Web.Http.FromBody] Posao model) { if(Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 1 || Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 2) { try { var dbPomocnik = new MySqlPomocnik(); double potrebnaKolicinaMaterijala = Convert.ToDouble(model.KolicinaMaterijala); var materijal = dbPomocnik.IzvrsiProceduru<Materijal>(Konstante.StoredProcedures.DAJ_MATERIJAL_ID, new Dictionary<string, object> { { "ID", model.MaterijalId } }); if(materijal.Kolicina < potrebnaKolicinaMaterijala) { return Json(new { Error = "Nedovoljno raspoloživog materijala!" }, JsonRequestBehavior.AllowGet); } materijal.Kolicina -= potrebnaKolicinaMaterijala; dbPomocnik.IzvrsiProceduru(Konstante.StoredProcedures.IZMJENI_MATERIJAL, materijal); model.VrstaMaterijala = materijal.Naziv; var response = dbPomocnik.IzvrsiProceduru<Posao>(Konstante.StoredProcedures.DODAJ_POSAO, model); return Json(new { Status = "Uspjesno" }, JsonRequestBehavior.AllowGet); } catch(Exception ex) { return Json(new { Error = ex.Message }, JsonRequestBehavior.AllowGet); } } else { return Json(new { Status = "Neuspjesno" }, JsonRequestBehavior.AllowGet); } }
public async System.Threading.Tasks.Task<HttpResponseMessage> UploadFile([FromBody]string id) { var supportedTypes = new List<string> { "png", "jpg", "jpeg", "gif" }; if(!Request.Content.IsMimeMultipartContent()) { return Request.CreateErrorResponse(HttpStatusCode.UnsupportedMediaType, "The request doesn't contain valid content!"); } try { var provider = new MultipartMemoryStreamProvider(); await Request.Content.ReadAsMultipartAsync(provider); string fileName = ""; string fullpath = ""; var file = provider.Contents.FirstOrDefault(); if(file != null) { if(string.IsNullOrEmpty(file.Headers.ContentDisposition.FileName)) throw new ArgumentNullException("file", "Invalid file provided!"); var serverPath = System.Web.HttpContext.Current.Server.MapPath("~/Images/Profile"); fileName = GetFileName(serverPath, file.Headers); var ext = Path.GetExtension(fileName); if(!supportedTypes.Contains(ext.Trim().TrimStart('.'))) throw new ArgumentException("Provided file type is not supported!"); fullpath = Path.Combine(serverPath, Path.GetFileName(fileName)); var dataStream = await file.ReadAsStreamAsync(); using(var fileStream = File.Create(fullpath)) { dataStream.Seek(0, System.IO.SeekOrigin.Begin); dataStream.CopyTo(fileStream); } } var dbHelper = new MySqlPomocnik(); //dbHelper.IzvrsiProceduru(new SqlUpit(), new Dictionary<string,object>()); var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(JSONHelper.ToJSON(new { fileName = fileName }), Encoding.UTF8, "text/plain"); response.Content.Headers.ContentType = new MediaTypeWithQualityHeaderValue(@"text/html"); return response; } catch(Exception e) { return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message); } }
List<Table> DajTabele(string connectionString1, string connectionString2) { var dbPomocnik = new MySqlPomocnik(); var c1 = new ConnectionString(connectionString1); var c2 = new ConnectionString(connectionString2); var tabele1 = DajTabele(c1.Database, dbPomocnik); var tabele2 = DajTabele(c2.Database, dbPomocnik); return null; }
// GET: Posao/Create public ActionResult Create() { if(Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 1 || Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 2) { var dbPomocnik = new MySqlPomocnik(); ViewBag.Materijali = new MaterijaliController().DajSve(); return View("Novi"); } else { return RedirectToAction("Index", "Home"); } }
public ActionResult DajMaterijalPartialView(int materijalId) { try { var dbPomocnik = new MySqlPomocnik(); var materijal = dbPomocnik.IzvrsiProceduru<Materijal>(Konstante.StoredProcedures.DAJ_MATERIJAL_ID, new Dictionary<string, object> { { "ID", materijalId } }); return PartialView("Materijal", materijal); } catch(Exception ex) { return PartialView("Error", ex.Message); } }
public string DajMaterijaleZaPosao(int posaoId) { if(Online_Stamparija.Models.LogovaniKorisnik.Instanca.Logovan) { var response = new List<ActionResult>(); var dbPomocnik = new MySqlPomocnik(); var materijali = dbPomocnik.DajKolekciju<Materijal>(Konstante.StoredProcedures.DAJ_MATERIJALE_ZA_POSAO, new Dictionary<string, object> { { "PosaoId", posaoId } }); var m1 = PartialView("Materijal", materijali.FirstOrDefault()); var s2 = m1.RenderToString(); s2 = string.Empty; return string.Join(" ", materijali.Select(m => PartialView("~/Views/Shared/Materijal.cshtml", m).RenderToString()).ToList()); } return string.Empty; }
public ActionResult Create([System.Web.Http.FromBody]Korisnik model) { try { var dbPomocnik = new MySqlPomocnik(); model.Password = KriptoPomocnik.GetMd5Hash(model.Password); dbPomocnik.IzvrsiProceduru(Konstante.StoredProcedures.REGISTRUJ_KORISNIKA, model); return RedirectToAction("Index", "Users"); } catch(Exception ex) { TempData["Error"] = ex.Message; return RedirectToAction("Index", "Users"); } }
public void Btn_Izvrsi_Click(object sender, RoutedEventArgs e) { try { var upit = txtKveriTekst.SelectedText; if(string.IsNullOrEmpty(upit)) upit = txtKveriTekst.Text; var odgovor = new MySqlPomocnik().IzvrsiProceduru(new SqlUpit("", upit, new List<string>()), new Dictionary<string, object>()); if(odgovor != null) { dataGridOdgovor.ItemsSource = odgovor.AsDataView(); } } catch(Exception ex) { dataGridOdgovor.ItemsSource = new[] { new {ErrorMessage = ex.Message }}; //MessageBox.Show(ex.Message); } }
public ActionResult Create([System.Web.Http.FromBody] Materijal model) { if(Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 1 || Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 2) { try { var dbPomocnik = new MySqlPomocnik(); var response = dbPomocnik.IzvrsiProceduru<Materijal>(Konstante.StoredProcedures.DODAJ_MATERIJAL, model); return RedirectToAction("Index"); } catch(Exception ex) { TempData["Error"] = ex.Message; return RedirectToAction("Index", "Home"); } } else { return RedirectToAction("Index", "Home"); } }
public ActionResult Create([System.Web.Http.FromBody] Posao model) { if(Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 1 || Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 2) { try { var dbPomocnik = new MySqlPomocnik(); double potrebnaKolicinaMaterijala = Convert.ToDouble(model.KolicinaMaterijala); var materijal = dbPomocnik.IzvrsiProceduru<Materijal>(Konstante.StoredProcedures.DAJ_MATERIJAL_ID, new Dictionary<string, object> { { "ID", model.MaterijalId } }); if(materijal.Kolicina < potrebnaKolicinaMaterijala) { TempData["Error"] = "Nedovoljno raspoloživog materijala!"; return RedirectToAction("Index", "Home"); } materijal.Kolicina -= potrebnaKolicinaMaterijala; dbPomocnik.IzvrsiProceduru(Konstante.StoredProcedures.IZMJENI_MATERIJAL, materijal); model.VrstaMaterijala = materijal.Naziv; var response = dbPomocnik.IzvrsiProceduru<Posao>(Konstante.StoredProcedures.DODAJ_POSAO, model); return RedirectToAction("Index"); } catch(Exception ex) { TempData["Error"] = ex.Message; return RedirectToAction("Index", "Home"); } } else { return RedirectToAction("Index", "Home"); } }
public List<Materijal> DajSve() { var dbPomocnik = new MySqlPomocnik(); return dbPomocnik.IzvrsiProceduru<Materijal, Materijal>(Konstante.StoredProcedures.DAJ_MATERIJALE, new Models.Materijal()); }
public string DajPosloveId(int pocIndeks, int brojPoslova) { var response = new List<ActionResult>(); var dbPomocnik = new MySqlPomocnik(); var posaoIds = dbPomocnik.IzvrsiProceduru<DajPosloveModel, Posao>( Konstante.StoredProcedures.DAJ_POSLOVE_ID, new DajPosloveModel { poc = pocIndeks, kra = brojPoslova } ); return string.Join(";", posaoIds.Select(posao => posao.ID).ToList()); }
// GET: Posao/Details/5 public ActionResult Details(int id) { if(Online_Stamparija.Models.LogovaniKorisnik.Instanca.Logovan) { var model = new Posao(); try { var dbPomocnik = new MySqlPomocnik(); model = dbPomocnik.IzvrsiProceduru<Posao>(Konstante.StoredProcedures.DAJ_POSAO_ID, new Dictionary<string, object> { { "ID", id } }); } catch(Exception ex) { TempData["Error"] = ex.Message; } TempData["BocnaDugmad"] = new List<MetroItem> { new Online_Stamparija.Models.MenuItems.MetroItem { LinkUrl = "javascript: pokaziSakrij('prosireaDesnaTraka'); pokaziSakrij('obicnaDesnaTraka')", ImageUrl = "/Images/novi.materijal.B.png", Title="Dodaj Materijal", MinimumAllowedPosition = PozicijaEnum.Radnik }}; return View("Detalji", model); } else { return RedirectToAction("Index", "Home"); } }
public ActionResult Edit(int id, Materijal model) { if(Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 1 || Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 2) { try { IDbPomocnik dbPomocnik = new MySqlPomocnik(); dbPomocnik.IzvrsiProceduru<Materijal>(Konstante.StoredProcedures.IZMJENI_MATERIJAL, model); return RedirectToAction("Index"); } catch(Exception ex) { TempData["Error"] = ex.Message; return RedirectToAction("Index"); } } else { return RedirectToAction("Index", "Home"); } }
// GET: Posao/Edit/5 public ActionResult Edit(int id) { if(Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 1 || Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 2) { var dbPomocnik = new MySqlPomocnik(); Materijal model = dbPomocnik.IzvrsiProceduru<Materijal>(Konstante.StoredProcedures.DAJ_MATERIJAL_ID, new Dictionary<string, object> { { "ID", id } }); return View("Uredi", model); } else { return RedirectToAction("Index", "Home"); } }
public ActionResult Details(int id) { if(Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 1 || Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 2) { var model = new Materijal(); try { var dbPomocnik = new MySqlPomocnik(); model = dbPomocnik.IzvrsiProceduru<Materijal>(Konstante.StoredProcedures.DAJ_MATERIJAL_ID, new Dictionary<string, object> { { "ID", id } }); } catch(Exception ex) { TempData["Error"] = ex.Message; } return View("Detalji", model); } else { return RedirectToAction("Index", "Home"); } }
public ActionResult Delete(int id, FormCollection collection) { if(Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 1 || Online_Stamparija.Models.LogovaniKorisnik.Instanca.Pozicija == 2) { try { var dbPomocnik = new MySqlPomocnik(); dbPomocnik.IzvrsiProceduru<Posao>(Konstante.StoredProcedures.IZBRISI_MATERIJAL, new Dictionary<string, object> { { "ID", id } }); return RedirectToAction("Index"); } catch(Exception ex) { TempData["Error"] = ex.Message; return RedirectToAction("Index", "Home"); } } else { return RedirectToAction("Index", "Home"); } }
public ActionResult DajPosaoPartialView(int posaoId, bool lite = false) { try { var dbPomocnik = new MySqlPomocnik(); var posao = dbPomocnik.IzvrsiProceduru<Posao>(Konstante.StoredProcedures.DAJ_POSAO_ID, new Dictionary<string, object> { { "ID", posaoId } }); if(lite) return PartialView("PosaoLaganiDetalji", posao); else return PartialView("Posao", posao); } catch(Exception ex) { return PartialView("Error", ex.Message); } }
public bool PromjeniLozinku(string username, string oldPassword, string newPassword) { var dbPomocnik = new MySqlPomocnik(); var odg = dbPomocnik.IzvrsiProceduru(Konstante.StoredProcedures.PROMJENI_LOZINKU, new Dictionary<string, object>()); return true; }