narsil/Tanshu.Accounts.PointOfSale/User Management/UserForm.cs
unknown d8ecec8bb6 Added inverse Attribute to ProductGroup.
BillInventory Renamed.
Refactored Bill to be more usable.
Added Bill Detail Report.
Added Open Bill and Bill Details Roles.
Zero Rate Products have Yellow background Color.
Refactored UserBI, FoodTableBI, ModifierBI, PrintLocationBI, ProductBI, ProductGroupBI, TaxBI, UserBI,
Cached the Products List.
Product and Product Group Form Working.
2011-06-23 18:17:48 +05:30

82 lines
2.3 KiB
C#

using System;
using System.Windows.Forms;
using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Entities.Auth;
namespace Tanshu.Accounts.PointOfSale
{
public partial class UserForm : Form
{
User _user;
public UserForm(int? userID)
{
InitializeComponent();
if (userID.HasValue)
using (var bi = new UserBI())
_user = bi.Get(x => x.UserID == userID.Value);
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnDelete_Click(object sender, EventArgs e)
{
using (var bi = new UserBI())
bi.Delete(x => x.UserID == _user.UserID);
btnCancel_Click(sender, e);
}
private void NewUser_Load(object sender, EventArgs e)
{
if (_user == null)
return;
txtUsername.Text = _user.Name;
txtPassword.Text = _user.Password;
chkLocked.Checked = _user.LockedOut;
}
private bool Save()
{
if (_user == null)
_user = new User();
_user.Name = txtUsername.Text.Trim();
if (_user.Password != txtPassword.Text.Trim())
_user.Password = Common.Md5.Hash(txtPassword.Text.Trim(), "v2");
_user.LockedOut = (chkLocked.Checked == true ? true : false);
if (_user.UserID == 0)
using (var bi = new UserBI())
bi.Insert(_user);
else
using (var bi = new UserBI())
bi.Update(_user);
return true;
}
private void btnSave_Click(object sender, EventArgs e)
{
if (!ValidateValues())
{
MessageBox.Show("Missing Information: Please check the form.");
txtUsername.Focus();
}
else
{
Save();
btnCancel_Click(sender, e);
}
}
private bool ValidateValues()
{
if (txtUsername.Text.Trim() == "")
return false;
if (txtPassword.Text.Trim() == "")
return false;
return true;
}
}
}