diff --git a/shangjian/CommonFunc/Tools/MachineRepairWin.xaml.cs b/shangjian/CommonFunc/Tools/MachineRepairWin.xaml.cs index e64cdb7..29512e0 100644 --- a/shangjian/CommonFunc/Tools/MachineRepairWin.xaml.cs +++ b/shangjian/CommonFunc/Tools/MachineRepairWin.xaml.cs @@ -116,12 +116,12 @@ namespace CommonFunc.Tools if (result.code == 200) { LogHelper.instance.log.Info($"报修成功>>" + result.msg); - CustomMessageBox.Show($"调用报修接口成功", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); + CustomMessageBox.Show($"报修成功", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); } else { LogHelper.instance.log.Error($"报修失败>>" + result.msg); - CustomMessageBox.Show($"调用报修接口失败:" + result.msg, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); + CustomMessageBox.Show($"报修失败:" + result.msg, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); } } catch (Exception ex) diff --git a/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs b/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs index fcb7cad..5e19593 100644 --- a/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs +++ b/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs @@ -119,8 +119,20 @@ namespace XGL.Dats.DBServiceFinishProd public bool UpdateAttendanceRecord(string userID, string deviceCode) { - string sql = $@" UPDATE mes_attendance_records set end_time = GETDATE(),end_addr = '{deviceCode}',work_hours = Convert(DECIMAL(12,2),DATEDIFF((MINUTE), start_time, GetDate()) / 60.00) - where user_id = '{userID}' and start_addr = '{deviceCode}' "; + string sql = $@" +UPDATE mes_attendance_records +SET end_time = GETDATE(), + end_addr = '{deviceCode}', + work_hours = CONVERT(DECIMAL(12,2), DATEDIFF(MINUTE, start_time, GETDATE()) / 60.00) +WHERE user_id = '{userID}' + AND start_addr = '{deviceCode}' + AND start_time = ( + SELECT MAX(start_time) + FROM mes_attendance_records + WHERE user_id = '{userID}' + AND start_addr = '{deviceCode}' + )"; + int ret = Utils.netClientDBHelper.executeUpdate(sql); return ret > 0 ? true : false; } @@ -130,7 +142,7 @@ namespace XGL.Dats.DBServiceFinishProd string sql = $@" select id, user_id, user_name, attendance_status, sex, age, id_number, start_time, start_addr, end_time, end_addr, attendance_time, attendance_date, work_hours, create_time,Convert(DECIMAL(12,2),DATEDIFF((MINUTE), start_time, GetDate()) / 60.00) as diff - from mes_attendance_records where start_addr = '{v}' and attendance_date = CONVERT(VARCHAR(10), GetDate() , 120)"; + from mes_attendance_records where start_addr = '{v}' and attendance_date = CONVERT(VARCHAR(10), GetDate() , 120) order by create_time desc"; DataSet dtset = Utils.netClientDBHelper.getDataSet(sql); if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0) { diff --git a/shangjian/XGL/App.config b/shangjian/XGL/App.config index 0f4164b..361d988 100644 --- a/shangjian/XGL/App.config +++ b/shangjian/XGL/App.config @@ -12,7 +12,7 @@ - + diff --git a/shangjian/XGLFinishPro/Views/LanJu_NowUser.xaml b/shangjian/XGLFinishPro/Views/LanJu_NowUser.xaml index f7731ea..ad1e162 100644 --- a/shangjian/XGLFinishPro/Views/LanJu_NowUser.xaml +++ b/shangjian/XGLFinishPro/Views/LanJu_NowUser.xaml @@ -70,7 +70,7 @@ - + diff --git a/shangjian/XGLFinishPro/Views/LanJu_NowUser.xaml.cs b/shangjian/XGLFinishPro/Views/LanJu_NowUser.xaml.cs index 4fb6ddd..bb3266c 100644 --- a/shangjian/XGLFinishPro/Views/LanJu_NowUser.xaml.cs +++ b/shangjian/XGLFinishPro/Views/LanJu_NowUser.xaml.cs @@ -42,15 +42,41 @@ namespace XGLFinishPro.Views private void GetRecordInfo() { - DataTable dt = userDbWareHouse.GetAttendanceRecord(deviceCode); - if (dt == null) + try { - dgUserInfo.ItemsSource = null; + DataTable dt = userDbWareHouse.GetAttendanceRecord(deviceCode); + if (dt == null) + { + dgUserInfo.ItemsSource = null; + } + else + { + // 添加一个新的列来表示上班/下班状态 + dt.Columns.Add("Status", typeof(string)); + + // 遍历每一行,并根据 endTime 的值设置状态 + foreach (DataRow row in dt.Rows) + { + if (row["end_time"] != DBNull.Value && !string.IsNullOrEmpty(row["end_time"].ToString())) + { + row["Status"] = "下班"; + } + else + { + row["Status"] = "上班"; + } + } + + dgUserInfo.ItemsSource = dt.DefaultView; + } } - else + catch (Exception ex) { - dgUserInfo.ItemsSource = dt.DefaultView; + + } + + } } } diff --git a/shangjian/XGLFinishPro/Views/LanJu_User.xaml b/shangjian/XGLFinishPro/Views/LanJu_User.xaml index bf58e73..aaf9930 100644 --- a/shangjian/XGLFinishPro/Views/LanJu_User.xaml +++ b/shangjian/XGLFinishPro/Views/LanJu_User.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:XGLFinishPro.Views" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" HorizontalAlignment="Stretch" - VerticalAlignment="Stretch" + VerticalAlignment="Stretch" Loaded="UserControl_Loaded" mc:Ignorable="d">