You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
248 lines
11 KiB
C#
248 lines
11 KiB
C#
using CommonFunc;
|
|
using CommonFunc.Tools;
|
|
using HandyControl.Tools.Extension;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Web.Services.Description;
|
|
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() };
|
|
List<useralldaka> listuserall=new List<useralldaka>();
|
|
public enum WindowID
|
|
{
|
|
frame
|
|
}
|
|
public LanJu_User()
|
|
{
|
|
InitializeComponent();
|
|
lanJu_User = this;
|
|
WindowChange(WindowID.frame);
|
|
DataTable userall = finishProdDBService.GetUserCodeServerAll();
|
|
if (userall != null)
|
|
{
|
|
foreach (DataRow row in userall.Rows)
|
|
{
|
|
string userName = row["user_name"].ToString(); // 假设列名为 user_name
|
|
string nikeName = row["nick_name"].ToString(); // 假设列名为 nick_name
|
|
useralldaka user = new useralldaka { UserName = userName ,nikeName=nikeName};
|
|
listuserall.Add(user);
|
|
}
|
|
}
|
|
}
|
|
|
|
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();
|
|
string post = dtUserInfo.Rows[0]["post_name"].ToString();
|
|
DataTable dt = finishProdDBService.GetExistAttendanceRecord(deviceCode,LoginUser.WorkDate);
|
|
if (dt != null && dt.Select($"user_id = '" + userCode + "' AND end_time IS NULL and start_addr='"+ deviceCode + "'").Length > 0)
|
|
{
|
|
//2024-06-21陈恒杰说一天只需要一次打卡
|
|
CustomMessageBox.Show("一天只能打卡一次谢谢!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Success, 1500);
|
|
txtOnWorkUserID.Text = "";
|
|
txtOnWorkUserID.Focus();
|
|
//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, post, deviceCode, LoginUser.WorkDate);
|
|
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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 20240627杨万里提出添加员工号打卡
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void txtOnWorkUsername_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.Key == Key.Enter)
|
|
{
|
|
try
|
|
{
|
|
|
|
string userID = txtOnWorkUsername.Text;//20240628杨万里说员工号打卡不需要去0
|
|
DataTable dtUserInfo = finishProdDBService.GetUserCodeServer(userID);
|
|
if (dtUserInfo == null || dtUserInfo.Rows.Count <= 0)
|
|
{
|
|
CustomMessageBox.Show("找不到该账户,请重试!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning, 1500);
|
|
txtOnWorkUsername.Text = "";
|
|
txtOnWorkUsername.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();
|
|
string post = dtUserInfo.Rows[0]["post_name"].ToString();
|
|
DataTable dt = finishProdDBService.GetExistAttendanceRecord(deviceCode,LoginUser.WorkDate);
|
|
if (dt != null && dt.Select($"user_id = '" + userCode + "' AND end_time IS NULL and start_addr='" + deviceCode + "'").Length > 0)
|
|
{
|
|
//2024-06-21陈恒杰说一天只需要一次打卡
|
|
CustomMessageBox.Show("一天只能打卡一次谢谢!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Success, 1500);
|
|
txtOnWorkUsername.Text = "";
|
|
txtOnWorkUsername.Focus();
|
|
dakaname.Content = null;
|
|
//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, post, deviceCode, LoginUser.WorkDate);
|
|
if (isSucc)
|
|
{
|
|
CustomMessageBox.Show("打卡成功,祝您工作愉快!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Success, 1500);
|
|
txtOnWorkUsername.Text = "";
|
|
txtOnWorkUsername.Focus();
|
|
dakaname.Content = null;
|
|
Record_Click(null, null);
|
|
}
|
|
else
|
|
{
|
|
CustomMessageBox.Show("打卡失败,请重试!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Error, 1500);
|
|
txtOnWorkUsername.Text = "";
|
|
dakaname.Content = null;
|
|
txtOnWorkUsername.Focus();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.instance.log.Error("上班打卡发生异常>>" + ex.Message);
|
|
CustomMessageBox.Show("上班打卡发生异常!" + ex.Message, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Error);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void txtOnWorkUsername_TextChanged(object sender, TextChangedEventArgs e)
|
|
{
|
|
if (txtOnWorkUsername.Text.Length > 4)
|
|
{
|
|
if (listuserall.Count != 0)
|
|
{
|
|
var dtUserInfo = listuserall.Find(t => t.UserName == txtOnWorkUsername.Text);
|
|
if (dtUserInfo != null)
|
|
{
|
|
dakaname.Content = dtUserInfo.nikeName;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
public class useralldaka {
|
|
|
|
public string UserName { get; set; }
|
|
public string nikeName { get; set; }
|
|
}
|
|
|
|
}
|