narsil/Tanshu.Accounts.PointOfSale/User Management/ChangePassword.cs

85 lines
3.0 KiB
C#
Raw Permalink Normal View History

2010-03-02 17:56:21 +00:00
using System;
using System.Drawing;
2010-03-02 17:56:21 +00:00
using System.Windows.Forms;
using Tanshu.Accounts.Contracts;
2018-08-24 10:41:33 +00:00
using Tanshu.Accounts.Repository;
using Tanshu.Common.KeyboardControl;
2010-03-02 17:56:21 +00:00
namespace Tanshu.Accounts.PointOfSale
{
public partial class ChangePassword : Form
{
IKeyboardControl keyboardControl;
public ChangePassword(IKeyboardControl keyboardControl)
2010-03-02 17:56:21 +00:00
{
InitializeComponent();
this.keyboardControl = keyboardControl;
var control = keyboardControl as UserControl;
if (control != null)
{
control.Location = new System.Drawing.Point(6, 140);
this.Controls.Add(control);
this.Size = this.SizeFromClientSize(new Size(6 + control.Width + 6, 140 + control.Height + 6));
}
2010-03-02 17:56:21 +00:00
}
private void ChangePassword_Load(object sender, EventArgs e)
{
2011-01-06 07:17:00 +00:00
txtUsername.Text = Session.User.Name;
2010-03-02 17:56:21 +00:00
}
private void btnCancel_Click(object sender, EventArgs e)
2010-03-02 17:56:21 +00:00
{
this.Close();
}
private void btnChangePassword_Click(object sender, EventArgs e)
2010-03-02 17:56:21 +00:00
{
if (txtPassword.Text.Trim() == "")
MessageBox.Show("Old password can not be blank", "Blank not allowed");
else
{
if (txtnewPassword.Text.Trim() == "")
MessageBox.Show("New password can not be blank", "Blank not allowed");
else
{
if (txtnewPassword.Text.Trim() != txtConfirmPassword.Text.Trim())
MessageBox.Show("New password not matched to confirm password", "Password not matched");
else
{
2018-08-24 10:41:33 +00:00
var changed = UserBI.ChangePassword(Session.User.Name, txtPassword.Text.Trim(), txtnewPassword.Text.Trim());
if (changed)
2010-03-02 17:56:21 +00:00
{
2018-08-24 10:41:33 +00:00
MessageBox.Show("Password changed", "Confirm");
this.Close();
2010-03-02 17:56:21 +00:00
}
else
MessageBox.Show("old Password not matched for user", "Wrong Password");
}
}
}
}
private void btnMsr_Click(object sender, EventArgs e)
{
2018-08-24 10:41:33 +00:00
var user = UserBI.ValidateUser(Session.User.Name, txtPassword.Text.Trim());
if (user == null)
return;
using (var frm = new MsrLoginForm(true))
{
2018-08-24 10:41:33 +00:00
frm.ShowDialog();
var msrString = frm.User().MsrString;
if (MessageBox.Show("Update Msr Card", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) !=
DialogResult.Yes)
return;
2018-08-24 10:41:33 +00:00
UserBI.ChangeMsr(user.Name, txtPassword.Text.Trim(), msrString);
MessageBox.Show("Msr Card Updated");
this.Close();
}
}
2010-03-02 17:56:21 +00:00
}
}