|
|
|
|
|
using CommonFunc;
|
|
|
|
|
|
using CommonFunc.Tools;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
|
using XGL.Dats.DBServiceFinishProd;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XGLFinishPro.Views
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// LanJu_User.xaml 的交互逻辑
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public partial class LanJu_User : UserControl
|
|
|
|
|
|
{
|
|
|
|
|
|
FinishProdDBService finishProdDBService = new FinishProdDBService();
|
|
|
|
|
|
string deviceCode = Utils.GetAppSetting("DeviceCode");
|
|
|
|
|
|
public static LanJu_User lanJu_User;
|
|
|
|
|
|
Frame frame = new Frame() { Content = new Views.LanJu_UserRecord() };
|
|
|
|
|
|
public enum WindowID
|
|
|
|
|
|
{
|
|
|
|
|
|
frame
|
|
|
|
|
|
}
|
|
|
|
|
|
public LanJu_User()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
lanJu_User = this;
|
|
|
|
|
|
WindowChange(WindowID.frame);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void WindowChange(WindowID windowID)
|
|
|
|
|
|
{
|
|
|
|
|
|
Window3.Content = frame;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Now_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
LanJu_NowUser lanJu_NowUser = new LanJu_NowUser();
|
|
|
|
|
|
Window3.Content = new Frame()
|
|
|
|
|
|
{
|
|
|
|
|
|
Content = lanJu_NowUser
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Record_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
LanJu_UserRecord lanJu_UserRecord = new LanJu_UserRecord();
|
|
|
|
|
|
Window3.Content = new Frame()
|
|
|
|
|
|
{
|
|
|
|
|
|
Content = lanJu_UserRecord
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
private void txtOnWorkUserID_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.Key == Key.Enter)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
string userID = txtOnWorkUserID.Text;
|
|
|
|
|
|
userID = userID.TrimStart('0');
|
|
|
|
|
|
DataTable dtUserInfo = finishProdDBService.GetUserInfoFromCloudServer(userID);
|
|
|
|
|
|
if (dtUserInfo == null || dtUserInfo.Rows.Count <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
CustomMessageBox.Show("找不到该账户,请重试!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning,1500);
|
|
|
|
|
|
txtOnWorkUserID.Text = "";
|
|
|
|
|
|
txtOnWorkUserID.Focus();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
string userCode = dtUserInfo.Rows[0]["user_name"].ToString();
|
|
|
|
|
|
string userName = dtUserInfo.Rows[0]["nick_name"].ToString();
|
|
|
|
|
|
string sex = dtUserInfo.Rows[0]["sex"].ToString();
|
|
|
|
|
|
DataTable dt = finishProdDBService.GetExistAttendanceRecord(deviceCode);
|
|
|
|
|
|
if (dt != null && dt.Select("user_id = '" + userCode + "' AND end_time IS NULL").Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
//2024-06-21陈恒杰说一天只需要一次打卡
|
|
|
|
|
|
CustomMessageBox.Show("一天只能打卡一次谢谢!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Success, 1500);
|
|
|
|
|
|
//bool isSucc = finishProdDBService.UpdateAttendanceRecord(userCode, deviceCode);
|
|
|
|
|
|
//if (isSucc)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// CustomMessageBox.Show("打卡成功,再见!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Success,1500);
|
|
|
|
|
|
// Record_Click(null, null);
|
|
|
|
|
|
// txtOnWorkUserID.Text = "";
|
|
|
|
|
|
// txtOnWorkUserID.Focus();
|
|
|
|
|
|
// return;
|
|
|
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
bool isSucc = finishProdDBService.InsertAttendanceRecord(userCode, userName, sex, deviceCode);
|
|
|
|
|
|
if (isSucc)
|
|
|
|
|
|
{
|
|
|
|
|
|
CustomMessageBox.Show("打卡成功,祝您工作愉快!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Success,1500);
|
|
|
|
|
|
txtOnWorkUserID.Text = "";
|
|
|
|
|
|
txtOnWorkUserID.Focus();
|
|
|
|
|
|
Record_Click(null, null);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
CustomMessageBox.Show("打卡失败,请重试!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Error,1500);
|
|
|
|
|
|
txtOnWorkUserID.Text = "";
|
|
|
|
|
|
txtOnWorkUserID.Focus();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
LogHelper.instance.log.Error("上班打卡发生异常>>" + ex.Message);
|
|
|
|
|
|
CustomMessageBox.Show("上班打卡发生异常!" + ex.Message, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Error);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
txtOnWorkUserID.Focus();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|