private void btnSave_Click(object sender, EventArgs e) { Bitmap bmp = new Bitmap(pictureBox1.Image, pictureBox1.Width, pictureBox1.Height); Graphics g = Graphics.FromImage(bmp); //检查是否存在文件夹 string subPath = "D://image"; if (false == System.IO.Directory.Exists(subPath)) { //创建pic文件夹 System.IO.Directory.CreateDirectory(subPath); } try { bmp.Save("D://image//" + strFilePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp); Bitmap bmps = new Bitmap("D://image//" + strFilePath + ".bmp"); pictureBox1.Image = bmps; AccessOperation.ExecuteNonQuery("Update [Messages] Set [Image]='" + strFilePath + "' Where [UserName]='" + username + "'"); } catch { MessageBox.Show("保存失败(尝试更改文件名后上传)"); return; } MessageBox.Show("保存成功!"); }
private void btnYes_Click(object sender, EventArgs e) { Regex pattern_password = new Regex(@"[\da-zA-Z0-9]{6,15}"); if (!pattern_password.IsMatch(txtUser.Text)) { MessageBox.Show("密码应为6到15位字母或数字!"); txtPs1.Text = ""; txtPs2.Text = ""; return; } if (!txtPs1.Text.Equals(txtPs2.Text)) { MessageBox.Show("两次输入的新密码不同!"); txtPs1.Text = ""; txtPs2.Text = ""; return; } try { AccessOperation.ExecuteNonQuery("Update [Login] Set [Password]='" + txtPs1.Text + "' Where [UserName]='" + txtUser.Text + "'"); MessageBox.Show("密码更改成功!"); this.Hide(); new Login().Show(); } catch { MessageBox.Show("未知错误未能更新密码!"); } }
private void btnSave_Click(object sender, EventArgs e) { try { //MessageBox.Show(""); AccessOperation.ExecuteNonQuery("Insert Into [Record] ([Movie], [UserName], [Link]) VALUES('" + MovieName + "', '" + username + "', '" + textBox1.Text + "')"); MessageBox.Show("收藏成功!"); } catch { MessageBox.Show("收藏失败!"); } }
private void btnDelete_Click(object sender, EventArgs e) { if (movies != "") { AccessOperation.ExecuteNonQuery("Delete * From Record Where Movie = '" + movies + "' and UserName='******'"); MessageBox.Show("删除成功!"); DataSet myDataSet = AccessOperation.Query("Select * From Record Where UserName='******'", "Record"); dataGridView1.DataSource = myDataSet.Tables["Record"]; } else { MessageBox.Show("未选中行!"); } }
private void btnSavemessage_Click(object sender, EventArgs e) { try { AccessOperation.ExecuteNonQuery("Insert Into [Messages] ([UserName], [RealName], [Sign],[Sex],[Old],[Style]) VALUES('" + username + "', '" + txtName.Text + "', '" + txtSign2.Text + "','" + cbSex.Text + "','" + txtOld.Text + "','" + cbStyle.Text + "')"); MessageBox.Show("信息插入成功!"); this.Hide(); new Login().Show(); } catch { MessageBox.Show("信息插入失败(未知错误)!"); } }
private void btnSavemessage_Click(object sender, EventArgs e) { try { AccessOperation.ExecuteNonQuery("Update Messages Set Sex='" + cbSex.Text + "' Where UserName='******'"); AccessOperation.ExecuteNonQuery("Update Messages Set Sign='" + txtSign2.Text + "' Where UserName='******'"); AccessOperation.ExecuteNonQuery("Update Messages Set Old='" + txtOld.Text + "' Where UserName='******'"); AccessOperation.ExecuteNonQuery("Update Messages Set RealName='" + txtName.Text + "' Where UserName='******'"); AccessOperation.ExecuteNonQuery("Update Messages Set Style='" + cbStyle.Text + "' Where UserName='******'"); MessageBox.Show("信息更新成功,界面主题会在下次开启本软件时更新!"); skinEngine1.SkinFile = @"Skins\" + AccessOperation.ExecuteScalar("Select Style From Messages Where UserName='******'").ToString(); } catch { MessageBox.Show("信息更新失败(未知错误)!"); } }
private void btnPost_Click(object sender, EventArgs e) { if (AccessOperation.Exists("Select * From Login where Password = '******' and UserName = '******'") == false) { MessageBox.Show("原密码错误!"); txtps1.Text = ""; txtps2.Text = ""; txtps3.Text = ""; return; } if (txtps1.Text == "" || txtps2.Text == "" || txtps3.Text == "") { MessageBox.Show("更改密码所需信息不能为空!"); return; } Regex pattern_password = new Regex(@"[\da-zA-Z0-9]{6,15}"); if (!pattern_password.IsMatch(txtps2.Text)) { MessageBox.Show("密码应为6到15位字母或数字!"); txtps2.Text = ""; txtps3.Text = ""; return; } if (!txtps2.Text.Equals(txtps3.Text)) { MessageBox.Show("两次输入的新密码不同!"); txtps2.Text = ""; txtps3.Text = ""; return; } try { AccessOperation.ExecuteNonQuery("Update [Login] Set [Password]='" + txtps2.Text + "' Where [UserName]='" + username + "'"); MessageBox.Show("修改完成!"); }catch { MessageBox.Show("修改失败!"); } }
private void btnLogin_Click(object sender, EventArgs e) { if (txtPwd.Text.Length == 0 || cbUser.Text.Length == 0) { MessageBox.Show("用户名或密码不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (AccessOperation.Exists("Select * From Login where UserName='******'") == false) { MessageBox.Show("用户不存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (AccessOperation.Exists("Select * From Login where Password = '******' and UserName = '******'") == false) { MessageBox.Show("密码错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (AccessOperation.Exists("Select * From Login where Password = '******' and UserName = '******'")) { username = cbUser.Text; MessageBox.Show("欢迎使用电影爱好者平台!"); if (!AccessOperation.Exists("Select * From UsedUser where UserName = '******'")) { try { AccessOperation.ExecuteNonQuery("Insert Into [UsedUser] VALUES('" + cbUser.Text + "')"); }catch { MessageBox.Show("未能插入本次登陆记录"); } } this.Hide(); this.skinEngine1.SkinFile = @"Skins\" + AccessOperation.ExecuteScalar("Select Style From Messages where UserName = '******'"); new Main(username).Show(); return; } }
private void btnRegister_Click(object sender, EventArgs e) { Regex pattern_email = new Regex(@"^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$"); Regex pattern_username = new Regex(@"[\da-zA-Z0-9]{2,10}"); Regex pattern_password = new Regex(@"[\da-zA-Z0-9]{6,15}"); if (txtUser.Text.Length == 0) { MessageBox.Show("用户名不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtEmail.Text.Length == 0) { MessageBox.Show("邮箱不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtPwd.Text.Length == 0) { MessageBox.Show("密码不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (AccessOperation.Exists("Select * From Login where UserName='******'") != false) { MessageBox.Show("用户名重复!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUser.Text = ""; return; } if (!pattern_username.IsMatch(txtUser.Text)) { MessageBox.Show("用户名应为2到10位字母或数字!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUser.Text = ""; return; } if (AccessOperation.Exists("Select * From Login where Email='" + txtEmail.Text + "'")) { MessageBox.Show("邮箱已使用!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Text = ""; return; } if (!pattern_email.IsMatch(txtEmail.Text)) { MessageBox.Show("邮箱格式错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Text = ""; return; } if (!pattern_password.IsMatch(txtUser.Text)) { MessageBox.Show("密码应为6到15位字母或数字!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPwd.Text = ""; txtRepeat.Text = ""; return; } if (txtRepeat.Text.Equals(txtPwd.Text) == false) { MessageBox.Show("密码两次输入不相同!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPwd.Text = ""; txtRepeat.Text = ""; return; } AccessOperation.ExecuteNonQuery("Insert Into [Login] ([UserName], [Password], [Email]) VALUES('" + txtUser.Text + "', '" + txtPwd.Text + "', '" + txtEmail.Text + "')"); MessageBox.Show("注册成功!"); this.Hide(); new InputMessages(txtUser.Text).Show(); return; }