85 lines
2.2 KiB
C#
85 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Tanshu.Accounts.Helpers;
|
|
using Tanshu.Accounts.BI;
|
|
using Tanshu.Accounts.Contracts;
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
{
|
|
public partial class UserForm : Form
|
|
{
|
|
UserBO user;
|
|
public UserForm( Guid? userID)
|
|
{
|
|
InitializeComponent();
|
|
if (userID.HasValue)
|
|
user = new UserBI().GetUser(userID.Value);
|
|
}
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void btnCreateUSer_Click(object sender, EventArgs e)
|
|
{
|
|
new UserBI().Delete(user.UserID);
|
|
btnCancel_Click(sender, e);
|
|
}
|
|
|
|
private void NewUser_Load(object sender, EventArgs e)
|
|
{
|
|
if (user != null)
|
|
{
|
|
txtUsername.Text = user.Name;
|
|
txtPassword.Text = user.Password;
|
|
chkLocked.Checked = user.LockedOut;
|
|
}
|
|
}
|
|
|
|
private bool Save()
|
|
{
|
|
if (user == null)
|
|
user = new UserBO();
|
|
user.Name = txtUsername.Text.Trim();
|
|
user.Password = Tanshu.Common.Md5.Hash(txtPassword.Text.Trim(), "Salt");
|
|
user.LockedOut = (chkLocked.Checked == true ? true : false);
|
|
if (user.UserID == new Guid())
|
|
new UserBI().Insert(user);
|
|
else
|
|
new UserBI().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;
|
|
}
|
|
|
|
|
|
}
|
|
}
|