private void Button1_Click(object sender, EventArgs e) { acc acnt = new acc(); DataTable dt = new DataTable(); acnt.user_code = txtuser.Text.Trim(); acnt.pass = txtpass.Text; dt = acnt.Select(); if (dt.Rows.Count > 0) { this.Close(); } else { MessageBox.Show("کلمه عبور نادرست است! دوباره سعی کنید!", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error); txtpass.Focus(); txtpass.SelectAll(); } }
private void btnUpdate_Click(object sender, EventArgs e) { // Declare local variables and objects... int intPosition; // Save the current record position... intPosition = objCurrencyManager.Position; if (rdobtnaccess.Checked) { acc acnt = new acc(); acnt.user_code = txtuser.Text.Trim(); acnt.fname = txtfname.Text; acnt.lname = txtlname.Text; acnt.tel = txttel.Text; acnt.address = txtaddress.Text; acnt.semat = txtsemat.Text.Trim(); acnt.UpdateAccess(); FillDataSetAndView(); BindFields(); // Set the record position // to the one that you saved... objCurrencyManager.Position = intPosition; // Show the current record position... ShowPosition(); // Display a message that the record was updated... toolStripStatusLabel1.Text = "عملیات ویرایش کاربر با موفقیت انجام شد"; } else if (rdobtnpass.Checked) { if (txtconfirmpass.Text.CompareTo(txtnewpass.Text) == 0) { acc acnt = new acc(); DataTable dt = new DataTable(); acnt.user_code = txtuser.Text.Trim(); acnt.pass = txtnowpass.Text; dt = acnt.Select(); if (dt.Rows.Count > 0)// password dorost bashad { acnt.user_code = txtuser.Text.Trim(); acnt.pass = txtnewpass.Text; acnt.UpdatePassword(); MessageBox.Show("کلمه عبور تغییر یافت", "توجه ", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); // Fill the DataSet and bind the fields... FillDataSetAndView(); BindFields(); // Set the record position // to the one that you saved... objCurrencyManager.Position = intPosition; // Show the current record position... ShowPosition(); // Display a message that the record was updated... toolStripStatusLabel1.Text = "عملیات ویرایش کاربر با موفقیت انجام شد"; } else { MessageBox.Show("کلمه عبور فعلی را درست وارد نمایید", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("کلمه های عبور جدید با هم مطابقت ندارد", "خطا"); } } }