private void button1_Click(object sender, EventArgs e) { if (txtName.Text == string.Empty || txtPass.Text == string.Empty) { MessageBox.Show("请输入用户名和密码!"); return; } DataSet ds = MainConfig.GetRecord("select * from [user] where UserName='******' and PassWord='******'"); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { MainConfig.Userds = ds; MainWindow mainwindow = new MainWindow(); mainwindow.Show(); this.Hide(); } else { MessageBox.Show("登录失败!"); return; } } else { MessageBox.Show("登录失败,数据库操作失败!"); return; } }
private void button1_Click(object sender, EventArgs e) { string sql = "insert into word(word,yinbiao,translate,type,fenzu,zhongwenyuyin,YingWenYuYan,SuoXie) values('" + word.Text + "','" + yinbiao.Text + "','" + translate.Text + "','" + wordtype.Text + "','" + fenzu.Text + "','" + textBox1.Text + "','" + textBox2.Text + "','" + txtSuoXie.Text + "')"; MainConfig.Excute(sql); MessageBox.Show("添加成功!"); }
private void button1_Click(object sender, EventArgs e) { string sql = "update [word] set word='" + word.Text + "',yinbiao='" + this.yinbiao.Text + "',Type='" + wordtype.Text + "',Translate='" + translate.Text + "',fenzu='" + fenzu.Text + "' where id='" + MainWindow.wordID + "'"; MainConfig.Excute(sql); MessageBox.Show("保存成功!"); }
private void UserDetail_Load(object sender, EventArgs e) { if (MainWindow.userID != "0") { DataSet ds = MainConfig.GetRecord("select * from [User] where Id='" + MainWindow.userID + "'"); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; this.UserName.Text = dr["UserName"].ToString(); UserName.Enabled = false; this.realName.Text = dr["realName"].ToString(); this.IdCard.Text = dr["idCard"].ToString(); this.Birthday.Text = dr["Birthday"].ToString(); this.Email.Text = dr["Email"].ToString(); this.Telephone.Text = dr["Telephone"].ToString(); this.Sex.Text = dr["Sex"].ToString(); this.UserType.Text = dr["UserType"].ToString() == "1" ? "管理员" : "普通用户"; this.remark.Text = dr["remark"].ToString(); } else { MessageBox.Show("找不到用户!"); } } } }
private void dataUser_CellContentClick(object sender, DataGridViewCellEventArgs e) { string action = dataUser.Columns[e.ColumnIndex].Name;//操作类型 if (action == "caozuo") { string id = dataUser.Rows[e.RowIndex].Cells[9].Value.ToString(); MainWindow.userID = id; UserDetail detail = new UserDetail(); detail.Show(); } if (action == "shanchu") { if (MessageBox.Show("确认删除?") == DialogResult.OK) { string id = dataUser.Rows[e.RowIndex].Cells[9].Value.ToString(); string sql = "delete [user] where id='" + id + "'"; MainConfig.Excute(sql); DataSet ds = MainConfig.GetRecord("select * from [User]"); dataUser.AutoGenerateColumns = false; dataUser.AllowUserToAddRows = false; dataUser.DataSource = ds.Tables[0].DefaultView; } } }
/// <summary> /// 初始化用户 /// </summary> private void InitFX() { DataSet ds = MainConfig.GetRecord("select Storage.ID as aid,word.* from Storage inner join Word on word.ID=Storage.wordID where Storage.UserID='" + MainConfig.Userds.Tables[0].Rows[0]["ID"].ToString() + "'"); dataFX.AutoGenerateColumns = false; dataFX.AllowUserToAddRows = false; dataFX.DataSource = ds.Tables[0].DefaultView; }
private void button5_Click(object sender, EventArgs e) { DataSet ds = MainConfig.GetRecord("select top 20 Storage.ID as aid,word.* from Storage inner join Word on word.ID=Storage.wordID where Storage.UserID='" + MainConfig.Userds.Tables[0].Rows[0]["ID"].ToString() + "' order by newid() desc"); dataFX.AutoGenerateColumns = false; dataFX.AllowUserToAddRows = false; dataFX.DataSource = ds.Tables[0].DefaultView; }
private void button1_Click(object sender, EventArgs e) { DataSet ds = MainConfig.GetRecord("select * from [Word] where word like '%" + textBox2.Text + "%' or SuoXie Like '%" + textBox2.Text + "%'"); dataWord.AutoGenerateColumns = false; dataWord.AllowUserToAddRows = false; dataWord.DataSource = ds.Tables[0].DefaultView; }
private void btn_Search_Click(object sender, EventArgs e) { DataSet ds = MainConfig.GetRecord("select * from [User] where username like '%" + textBox1.Text + "%'"); dataUser.AutoGenerateColumns = false; dataUser.AllowUserToAddRows = false; dataUser.DataSource = ds.Tables[0].DefaultView; }
private void InitUser() { DataSet ds = MainConfig.GetRecord("select * from [User]"); dataUser.AutoGenerateColumns = false; dataUser.AllowUserToAddRows = false; dataUser.DataSource = ds.Tables[0].DefaultView; }
private void button1_Click(object sender, EventArgs e) { string type = UserType.Text == "管理员" ? "1" : "2"; string sql = "update [User] set IdCard='" + IdCard.Text + "',Birthday='" + this.Birthday.Text + "',Sex='" + Sex.Text + "',RealName='" + realName.Text + "',Email='" + Email.Text + "',Telephone='" + Telephone.Text + "',Remark='" + remark.Text + "',UserType='" + type + "' where id='" + MainWindow.userID + "'"; MainConfig.Excute(sql); MessageBox.Show("保存成功!"); }
private void button6_Click(object sender, EventArgs e) { DataSet ds = MainConfig.GetRecord("select Storage.ID as aid,word.* from Storage inner join Word on word.ID=Storage.wordID where Storage.UserID='" + MainConfig.Userds.Tables[0].Rows[0]["ID"].ToString() + "' and word.word like '%" + SCTXT.Text + "%'"); dataSC.AutoGenerateColumns = false; dataSC.AllowUserToAddRows = false; dataSC.DataSource = ds.Tables[0].DefaultView; }
/// <summary> /// 初始化自由记忆单词 /// </summary> private void InitFenZu() { string sql = "select top 20 * from word where fenzu='" + fenzuType.Text + "'"; DataSet ds = MainConfig.GetRecord(sql); dataFenzu.AutoGenerateColumns = false; dataFenzu.AllowUserToAddRows = false; dataFenzu.DataSource = ds.Tables[0].DefaultView; }
/// <summary> /// 初始化自由记忆单词 /// </summary> private void InitZiYou() { string sql = "select top 20 * from word"; DataSet ds = MainConfig.GetRecord(sql); dataziyou.AutoGenerateColumns = false; dataziyou.AllowUserToAddRows = false; dataziyou.DataSource = ds.Tables[0].DefaultView; }
private void button3_Click(object sender, EventArgs e) { string sql = "select top 20 * from word where fenzu='" + fenzuType.Text + "' order by newid() desc"; DataSet ds = MainConfig.GetRecord(sql); dataFenzu.AutoGenerateColumns = false; dataFenzu.AllowUserToAddRows = false; dataFenzu.DataSource = ds.Tables[0].DefaultView; }
private void button12_Click(object sender, EventArgs e) { DataSet ds = MainConfig.GetRecord("select * from word where word='" + txtFY.Text + "'"); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; LblResult_Click(dr["zhongwenyuyin"].ToString(), e); } }
//private void beginGame_Click(object sender, EventArgs e) //{ // beginGame.Text = "开始游戏...."; // beginGame.Enabled= false; // DataSet ds = MainConfig.GetRecord("select top 1 * from word order by newid() desc"); // if (ds != null) // { // if (ds.Tables[0].Rows.Count > 0) // { // string DC = ds.Tables[0].Rows[0]["word"].ToString(); // this.lblSY.Text = ds.Tables[0].Rows[0]["translate"].ToString(); // Random rad = new Random(); // int temp=rad.Next(0, DC.Length - 1); // int i = 0; // foreach (char c in DC) // { // if (temp == i) // { // this.lblDC.Text += "_"; // tempchar=c.ToString(); // } // else // { // this.lblDC.Text += c.ToString(); // } // i++; // } // this.lblSY.Text = ds.Tables[0].Rows[0]["translate"].ToString(); // } // } // timer1.Start(); //} //private void timer1_Tick(object sender, EventArgs e) //{ // this.lblDJ.Text = (Convert.ToInt32(lblDJ.Text)-1).ToString(); // if (this.lblDJ.Text == "0") // { // GameFail++; // this.lblDJ.Text = "5"; // this.lblDC.Text = string.Empty; // beginGame_Click(null, null); // } // if (GameSuccess + GameFail == 10) // { // timer1.Stop(); // string mess = string.Empty; // if (GameSuccess >= 8) // { // mess = "评级:英语牛人!"; // } // if (GameSuccess < 8 && GameSuccess >= 5) // { // mess = "评级:英语达人"; // } // if (GameSuccess < 5) // { // mess = "评级:英语菜鸟"; // } // MessageBox.Show("游戏结束,当前得分" + GameSuccess * 10 + "分;" + mess); // GameSuccess = 0; // GameFail = 0; // tempchar = string.Empty; // beginGame.Enabled = true; // beginGame.Text = "开始游戏"; // } //} //private void button9_Click(object sender, EventArgs e) //{ // if (tempchar == txtZM.Text) // { // GameSuccess++; // } // else // { // GameFail++; // } // this.lblDJ.Text = "5"; // this.lblDC.Text = string.Empty; // beginGame_Click(null, null); // if (GameSuccess + GameFail == 10) // { // timer1.Stop(); // string mess = string.Empty; // if (GameSuccess >= 8) // { // mess = "评级:英语牛人!"; // } // if (GameSuccess < 8 && GameSuccess >= 5) // { // mess = "评级:英语达人"; // } // if (GameSuccess < 5) // { // mess = "评级:英语菜鸟"; // } // MessageBox.Show("游戏结束,当前得分"+GameSuccess*10+"分;"+mess); // GameSuccess = 0; // GameFail = 0; // tempchar = string.Empty; // beginGame.Enabled = true; // beginGame.Text = "开始游戏"; // } // this.lblDJ.Text = "5"; //} private void button10_Click(object sender, EventArgs e) { button10.Text = "开始测试...."; button10.Enabled = false; DataSet ds = MainConfig.GetRecord("select top 1 * from word order by newid() desc"); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { tempDC = ds.Tables[0].Rows[0]["word"].ToString(); this.lblCs.Text = ds.Tables[0].Rows[0]["translate"].ToString(); } } }
private void dataSC_CellContentClick(object sender, DataGridViewCellEventArgs e) { string action = dataSC.Columns[e.ColumnIndex].Name; //操作类型 if (action == "deleteStrage") { if (MessageBox.Show("确认删除?") == DialogResult.OK) { string id = dataSC.Rows[e.RowIndex].Cells[5].Value.ToString(); string sql = "delete Storage where id='" + id + "'"; MainConfig.Excute(sql); DataSet ds = MainConfig.GetRecord("select Storage.ID as aid,word.* from Storage inner join Word on word.ID=Storage.wordID where Storage.UserID='" + MainConfig.Userds.Tables[0].Rows[0]["ID"].ToString() + "' and word.word like '%" + SCTXT.Text + "%'"); dataSC.AutoGenerateColumns = false; dataSC.AllowUserToAddRows = false; dataSC.DataSource = ds.Tables[0].DefaultView; } } }
private void button1_Click(object sender, EventArgs e) { string exist = "select * from [User] where username='******'"; DataSet ds = MainConfig.GetRecord(exist); if (ds.Tables[0].Rows.Count > 0) { MessageBox.Show("该用户名已注册!"); return; } if (pass.Text == string.Empty || pass.Text != confirm.Text) { MessageBox.Show("密码输入不正确!"); } string sql = "insert into [User](UserName,PassWord,IdCard,Birthday,Sex,RealName,Email,Telephone,Remark,UserType) values('" + UserName.Text + "','" + pass.Text + "','" + IdCard.Text + "','" + this.Birthday.Text + "','" + Sex.Text + "','" + realName.Text + "','" + Email.Text + "','" + Telephone.Text + "','" + remark.Text + "',2)"; //string sql = "update [User] set IdCard='" + IdCard.Text + "',Birthday='" + this.Birthday.Text + "',Sex='" + Sex.Text + "',RealName='" + realName.Text + "',Email='" + Email.Text + "',Telephone='" + Telephone.Text + "',Remark='" + remark.Text + "',UserType='" + type + "' where id='" + MainWindow.userID + "'"; MainConfig.Excute(sql); MessageBox.Show("注册成功!"); }
private void dataFenzu_CellContentClick(object sender, DataGridViewCellEventArgs e) { string action = dataFenzu.Columns[e.ColumnIndex].Name;//操作类型 if (action == "StorageBtn") { string id = dataFenzu.Rows[e.RowIndex].Cells[4].Value.ToString(); string sql = "select * from Storage where UserId='" + MainConfig.Userds.Tables[0].Rows[0]["ID"].ToString() + "' and wordID='" + id + "'"; DataSet ds = MainConfig.GetRecord(sql); if (ds.Tables[0].Rows.Count > 0) { MessageBox.Show("您已收藏过该单词!"); } else { string sql1 = "insert into Storage(UserID,UserName,WordID,WordName) values('" + MainConfig.Userds.Tables[0].Rows[0]["ID"].ToString() + "','" + MainConfig.Userds.Tables[0].Rows[0]["UserName"].ToString() + "','" + id + "','" + dataFenzu.Rows[e.RowIndex].Cells[0].Value.ToString() + "')"; MainConfig.Excute(sql1); MessageBox.Show("收藏成功!"); } } }
private void button7_Click(object sender, EventArgs e) { this.lblResult.Text = string.Empty; this.lblYinbiao.Text = string.Empty; this.lblFY.Text = string.Empty; if (txtFY.Text == string.Empty) { MessageBox.Show("请输入单词"); } else { DataSet ds = MainConfig.GetRecord("select * from word where word='" + txtFY.Text + "' or SuoXie='" + txtFY.Text + "'"); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; this.lblResult.Text = "单词:" + dr["word"].ToString(); this.lblYinbiao.Text = "音标:" + dr["yinbiao"].ToString(); this.lblFY.Text = "释义:" + dr["Translate"].ToString(); } } }
private void WordDetail_Load(object sender, EventArgs e) { if (MainWindow.wordID != "0") { DataSet ds = MainConfig.GetRecord("select * from [word] where Id='" + MainWindow.wordID + "'"); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; this.word.Text = dr["word"].ToString(); this.yinbiao.Text = dr["yinbiao"].ToString(); this.wordtype.Text = dr["type"].ToString(); this.translate.Text = dr["Translate"].ToString(); this.fenzu.Text = dr["fenzu"].ToString(); } else { MessageBox.Show("找不到用户!"); } } } }
private void button14_Click(object sender, EventArgs e) { DataTable dt = ConvertCSVToTable(this.textBox3.Text); foreach (DataRow dr in dt.Rows) { try { DataSet dsds = MainConfig.GetRecord("select * from Word where Word='" + dr[0].ToString() + "'"); if (dsds != null && dsds.Tables[0].Rows.Count > 0) { } else { string sql = "insert into word(word,translate,type) values('" + dr[0].ToString() + "','" + dr[2].ToString() + "','" + dr[1].ToString() + "')"; MainConfig.Excute(sql); } } catch { } } MessageBox.Show("数据导入完毕"); }