|
|
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_NowUser() };
|
|
|
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;
|
|
|
DataTable dt = finishProdDBService.GetExistAttendanceRecord(deviceCode);
|
|
|
|
|
|
if (dt != null && dt.Select("user_id = '" + userID + "'").Length > 0)
|
|
|
{
|
|
|
CustomMessageBox.Show("您已经上班打卡成功,请勿再次打卡!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
return;
|
|
|
}
|
|
|
DataTable dtUserInfo = finishProdDBService.GetUserInfoFromCloudServer(userID);
|
|
|
if (dtUserInfo == null || dtUserInfo.Rows.Count <= 0)
|
|
|
{
|
|
|
CustomMessageBox.Show("找不到该账户,请重试!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
return;
|
|
|
}
|
|
|
string userName = dtUserInfo.Rows[0]["nick_name"].ToString();
|
|
|
string sex = dtUserInfo.Rows[0]["sex"].ToString();
|
|
|
bool isSucc = finishProdDBService.InsertAttendanceRecord(userID, userName, sex,deviceCode);
|
|
|
if (isSucc)
|
|
|
{
|
|
|
CustomMessageBox.Show("打卡成功,祝您工作愉快!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
txtOnWorkUserID.Text = "";
|
|
|
txtOnWorkUserID.Focus();
|
|
|
Now_Click(null, null);
|
|
|
}
|
|
|
else {
|
|
|
CustomMessageBox.Show("打卡失败,请重试!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.instance.log.Error("上班打卡发生异常>>" + ex.Message);
|
|
|
CustomMessageBox.Show("上班打卡发生异常!" + ex.Message, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Error);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void txtOffWorkUserID_KeyDown(object sender, KeyEventArgs e)
|
|
|
{
|
|
|
if (e.Key == Key.Enter)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string userID = txtOffWorkUserID.Text;
|
|
|
DataTable dt = finishProdDBService.GetExistAttendanceRecord(deviceCode);
|
|
|
if (dt!=null && dt.Select("user_id = '" + userID + "'").Length > 0)
|
|
|
{
|
|
|
if (dt.Select("user_id = '" + userID + "' and start_addr = '" + deviceCode + "'").Length > 0)
|
|
|
{
|
|
|
bool isSucc = finishProdDBService.UpdateAttendanceRecord(userID, deviceCode);
|
|
|
if (isSucc)
|
|
|
{
|
|
|
CustomMessageBox.Show("打卡成功,再见!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
Now_Click(null, null);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
string start_addr = dt.Select("user_id = '" + userID + "'")[0]["start_addr"].ToString();
|
|
|
CustomMessageBox.Show("打卡失败,您的打卡地址在" + start_addr + "!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.instance.log.Error("下班打卡发生异常>>" + ex.Message);
|
|
|
CustomMessageBox.Show("下班打卡发生异常!" + ex.Message, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Error);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|