|
 |
|
Property Get/Set ใช้แล้วยังส่งไม่ได้สักที (Visual C#) ปัญหาการเปลี่ยนรหัสผ่าน |
|
 |
|
|
 |
 |
|
ผมเน้นตรงสีแดงไว้ให้แล้วครับ!! มันไม่ยอมส่งค่ามา ?
'
Form login
Code (C#)
private string Passwords;
public string password
{
set {
Passwords = value;
}
get{
return Passwords;
}
}
private void butt_from_Click(object sender, EventArgs e)
{
string conStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DataPro.mdf;Integrated Security=True;User Instance=True;";
connection = new SqlConnection(conStr);
connection.Open();
sql = "SELECT me_username,me_password,me_status FROM member where me_username =@user and me_password =@pass";
command = new SqlCommand(sql, connection);
command.Parameters.AddWithValue("user", user.Text);
command.Parameters.AddWithValue("pass", pass.Text);
SqlDataAdapter adapter = new SqlDataAdapter(command);
//command.Parameters.Clear();
//adapter.SelectCommand = command;
DataSet data = new DataSet();
adapter.Fill(data,"member");
DataTable dtb1 = data.Tables["member"];
int check = dtb1.Rows.Count;
if (check > 0)
{
string st1 = dtb1.Rows[0]["me_status"].ToString();
if (st1 == "admin")
{
if (pass.Text == "1234")
{
MessageBox.Show("กรุณาเปลี่ยนรหัสผ่าน เพื่อความปลอดภัย" ,"ตรวจพบเป็นรหัสแรกเริ่ม",MessageBoxButtons.OK);
}
password = pass.Text;
main man = new main();
man.Show();
man.Showme("Admin");
this.Hide();
}
else
{
main man = new main();
man.Show();
man.Showme("Teacher");
this.Hide();
}
}
else
{
MessageBox.Show("ชื่อหรือรหัสผ่านไม่ถูกต้อง กรุณากรอกอีกครั้ง","ผิดพลาด",MessageBoxButtons.OK);
}
}
form change password
public partial class changepass : Form
{
public changepass()
{
InitializeComponent();
}
private SqlConnection connection;
private SqlCommand command;
private string sql;
private void changepass_Load(object sender, EventArgs e)
{
string conStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DataPro.mdf;Integrated Security=True;User Instance=True;";
connection = new SqlConnection(conStr);
connection.Open();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void buttonOK_Click(object sender, EventArgs e)
{
if (passold.Text != "" && passnew.Text != "" && checkpass.Text != "")
{
login log2 = new login();
string pw1 = log2.password;
if (passold.Text == pw1)
{
if (passnew.Text == checkpass.Text)
{
UpdatePass();
}
else
{
MessageBox.Show("กรอกรหัสผ่านใหม่กับยืนยันรหัสผ่านไม่ตรงกัน กรุณากรอกอีกครั้ง", "ผิดพลาด", MessageBoxButtons.OK);
}
}
else
{
MessageBox.Show("กรอกรหัสผ่านเก่าไม่ถูกต้อง กรุณากรอกอีกครั้ง", "ผิดพลาด", MessageBoxButtons.OK);
}
}
else
{
MessageBox.Show("กรอกไม่ครบทุกช่อง กรุณากรอกอีกครั้ง", "ผิดพลาด", MessageBoxButtons.OK);
}
}
Tag : .NET, Win (Windows App), C#

|
|
 |
 |
 |
 |
Date :
2012-08-30 15:08:21 |
By :
ArmLazySong |
View :
4044 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (C#)
string pw1 = log2.password;
ไม่ต้อง New ครับ ถ้าคุณประกาศแบบ Public มันสามารถเรียก ชื่อ form ตามด้วย ตัวแปรครับ
|
 |
 |
 |
 |
Date :
2012-08-30 20:38:47 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2012-08-30 21:19:08 |
By :
ArmLazySong |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|