private Odr ConvertToEntity(DataRow row) { if (row == null) { return(null); } Odr od = new Odr(); od.order_no = int.Parse(row["customer_no"].ToString()); od.order_date = DateTime.Parse(row["order_date"].ToString()); return(od); }
void nacrtajReklami() { int i = 1; if (Session["Korisnik"] != null) { this.Master.podatociFirma = (Dictionary <String, String>)(Session["Korisnik"]); try { oradb = WebConfigurationManager.ConnectionStrings["Tunel"].ToString(); String komanda = "Select p.ime as IME,tipcena.Ime as Tip,p.Cena as Cena,VratiCena(p.id," + this.Master.podatociFirma["KomitentId"].ToString() + ") as CenaP,Sliki.Slika_URL as URL from edinecnacena e join komitent on e.Komitent_ID=komitent.id join tipcena on tipcena.id=e.tipcena_id join proizvod p on p.id = e.proizvod_id join sliki on p.id = sliki.proizvod_id where komitent.id=" + this.Master.podatociFirma["KomitentId"].ToString(); OCon = new OracleConnection(oradb); OCom = new OracleCommand(komanda, OCon); OracleDataReader Odr; OCon.Open(); Odr = OCom.ExecuteReader(); this.reklamiNarackiDiv.Controls.AddAt(0, new LiteralControl("<div id=\"slikiReklami\" class=\"nar\">")); if (Odr.HasRows) { while (Odr.Read()) { String info = "<div class=\"hide\" id=\"" + i.ToString() + "\">Производ:" + Odr["Ime"].ToString() + "<br/>ТипЦена:" + Odr["Tip"].ToString() + "<br/>Цена регуларна:" + Odr["Cena"].ToString() + ",00ден<br/>Цена крајна:" + Odr["CenaP"].ToString() + ",00ден</div>"; this.proba.ContentTemplateContainer.Controls.Add(new LiteralControl(info)); this.reklamiNarackiDiv.Controls.Add(new LiteralControl("<img onmouseout=\"iscisti(this.alt)\" onmouseover=\"prikazi(this.alt)\" alt=\"" + i.ToString() + "\" src=\"" + Odr["URL"].ToString() + " \" width=\"150px\" height=\"550px\" />")); i++; } } else { komanda = "Select p.ime as Ime,p.Cena as Cena,s.Slika_URL as URL,VratiCena(p.id," + this.Master.podatociFirma["KomitentId"].ToString() + ") as CenaP from sliki s join proizvod p on p.id = s.proizvod_id"; OCom = new OracleCommand(komanda, OCon); Odr = OCom.ExecuteReader(); while (Odr.Read()) { String info = "<div class=\"hide\" id=\"" + i.ToString() + "\">Производ:" + Odr["Ime"].ToString() + "<br/>Цена регуларна:" + Odr["Cena"].ToString() + ",00ден<br/>Цена крајна:" + Odr["CenaP"].ToString() + ",00ден</div>"; this.proba.ContentTemplateContainer.Controls.Add(new LiteralControl(info)); this.reklamiNarackiDiv.Controls.Add(new LiteralControl("<img onmouseout=\"iscisti(this.alt)\" onmouseover=\"prikazi(this.alt)\" alt=\"" + i.ToString() + "\" src=\"" + Odr["URL"].ToString() + " \" width=\"150px\" height=\"550px\" />")); i++; } } this.reklamiNarackiDiv.Controls.AddAt(this.reklamiNarackiDiv.Controls.Count, new LiteralControl("</div>")); OCon.Close(); } catch (Exception ex) { OCon.Close(); Response.Write("Sliki Baza " + ex.Message); } } }
public Result <Odr> AddOrder(Odr od) { var result = new Result <Odr>(); string query = "select * from order where order_no = " + od.order_no + ";"; var dt = DataAccess.GetDataTable(query); if (dt == null || dt.Rows.Count == 0) { query = "Insert into order values ('" + od.order_date + "')"; } result.HasError = DataAccess.ExecuteQuery(query) <= 0; if (result.HasError) { result.Message = "Wrong"; } else { result.Data = od; } return(result); }
public Result <List <Odr> > GetAllOrder() { var result = new Result <List <Odr> >() { Data = new List <Odr>() }; try { string query = "Select * from order"; var dt = DataAccess.GetDataTable(query); for (int i = 0; i < dt.Rows.Count; i++) { Odr od = ConvertToEntity(dt.Rows[i]); result.Data.Add(od); } } catch (Exception exc) { result.HasError = true; result.Message = exc.Message; } return(result); }