protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { DB.Open(); string[][] contactsArray = DB.Query("SELECT * FROM contacts WHERE Id=1"); AddressTextBox.Text = contactsArray[0][1].ToString(); PostalTextBox.Text = contactsArray[0][2].ToString(); CityTextBox.Text = contactsArray[0][3].ToString(); PhoneTextBox.Text = contactsArray[0][4].ToString(); HandphoneTextbox.Text = contactsArray[0][5].ToString(); EmailTextBox.Text = contactsArray[0][6].ToString(); } catch (Exception ex) { } finally { DB.Close(); } } }
/// <summary> /// Adds an SHA256 encrypted IP and browser information to the database. /// </summary> /// <param name="ip">The IP which you want added to the database.</param> /// <param name="browserVersion">The version of the users browser.</param> /// <param name="browserPlatform">The users platform. e.g. WinNT.</param> public void Add(string ip, string browserName, string browserVersion, string browserPlatform) { try { int uniqueIp = 0; //If the IP already exists in the DB, we will not add it again. We only want unique ips. DB.Open(); string[][] getIp = DB.Query("SELECT * FROM ips"); for (int i = 0; i < getIp.Length; i++) { if (getIp[i][1] == Sha256(ip)) { uniqueIp++; } } if (uniqueIp == 0) { DB.Exec("INSERT INTO ips VALUES('" + Sha256(ip) + "', '" + browserName + "', '" + browserVersion + "', '" + browserPlatform + "')"); } } catch (Exception ex) { } finally { DB.Close(); } }
// static method public static UnitModel GetModelFromID(string id) { IDatabase sqldb = new SQLDatabase(); sqldb.Open(); SqlDataReader reader = sqldb.ExcuteReader("SELECT * FROM DONVITINH WHERE MaDonViTinh='" + id + "'"); while (reader.Read()) { UnitModel unit = new UnitModel(reader.GetString(0), reader.GetString(1)); sqldb.Close(); return(unit); } sqldb.Close(); return(null); }
protected void btnOpret_Click(object sender, EventArgs e) { SQLDatabase db = new SQLDatabase("ForumDB.mdf", "LocalDB", "", ""); if ((txtUsername.Text != "") && (txtMail.Text != "") && (txtMail.Text.Contains("@"))) { if (txtPassword.Text.Equals(txtConfPass.Text)) { string password = PasswordHash.CreateHash(txtPassword.Text); try { db.Open(); db.Exec("INSERT INTO Users(user_name, user_pass, user_email, user_date, userlevel) VALUES('" + txtUsername.Text + "', '" + password + "', '" + txtMail.Text + "', GETDATE(), 1)"); } catch (Exception ex) { lblFejl.Text = "En fejl er muligvis opstået. Prøv igen."; } finally { content.InnerHtml = "Brugeren er nu oprettet. Du kan logge ind <a href='LogIn.aspx'>her</a>."; db.Close(); } } } else { lblFejl.Text = "Udfyld venligst alle felterne korrekt."; } }
protected void Page_Load(object sender, EventArgs e) { SQLDatabase db = new SQLDatabase("ForumDB.mdf", "LocalDB", "", ""); string html = ""; if (Request.Cookies["forumcookie"]["userlevel"] == "0") { try { db.Open(); db.Exec("DELETE FROM posts WHERE post_id =" + Request.QueryString["id"]); } catch (Exception ex) { } finally { db.Close(); html = "Tråden er nu slettet, du kan vende tilbage til forsiden <a href='Default.aspx'>her</a>."; content.InnerHtml = html; } } else { content.InnerHtml = "Du har vist ikke noget at gøre her. Vend tilbage til forsiden ved at klikke <a href='Default.aspx'>på dette link</a>."; } }
public static int GetSumDetailImportationFromIngridient(string ingridientID) { IDatabase sqldb = new SQLDatabase(); int result = 0; try { sqldb.Open(); SqlDataReader reader = sqldb.ExcuteReader("SELECT COUNT(MaCTPhieuNhapHang) FROM CHITIETPHIEUNHAPHANG WHERE MaNguyenLieu = '" + ingridientID + "'"); while (reader.Read()) { result = reader.GetInt32(0); } } catch (SqlException e) { Debug.LogOutput("Sql exception in ListDetailImportationModel >> " + e.ToString()); return(0); } finally { sqldb.Close(); } return(result); }
public static int GetSumDetailImportation() { IDatabase sqldb = new SQLDatabase(); int result = 0; try { sqldb.Open(); SqlDataReader reader = sqldb.ExcuteReader("SELECT COUNT(MaPhieuNhapHang) FROM PHIEUNHAPHANG"); while (reader.Read()) { result = reader.GetInt32(0); } } catch (SqlException e) { Debug.LogOutput("Sql exception in ListDetailImportationModel >> " + e.ToString()); return(0); } finally { sqldb.Close(); } return(result); }
public static ProductTypeModel GetModelFromID(string id) { IDatabase sqldb = new SQLDatabase(); sqldb.Open(); SqlDataReader reader = sqldb.ExcuteReader("SELECT * FROM LOAIMATHANG WHERE MaLoaiMatHang='" + id + "'"); while (reader.Read()) { ProductTypeModel type = new ProductTypeModel(reader.GetString(0), reader.GetString(1)); sqldb.Close(); return(type); } sqldb.Close(); return(null); }
protected void btnOpret_Click(object sender, EventArgs e) { if (Request.Cookies["forumcookie"]["userlevel"] == "0") { SQLDatabase db = new SQLDatabase("ForumDB.mdf", "LocalDB", "", ""); try { db.Open(); db.Exec("INSERT INTO topics (topic_subject, topic_date, topic_cat, topic_by, topic_locked) VALUES('" + txtEmne.Text + "', GETDATE(), " + Request.QueryString["id"] + ", " + Request.Cookies["forumcookie"]["userid"] + ", 0)"); //db.Exec("INSERT INTO posts (post_content, post_date, post_topic, post_by) VALUES ('" + txtContent.Text + "', GETDATE(), " + Request.QueryString["id"] + ", " + Request.Cookies["forumcookie"]["userid"]+")"); } catch (Exception ex) { } finally { db.Close(); Response.Redirect("Category.aspx?id=" + Request.QueryString["id"]); } } else { content.InnerHtml = "Du skal være oprettet som bruger før du kan oprette en tråd."; } }
public static int GetSumDetailBillFromProduct(string productID) { IDatabase sqldb = new SQLDatabase(); int result = 0; try { sqldb.Open(); SqlDataReader reader = sqldb.ExcuteReader("SELECT COUNT(MaCTHoaDon) FROM CHITIETHOADON WHERE MaMatHang = '" + productID + "'"); while (reader.Read()) { result = reader.GetInt32(0); } } catch (SqlException e) { Debug.LogOutput("Sql exception in ListDetailBillModel >> " + e.ToString()); return(0); } finally { sqldb.Close(); } return(result); }
protected void Page_Load(object sender, EventArgs e) { try { DB.Open(); string[][] contactsArray = DB.Query("SELECT * FROM contacts WHERE Id=1"); string email = contactsArray[0][6]; string htmlstring = ""; htmlstring += contactsArray[0][1] + "<br />"; htmlstring += contactsArray[0][2] + ", " + contactsArray[0][3] + "<br />"; htmlstring += "<abbr title='Telefon'>Tlf: </abbr>" + contactsArray[0][4] + "<br />"; htmlstring += "<abbr title='Mobiltelefon'>Mobil: </abbr>" + contactsArray[0][5]; addressBox.InnerHtml = htmlstring; if (email != "" || email != null) { emailaddressBox.InnerHtml = "<strong>Salg:</strong> <a href='mailto:" + email + "'>" + email + "</a><br />"; } } catch (Exception ex) { } finally { DB.Close(); } }
public static PositionModel GetModelFromID(string id) { IDatabase sqldb = new SQLDatabase(); sqldb.Open(); SqlDataReader reader = sqldb.ExcuteReader("SELECT * FROM CHUCVU WHERE MaChucVu='" + id + "'"); while (reader.Read()) { PositionModel type = new PositionModel(reader.GetString(0), reader.GetString(1)); sqldb.Close(); return(type); } sqldb.Close(); return(null); }
public static string GenerateID() { IDatabase sqldb = new SQLDatabase(); string currentID = null; try { sqldb.Open(); SqlDataReader reader = sqldb.ExcuteReader("SELECT MAX(MaNhanVien) FROM NHANVIEN"); while (reader.Read()) { currentID = reader.GetString(0); } if (currentID != null) { string prefix = currentID.Substring(0, 2); int no = Convert.ToInt32(currentID.Substring(2, 3)); return(prefix + (++no).ToString("000")); } } catch (SqlException e) { Debug.LogOutput("SqlException in EmployeeModel >> " + e.ToString()); } finally { sqldb.Close(); } return(null); }
protected void add_button_Click(object sender, EventArgs e) { DB.Open(); DB.Exec("INSERT INTO links (title, link) VALUES ('" + titleTextBox.Text + "', '" + linkTextBox.Text + "')"); DB.Close(); GridView1.DataBind(); }
protected void confirm_Button_Click(object sender, EventArgs e) { DB.Open(); DB.Exec("INSERT INTO productinfo (productname, amount, price, info) VALUES ('" + navnTextbox.Text + "', " + amountTextBox.Text + ", " + prisTextbox.Text + ", '" + infoTextbox.Text + "')"); //content12.InnerHtml += "<p>" + getData[i][1] + i + "</p>"; DB.Close(); GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { DB.Open(); string[][] profileArray = DB.Query("SELECT profile FROM profileinfo WHERE Id=1"); profilEditTextBox.Text = profileArray[0][0]; } catch (Exception ex) { } finally { DB.Close(); } } }
public static void SaveToDatabase(BillModel bill) { IDatabase sqldb = new SQLDatabase(); try { sqldb.Open(); sqldb.ExcuteNonQuery("INSERT INTO HOADON VALUES('" + bill.ID + "', " + bill.DeskNo + ",'" + bill.Date + "', " + bill.Price + ")"); sqldb.Close(); } catch (SqlException e) { Debug.LogOutput(e.ToString()); } }
public static void SaveToDatabase(DetailImportationModel detail) { IDatabase sqldb = new SQLDatabase(); try { sqldb.Open(); sqldb.ExcuteNonQuery("INSERT INTO CHITIETPHIEUNHAPHANG VALUES('" + detail.ID + "', '" + detail.ImportationID + "', '" + detail.IngridientID + "', " + detail.Quantity + ", " + detail.Price + ")"); sqldb.Close(); } catch (SqlException e) { Debug.LogOutput(e.ToString()); } }
public static void SaveToDatabase(DetailBillModel detail) { IDatabase sqldb = new SQLDatabase(); try { sqldb.Open(); sqldb.ExcuteNonQuery("INSERT INTO CHITIETHOADON VALUES('" + detail.ID + "', '" + detail.BillID + "', '" + detail.ProductID + "', " + detail.Quantity + ", " + detail.Price + ")"); sqldb.Close(); } catch (SqlException e) { Debug.LogOutput(e.ToString()); } }
public static void SaveToDatabase(ImportationModel importation) { IDatabase sqldb = new SQLDatabase(); try { sqldb.Open(); sqldb.ExcuteNonQuery("INSERT INTO PHIEUNHAPHANG VALUES('" + importation.ID + "', '" + importation.Date + "', " + importation.Price + ")"); sqldb.Close(); } catch (SqlException e) { Debug.LogOutput(e.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { try { DB.Open(); string[][] profileArray = DB.Query("SELECT profile FROM profileinfo WHERE id=1"); ProfileContent.InnerHtml = "<p>" + profileArray[0][0] + "</p>"; } catch (Exception ex) { } finally { DB.Close(); } }
static void Main(string[] args) { ws.HTTPDataReceived += Ws_HTTPDataReceived; web.HTTPDataReceived += Web_HTTPDataReceived; var x = string.Empty; while (x != "-exit") { x = Console.ReadLine(); } web.Dispose(); ws.Dispose(); db.Close(); }
protected void btnRyd_Click(object sender, EventArgs e) { SQLDatabase DB = new SQLDatabase("JTM.mdf", "LocalDB", "", ""); try { DB.Open(); DB.Exec("DELETE * FROM ips"); } catch (Exception ex) { } finally { DB.Close(); } }
public static void RemoveFromDatabase(string productID) { IDatabase sqldb = new SQLDatabase(); try { sqldb.Open(); sqldb.ExcuteNonQuery("UPDATE MATHANG SET GhiChu='REMOVED' WHERE MaMatHang='" + productID + "'"); } catch (SqlException e) { Debug.LogOutput("SqlException in ProductModel >> " + e.ToString()); } finally { sqldb.Close(); } }
public static void RemoveFromDatabase(string employeeID) { IDatabase sqldb = new SQLDatabase(); try { sqldb.Open(); sqldb.ExcuteNonQuery("UPDATE NHANVIEN SET GhiChu='REMOVED' WHERE MaNhanVien='" + employeeID + "'"); } catch (SqlException e) { Debug.LogOutput("SqlException in EmployeeModel >> " + e.ToString()); } finally { sqldb.Close(); } }
public static void UpdateDatabase(ProductModel product) { IDatabase sqldb = new SQLDatabase(); try { sqldb.Open(); sqldb.ExcuteNonQuery("UPDATE MATHANG SET TenMatHang = N'" + product.Name + "', MaLoaiMatHang='" + product.TypeID + "', MaDonViTinh='" + product.UnitID + "', TriGia=" + product.Price + ", HinhAnh='" + product.ImageSource + "' WHERE MaMatHang='" + product.ID + "'"); } catch (SqlException e) { Debug.LogOutput("SqlException in ProductModel >> " + e.ToString()); } finally { sqldb.Close(); } }
protected void CreateSubBtn_Click(object sender, EventArgs e) { if (Request.Cookies["forumcookie"] != null && subname != null && subdesc != null) { if (Request.Cookies["forumcookie"]["userlevel"] == "0") { SQLDatabase db = new SQLDatabase("ForumDB.mdf", "LocalDB", "", ""); db.Open(); db.Exec("INSERT INTO categories (cat_name, cat_description) VALUES ('" + subname.Value + "','" + subdesc.Value + "')"); db.Close(); } else { content.InnerHtml = "<p>Du skal være administrator for at oprette et nyt suforum</p>"; } } Response.Redirect("Default.aspx"); }
public static void RemoveFromDatabase(string ingridientID) { IDatabase sqldb = new SQLDatabase(); try { sqldb.Open(); sqldb.ExcuteNonQuery("UPDATE NGUYENLIEU SET GhiChu='REMOVED' WHERE MaNguyenLieu='" + ingridientID + "'"); } catch (SqlException e) { Debug.LogOutput("SqlException in IngridientModel >> " + e.ToString()); } finally { sqldb.Close(); } }
public static void UpdateDatabase(IngridientModel ingridient) { IDatabase sqldb = new SQLDatabase(); try { sqldb.Open(); sqldb.ExcuteNonQuery("UPDATE NGUYENLIEU SET TenNguyenLieu = N'" + ingridient.Name + "', MaDonViTinh='" + ingridient.UnitID + "', TriGia=" + ingridient.Price + ", HinhAnh='" + ingridient.ImageSource + "' WHERE MaNguyenLieu='" + ingridient.ID + "'"); } catch (SqlException e) { Debug.LogOutput("SqlException in IngridientModel >> " + e.ToString()); } finally { sqldb.Close(); } }
public void SaveToDatabase() { IDatabase sqldb = new SQLDatabase(); try { sqldb.Open(); sqldb.ExcuteNonQuery("INSERT INTO NHANVIEN VALUES('" + ID + "', N'" + Name + "', '" + Birthday + "', " + CardID + ", '" + Phone + ", '" + PositionID + ", '" + StartDate + ", '" + Shift + "', NULL)"); } catch (SqlException e) { Debug.LogOutput("SqlException in EmployeeModel >> " + e.ToString()); } finally { sqldb.Close(); } }