using DevExpress.DocumentView.Native;
|
using DevExpress.Mvvm.POCO;
|
using Furion.LinqBuilder;
|
using System.Text.RegularExpressions;
|
using Yw.Entity;
|
|
namespace HStation.WinFrmUI.Organize
|
{
|
public partial class EmloyeeInfoCtrl : UserControl
|
{
|
/// <summary>
|
/// /
|
/// </summary>
|
public EmloyeeInfoCtrl()
|
{
|
InitializeComponent();
|
|
|
}
|
HStation.BLL.EmployeeMain _service;
|
HStation.Vmo.EmployeeMain _employee;
|
int staffstatus;
|
public void ShowBangDingData(HStation.Vmo.EmployeeMain employee)//展示本控件数据
|
{
|
//HStation.WinFrmUI.Organize.EmployeeViewModel _employee = new HStation.WinFrmUI.Organize.EmployeeViewModel(employee);
|
NametextEdit.Text = employee.FirstName;//姓名
|
textEditBianHao.Text = employee.ErpCode;//编号
|
ZhiWutextEdit.Text = employee.PositonName;//职务
|
DianHuatextEdit.Text = employee.Telephone;//电话
|
textEditQianMing.Text = employee.DrawSignal;//签名
|
YouXiangtextEdit.Text = employee.Email;//邮箱
|
ChongZhiimageComboBoxEdit.SelectedIndex = employee.RequirePasswordReset;
|
if (employee.StaffStatus == Vmo.eJobType.exist)
|
{
|
ZhuangTaiimageComboBoxEdit.SelectedIndex = 1;
|
}
|
else
|
{
|
ZhuangTaiimageComboBoxEdit.SelectedIndex = 0;
|
}
|
EnglishNametextEdit.Text = employee.LastName;//姓名 英文
|
}
|
|
public HStation.Vmo.EmployeeMain ReadCtrlData(out string error)//传入本控件数据
|
{
|
error = "";
|
HStation.Vmo.EmployeeMain employee = new Vmo.EmployeeMain();
|
employee = _employee;
|
dxValidationProviderBianHao.Validate();
|
if (String.IsNullOrEmpty(NametextEdit.Text) || String.IsNullOrEmpty(textEditBianHao.Text) )
|
{
|
error = "姓名或编号未填写!";
|
return null;
|
}
|
if (!String.IsNullOrEmpty(DianHuatextEdit.Text))
|
{
|
if (DianHuatextEdit.Text.Length != 11)
|
{
|
error = "请输入正确电话号码!";
|
return null;
|
}
|
foreach (char _Telephone in DianHuatextEdit.Text)
|
{
|
if (_Telephone < '0' && _Telephone > '9')
|
{
|
error = "请输入正确电话号码!";
|
return null;
|
}
|
}
|
}
|
|
if (!Regex.IsMatch(YouXiangtextEdit.Text, @"^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$") && !String.IsNullOrEmpty(YouXiangtextEdit.Text))
|
{
|
error = "请输入正确的邮箱!";
|
return null;
|
}
|
employee.LastModifyTime = DateTime.Now.ToString();
|
employee.FirstName = NametextEdit.Text;
|
employee.ErpCode = textEditBianHao.Text;
|
employee.PositonName = ZhiWutextEdit.Text;
|
employee.Telephone = DianHuatextEdit.Text;
|
employee.DrawSignal = textEditQianMing.Text;
|
employee.Email = YouXiangtextEdit.Text;
|
employee.RequirePasswordReset = ChongZhiimageComboBoxEdit.SelectedIndex;
|
if (ZhuangTaiimageComboBoxEdit.SelectedIndex == 1)
|
{
|
employee.StaffStatus = Vmo.eJobType.exist;
|
}else
|
{
|
employee.StaffStatus = Vmo.eJobType.leave;
|
}
|
employee.LastName = EnglishNametextEdit.Text;
|
return employee;
|
}
|
|
|
|
public HStation.Vmo.EmployeeMain SetBindingData(HStation.Vmo.EmployeeMain employee, out string error)
|
{
|
error = "";
|
|
this._employee = employee;
|
if (_employee.EmployeeID == 0)
|
{
|
//_employee.AddTime = DateTime.Now;
|
//_employee.LastModifyTime = DateTime.Now.ToString();
|
_employee = ReadCtrlData(out error);
|
employee.AddTime = DateTime.Now;
|
if (!string.IsNullOrEmpty(error))
|
{
|
return null;
|
}
|
if (!checkEditCreateLogin.Checked)//判断是否新建用户
|
{
|
return _employee;
|
}
|
else
|
{
|
if (loginUserInfoCtrl.NewBindingData(_employee.User, out error) == null)//出现错误并返回null和错误
|
{
|
return null;
|
}
|
}
|
return _employee;
|
}
|
else
|
{
|
_employee = ReadCtrlData(out error);
|
if (_employee.EmployeeID == 0)//出现错误并返回null和错误
|
{
|
error = "出现错误!ID为0!";
|
return null;
|
}
|
if (!string.IsNullOrEmpty(error))
|
{
|
return null;
|
}
|
if (!checkEditCreateLogin.Checked)//判断是否新建用户
|
{
|
return _employee;
|
}
|
else
|
{
|
if (loginUserInfoCtrl.NewBindingData(_employee.User, out error) == null)//出现错误并返回null和错误
|
{
|
return null;
|
}
|
}
|
return _employee;
|
}
|
|
|
|
}
|
|
|
public void GetBindingData(HStation.Vmo.EmployeeMain employee, out string error)//修改时展示原信息
|
{
|
error = "";
|
if (employee == null)
|
{
|
error = "入参为空!";
|
return;
|
}
|
ShowBangDingData(employee);
|
if (employee.User != null)
|
{
|
loginUserInfoCtrl.SetNoInput();
|
checkEditCreateLogin.Visible = false;
|
}
|
}
|
|
|
//只读
|
public void SetOnlyRead(HStation.Vmo.EmployeeMain employee, out string error)
|
{
|
error = "";
|
if (employee == null)
|
{
|
error = "入参为空!";
|
return;
|
}
|
ShowBangDingData(employee);
|
}
|
|
private void TouXiangpictureEdit_Click(object sender, EventArgs e)
|
{
|
if (QianMingopenFileDialog.ShowDialog() != DialogResult.OK)
|
{
|
return;
|
}
|
string QianMingfilePath = QianMingopenFileDialog.FileName;
|
if (QianMingfilePath == null)
|
{
|
return;
|
}
|
TouXiangpictureEdit.Image = Image.FromFile(QianMingfilePath);
|
}
|
|
private void checkEditCreateLogin_CheckedChanged(object sender, EventArgs e)//按钮状态发生改变时
|
{
|
if (checkEditCreateLogin.Checked)
|
{
|
loginUserInfoCtrl.SetOffInput();
|
}
|
else
|
{
|
loginUserInfoCtrl.SetNoInput();
|
}
|
}
|
}
|
}
|