protected void b_send_Click(object sender, EventArgs e) { if (tb_cno.Text.Length == 0) { WebMessage.Show("请输入课程号!"); } else { ConnSql con = new ConnSql(); System.Data.DataTable table = new System.Data.DataTable(); string tno = con.RunSqlReturnTable("select tno from teacher where tname='" + ddl_lt.Text.Trim() + "'").Rows[0][0].ToString(); int result = con.RunSql("insert into course(cno,cname,tno,xs,skdd) values ('" + tb_cno.Text.Trim() + "','" + tb_cname.Text.Trim() + "','" + tno + "','" + tb_cth.Text.Trim() + "','" + tb_classAdd.Text.Trim() + "')"); if (result == 1) { WebMessage.Show("添加成功"); } else { WebMessage.Show("添加失败"); } } }
protected void Page_Load(object sender, EventArgs e) {//IsPostBack == false && if (Request.QueryString["kch"] != null) { string kch = Request.QueryString["kch"].ToString(); ConnSql con = new ConnSql(); System.Data.DataTable table = new System.Data.DataTable(); table = con.RunSqlReturnTable("SELECT * from course where cno = '" + kch + "'"); if (!IsPostBack && table.Rows.Count != 0) { //ddl_tch.SelectedIndex = 0; tb_cno.Text = table.Rows[0]["cno"].ToString(); tb_cname.Text = table.Rows[0]["cname"].ToString(); tb_lt.Text = table.Rows[0]["xs"].ToString(); tb_addr.Text = table.Rows[0]["skdd"].ToString(); ddl_tch.DataBind(); ddl_tch.SelectedValue = table.Rows[0]["tno"].ToString(); var list = ddl_tch.Items.FindByValue(table.Rows[0]["tno"].ToString()); //ddl_tch.SelectedItem;// = table.Rows. } } else { Response.Redirect("./CourseManage.aspx"); } }
protected void Button1_Click(object sender, EventArgs e) { string sqltext = ""; ConnSql con = new ConnSql(); if (TextBox1.Text == "") { WebMessage.Show("输入初始密码!"); } else if (TextBox2.Text == "") { WebMessage.Show("请输入密码!"); } else if (TextBox2.Text != TextBox3.Text) { WebMessage.Show("输入的两次密码不相同!"); } else if (TextBox2.Text.Length < 6) { WebMessage.Show("密码长度小于6"); } else if (TextBox1.Text != Session["password"].ToString()) { WebMessage.Show("你输入原始密码不正确!"); } else { sqltext = "update student set pwd='" + TextBox2.Text + "'where sno='" + Session["username"].ToString() + "'"; con.RunSql(sqltext); Session["password"] = TextBox2.Text;//保存新密码到Session WebMessage.Show("修改密码正确!", "selectCourse.aspx"); } }
/// <summary> /// vérifier le donnée a déjà exist dans la base de données /// </summary> /// <param name="Table">La table</param> /// <param name="Colonne">Le colonne de la table</param> /// <param name="Value">La valeur du colonne</param> /// <returns>bool</returns> private bool DonneeIsExist(string Table, string Colonne, string Value) { CmdRecherche = ConnSql.CreateCommand(); //Rechercher ID familles en relation dans table "Familles" CmdRecherche.CommandText = "SELECT COUNT( " + Colonne + " ) FROM " + Table + " WHERE " + Colonne + "=@Value;"; CmdRecherche.Parameters.AddWithValue("@Value", Value); CmdRecherche.ExecuteNonQuery(); RdrReche = CmdRecherche.ExecuteReader(); try { int Count = -1; if (RdrReche.Read()) { Count = (int)RdrReche.GetValue(0); } if (Count > 0) { return(true); } else { return(false); } } catch (Exception ex) { Console.Out.WriteLine(ex.Message); return(false); } }
protected void Button1_Click(object sender, EventArgs e) { ConnSql con = new ConnSql(); con.RunSql("insert stu_course(sno,cno) values('" + Label9.Text.Trim() + "','" + Label11.Text.Trim() + "')"); Response.Redirect("QueryCourse.aspx"); }
protected void Button1_Click(object sender, EventArgs e) //添加 { ConnSql con = new ConnSql(); string sqltext = ""; sqltext = "insert student(sno,sname,sex,birthday) values('" + TextBox1.Text.Trim() + "','" + TextBox2.Text.Trim() + "','" + DropDownList1.SelectedIndex.ToString() + "','" + TextBox3.Text.Trim() + "')"; con.RunSql(sqltext); TextBox1.Text = "添加成功"; TextBox2.Text = string.Empty; TextBox3.Text = DateTime.Now.ToString("yyyy-MM-dd"); }
/// <summary> /// Insérer les données de Familles dans la base de données, si ce nom exsite déjà, /// on ne l'ajoute pas /// </summary> /// <param name="Value">La valeur de nom du Familles<</param> private void InsererFamilles(string Value) { SqlCeCommand CmdSql = ConnSql.CreateCommand(); Value = Regex.Replace(Value, @"\s+", " "); if (!DonneeIsExist("Familles", "Nom", Value)) { CmdSql.CommandText = "INSERT INTO Familles(Nom) values(@FNom)"; CmdSql.Parameters.AddWithValue("@FNom", Value); CmdSql.ExecuteNonQuery(); Console.Out.WriteLine("INSERT INTO Familles(Nom) values(" + Value + ")"); } }
/// <summary> /// Insérer les données de SousFamilles dans la base de données, si ce nom exsite déjà, /// on ne l'ajoute pas /// </summary> /// <param name="Value">La valeur de nom du SousFamille</param> /// <param name="Famille">La valeur de nom du Famille</param> private void InsererSousFamilles(string Value, string Famille) { SqlCeCommand CmdSql = ConnSql.CreateCommand(); Value = Regex.Replace(Value, @"\s{1,}", " "); if (!DonneeIsExist("SousFamilles", "Nom", Value)) { CmdSql.CommandText = "INSERT INTO SousFamilles(Nom,IDFamille) values(@SFNom,@IDFam)"; CmdSql.Parameters.AddWithValue("@SFNom", Value); CmdSql.Parameters.AddWithValue("@IDFam", GetIdByName("Familles", Famille)); CmdSql.ExecuteNonQuery(); Console.Out.WriteLine("INSERT INTO SousFamilles(Nom,IDFamille) values(" + Value + "," + GetIdByName("Familles", Famille) + ")"); } }
protected void Button1_Click(object sender, EventArgs e) { ConnSql con = new ConnSql(); string sqltext = ""; sqltext = "delete student where sno='" + TextBox1.Text.Trim() + "'"; if (con.RunSql(sqltext) == 1) { WebMessage.Show("删除成功"); } else { WebMessage.Show("删除失败"); } }
protected void Button_Confirm(object sender, EventArgs e) { if (Username.Text == "") { WebMessage.Show("请输入用户名"); } else if (name.Text == "") { WebMessage.Show("请输入姓名"); } else if (xueyuan.Text == "") { WebMessage.Show("请输入学院"); } else if (banji.Text == "") { WebMessage.Show("请输入班级"); } else if (Password.Text == "") { WebMessage.Show("请输入密码"); } else if (Check.Text == "") { WebMessage.Show("请再次输入密码"); } else if (Password.Text != Check.Text) { WebMessage.Show("密码不一致!"); } else { string sql = "INSERT INTO bookuser (id,pwd,name,class,xueyuan,status,sex,admin,times1) VALUES ('" + Username.Text.Trim() + "','" + Password.Text.Trim() + "','" + name.Text.Trim() + "','" + banji.Text.Trim() + "','" + xueyuan.Text.Trim() + "','1','" + RadioButtonList1.SelectedValue + "','0','0')"; ConnSql conn = new ConnSql(); int s = conn.RunSql(sql); if (s > 0) { WebMessage.Show("添加成功", "Index.aspx"); } else { WebMessage.Show("添加失败"); } } }
/// <summary> /// Insérer les données de Articles dans la base de données, si la référence exsite déjà, /// on ne l'ajoute pas /// </summary> /// <param name="Descrip">La valeur de la description</param> /// <param name="Ref">La valeur de la référence</param> /// <param name="Prix">La valeur de prix</param> /// <param name="Marque">La valeur de nom du Marque</param> /// <param name="SousFamille">La valeur de nom du SousFamille</param> private void InsererArticles(string Descrip, string Ref, double Prix, string Marque, string SousFamille) { SqlCeCommand CmdSql = ConnSql.CreateCommand(); if (!DonneeIsExist("Articles", "Ref", Ref)) { CmdSql.CommandText = "INSERT INTO Articles(Description,Ref,Prix,IDMarque,IDSousFamille)" + "values(@ADspt,@ARef,@APrix,@AIDMq,@AIDSsFm);"; CmdSql.Parameters.AddWithValue("@ADspt", Descrip); CmdSql.Parameters.AddWithValue("@ARef", Ref); CmdSql.Parameters.AddWithValue("@APrix", Prix); CmdSql.Parameters.AddWithValue("@AIDMq", GetIdByName("Marques", Marque)); CmdSql.Parameters.AddWithValue("@AIDSsFm", GetIdByName("SousFamilles", SousFamille)); CmdSql.ExecuteNonQuery(); Console.Out.WriteLine("INSERT INTO Articles(Description,Ref,Prix,IDMarque,IDSousFamille)values(" + Descrip + "," + Ref + "," + Prix + "," + GetIdByName("Marques", Marque) + "," + GetIdByName("SousFamilles", SousFamille)); } }
protected void bSend_Click(object sender, EventArgs e) { //!Error 学生姓名过长会 截断字符串 ConnSql con = new ConnSql(); int sex_tmp = rb_girl.Checked ? 1 : 0; // 暂存性别信息 女true 男false sex_tmp = con.RunSql("update student set sname = '" + tb_sname.Text.Trim() + "', sex=" + sex_tmp + ", birthday = '" + tb_birth.Text.Trim() + "' where sno = '" + tb_sno.Text.Trim() + "'"); if (sex_tmp.Equals(1)) { WebMessage.Show("执行成功"); } else { WebMessage.Show("执行失败"); } }
protected void btn_login_Click(object sender, EventArgs e) { if (btn_showCheck.Text == tb_checkcode.Text.Trim()) { ConnSql conn = new ConnSql(); string sql = "select * from student where sno = '" + tb_sno.Text + "' AND pwd='" + tb_pwd.Text + "'"; var table = conn.RunSqlReturnTable(sql); if (table.Rows.Count != 0) { Session["sno"] = tb_sno.Text.Trim(); Session["sname"] = table.Rows[0]["sname"].ToString().Trim(); Response.Redirect("Stu/UpdateStu.aspx"); } else { Response.Redirect("./Default.aspx"); } } }
/// <summary> /// supprimer toutes les données de la base de données .sdf /// </summary> private void ClearAllData() { ConnSql.Open(); SqlCeCommand Cmd = new SqlCeCommand("DELETE FROM Articles", ConnSql); Cmd.ExecuteNonQuery(); Cmd.CommandText = "DELETE FROM Marques"; Cmd.ExecuteNonQuery(); Cmd.CommandText = "DELETE FROM SousFamilles"; Cmd.ExecuteNonQuery(); Cmd.CommandText = "DELETE FROM Familles"; Cmd.ExecuteNonQuery(); ConnSql.Close(); }
protected void btn_edit_Click(object sender, EventArgs e) { ConnSql con = new ConnSql(); string sql = "update course set " + "cname = '" + tb_cname.Text + "'," + "xs = " + int.Parse(tb_lt.Text.Trim()) + "," + "skdd = '" + tb_addr.Text + "'," + "tno = '" + ddl_tch.SelectedValue + "'" + " where cno = '" + tb_cno.Text + "'"; try { con.RunSql(sql); } catch (Exception ex) { WebMessage.Show(ex.ToString()); throw; } }
protected void Button2_Click(object sender, EventArgs e) { if (TextBox1.Text.Trim() == "") { WebMessage.Show("请输入用户名"); } else if (TextBox2.Text.Trim() == "") { WebMessage.Show("请输入密码"); } else if (TextBox3.Text.Trim() == "") { WebMessage.Show("请输入验证码"); } else { string sqltext = "select * from student where sno='" + TextBox1.Text.Trim() + "'"; DataTable table = new DataTable(); ConnSql cn = new ConnSql(); table = cn.RunSqlReturnTable(sqltext); if (table.Rows.Count <= 0) { WebMessage.Show("用户名错误!"); } else if (table.Rows[0]["pwd"].ToString().Trim() != TextBox2.Text) { WebMessage.Show("密码错误!"); } else if (TextBox3.Text.Trim().ToUpper() != Button1.Text.Trim().ToUpper()) { WebMessage.Show("验证码错误!"); } else { Session["username"] = TextBox1.Text.Trim(); Session["password"] = TextBox2.Text.Trim(); Session["sname"] = table.Rows[0]["sname"].ToString().Trim(); WebMessage.Show("全部正确", "StudentMain.aspx"); } } }
/// <summary> /// lecture du fichier excel et stockage les contenu dans la base de données .sdf /// </summary> /// <param name="PathExcel">le complète path du fichier Excel</param> /// <param name="PathSdf">le complète path du fichier Sdf</param> public void LectureExcel(string PathExcel, string PathSdf) { Connection(PathExcel, PathSdf);//connecter le fichier .xls et le fichier .sdf try { while (ReaderExcel.Read()) { //Console.Out.WriteLine(ReaderExcel.GetString(0) + ";" + ReaderExcel.GetString(1) + ";" + ReaderExcel.GetString(2) + ";" + ReaderExcel.GetString(3) + ";" + ReaderExcel.GetString(4) + ";" + ReaderExcel.GetDouble(5)); SqlCeCommand CmdSql = ConnSql.CreateCommand(); InsererMarques(ReaderExcel.GetString(2)); // Insérer Marques InsererFamilles(ReaderExcel.GetString(3)); // Insérer Familles InsererSousFamilles(ReaderExcel.GetString(4), ReaderExcel.GetString(3)); // Insérer SousFamilles InsererArticles(ReaderExcel.GetString(0), ReaderExcel.GetString(1), ReaderExcel.GetDouble(5), ReaderExcel.GetString(2), ReaderExcel.GetString(4));// Insérer Articles } ReaderExcel.Close(); } catch (Exception ex) { Console.Out.WriteLine(ex.Message); } finally { if (ConnOleDb.State == ConnectionState.Open) { ConnOleDb.Close(); ConnOleDb.Dispose(); } if (ConnSql.State == ConnectionState.Open) { ConnSql.Close(); ConnSql.Dispose(); } } Console.In.Read(); }
protected void bCheck_Click(object sender, EventArgs e) { if (tb_sno.Text.Length == 0) { WebMessage.Show("请输入学号!"); } else { ConnSql con = new ConnSql(); DataTable table = new DataTable(); table = con.RunSqlReturnTable("select * from student where sno = " + "'" + tb_sno.Text.Trim() + "'"); if (table.Rows.Count.Equals(0)) { WebMessage.Show("学号不存在"); return; } else { tb_sname.Text = table.Rows[0][1].ToString(); //获取出生年月日 string s = table.Rows[0]["birthday"].ToString(); tb_birth.Text = s.Substring(0, s.LastIndexOf(' ')); //获取性别 if (table.Rows[0]["sex"].Equals(true)) { rb_girl.Checked = true; } else { rb_man.Checked = true; } tb_sno.BackColor = System.Drawing.Color.DarkGray; tb_sno.ReadOnly = true; } } }
/// <summary> /// obtenir ID par le nom donnée de la table /// </summary> /// <param name="Table">Le nom de la table</param> /// <param name="NomValue">La valeur du nom</param> /// <returns>ID </returns> private int GetIdByName(string Table, string NomValue) { CmdRecherche = ConnSql.CreateCommand(); //Rechercher ID familles en relation dans table "Familles" CmdRecherche.CommandText = "SELECT [ID] FROM " + Table + " WHERE Nom=@Nom;"; CmdRecherche.Parameters.AddWithValue("@Nom", NomValue); CmdRecherche.ExecuteNonQuery(); RdrReche = CmdRecherche.ExecuteReader(); try { int IDFam = -1; while (RdrReche.Read())//normalement il y a qu'un resultat { IDFam = (int)RdrReche.GetValue(0); } //set le paramètre IDFam dans l'insertion de SousFamilles return(IDFam); } catch (Exception ex) { Console.Out.WriteLine(ex.Message); return(-1); } }
protected void btn_login_Click(object sender, EventArgs e) { string sqltext = "select * from admini where username = '******' and pwd = '" + tb_password.Text + "'"; ConnSql conn = new ConnSql(); System.Data.DataTable table = conn.RunSqlReturnTable(sqltext); if (tb_checkcode.Text == btn_img.Text) { if (table.Rows.Count != 1) { WebMessage.Show("用户名或密码错误。"); } else { Session["username"] = table.Rows[0]["username"]; Response.Redirect("Index_Admin.aspx"); } //return; } else { WebMessage.Show("验证码错误。"); } }
protected void Button3_Click(object sender, EventArgs e) //测试数据库连接 { ConnSql con = new ConnSql(); con.Test(); }
public MainPageCS(App app) { // switch(RuntimePlateform); var padding = new Thickness(0, 40, 0, 0); ConnSql s = ConnSql.Instance; var listUser = s.CountUtilisateur(); if (listUser.Count != 0) { List <ContentPage> listContent = new List <ContentPage>(); //List<> for (int i = 0; i < listUser.Count; i++) { Button bouton1 = new Button2(); bouton1.Text = "Creer nouveau"; bouton1.HorizontalOptions = LayoutOptions.Center; bouton1.VerticalOptions = LayoutOptions.EndAndExpand; bouton1.Clicked += (sender, ea) => { App.Instance.ToNewUser(); } ; Button2 bouton2 = new Button2(); bouton2.Text = "Supprimer "; bouton2.HorizontalOptions = LayoutOptions.Center; bouton2.VerticalOptions = LayoutOptions.Center ; bouton2.utilisateur = listUser[i]; bouton2.Clicked += (sender, ea) => { var e = i; Containeur.Instance.delUser(bouton2.utilisateur); App.Instance.ToCarrousel(); }; Button2 bouton = new Button2(); bouton.Text = "Selectionner "; bouton.HorizontalOptions = LayoutOptions.Center; bouton.VerticalOptions = LayoutOptions.Center ; bouton.utilisateur = listUser[i]; bouton.Clicked += (sender, ea) => { var e = i; Containeur.Instance.SetUser(bouton.utilisateur); };// } //fonctionClicked; string str = listUser[i].nom; string str2 = listUser[i].prenom; var redContentPage = new ContentPage { Padding = padding, Content = new StackLayout { Children = { new Label { Text = "Selectionnez un compte", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalOptions = LayoutOptions.Center }, new StackLayout { VerticalOptions = LayoutOptions.CenterAndExpand, Children = { new Label { Text = str, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalOptions = LayoutOptions.Center }, new Label { Text = str2, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalOptions = LayoutOptions.Center }, new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.CenterAndExpand, Children = { bouton, bouton2 } } } }, bouton1 } } }; listContent.Add(redContentPage); } foreach (ContentPage cp in listContent) { Children.Add(cp); } } else { var redContentPage = new ContentPage { Padding = padding, Content = new StackLayout { } }; Children.Add(redContentPage); Thread.Sleep(100); App.Instance.ToNewUser(); } }
protected void Button_Login(object sender, EventArgs e) { if (Username.Text == "") { WebMessage.Show("请输入用户名"); } else if (Password.Text == "") { WebMessage.Show("请输入密码"); } else if (yzm.Text == "") { WebMessage.Show("请输入验证码"); } else { string sqltext = "select * from bookuser where id='" + Username.Text + "'"; DataTable table = new DataTable(); ConnSql cn = new ConnSql(); table = cn.RunSqlReturnTable(sqltext); if (table.Rows.Count <= 0) { WebMessage.Show("用户名错误!"); } else if (table.Rows[0][1].ToString().Trim() != Password.Text) { WebMessage.Show("密码错误!"); } else if (table.Rows[0][4].ToString().Trim() == "0") { WebMessage.Show("账户处于挂失状态,无法登陆!"); } else if (yzm.Text != btn_yzm.Text) { WebMessage.Show("验证码输入错误"); } else { ConnSql con = new ConnSql(); string sql = "update bookuser SET last_login_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff") + "' WHERE id='" + table.Rows[0][0].ToString() + "'"; con.RunSql(sql); //保存登录的用户的用户名和密码到Session对象 Session["Admin"] = table.Rows[0][5].ToString(); if (Session["Admin"].ToString() == "1") { Session["Username"] = table.Rows[0][0].ToString(); Session["Password"] = table.Rows[0][1].ToString(); Session["Name"] = table.Rows[0][2].ToString(); Session["Time"] = table.Rows[0][6].ToString(); Session["id"] = Username.Text; WebMessage.Show("登录成功,管理员:" + Session["Name"].ToString().Trim() + "欢迎您!", "/Admin/Index/Index.aspx"); } else if (Session["Admin"].ToString() == "0") { Session["Username"] = table.Rows[0][0].ToString(); Session["Password"] = table.Rows[0][1].ToString(); Session["Name"] = table.Rows[0][2].ToString(); Session["Time"] = table.Rows[0][6].ToString(); Session["id"] = Username.Text; WebMessage.Show("登录成功," + Session["Name"].ToString().Trim() + "同学,欢迎您!", "/Home/Index/Index.aspx"); } } } }
Containeur() { this.sql = ConnSql.Instance; }
protected void Page_Load(object sender, EventArgs e) { HotMenu.DataSource = ConnSql.Re("select top 5 menuid,COUNT(*) lysl,name=(select name from bbs_menu where id=menuid ) from bbs_ly group by menuid order by 2 desc").DefaultView; HotMenu.DataBind(); }