|
|
using CommonFunc;
|
|
|
using CommonFunc.Tools;
|
|
|
|
|
|
using HandyControl.Tools.Extension;
|
|
|
using PdfSharpCore;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Linq;
|
|
|
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.Shapes;
|
|
|
using XGL.Data;
|
|
|
using XGL.Data.DBService;
|
|
|
using XGL.Dats.DBServiceFinishProd;
|
|
|
using XGL.Models;
|
|
|
using XGL.Models.Model;
|
|
|
|
|
|
namespace XGLFinishPro.Views
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// PieceSalaryCalWin.xaml 的交互逻辑
|
|
|
/// </summary>
|
|
|
public partial class PieceSalaryCalWin : Window
|
|
|
{
|
|
|
FinishProdDBService prodDBService = new FinishProdDBService();
|
|
|
string _deviceCode = "", _productCode = "", _workOrderCode = "", _sapWorkOrderCode = "", _productName = "", _childprocessCode = "", _childprocessName = "";
|
|
|
string _LineCode = "";
|
|
|
string number = "0";
|
|
|
public PieceSalaryCalWin()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
}
|
|
|
|
|
|
public PieceSalaryCalWin(string productCode, string productName, string deviceCode, string workOrderCode, string sapWorkOrderCode)
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
_LineCode = deviceCode;
|
|
|
_deviceCode = deviceCode;
|
|
|
_productCode = productCode;
|
|
|
_productName = productName;
|
|
|
_workOrderCode = workOrderCode;
|
|
|
_sapWorkOrderCode = sapWorkOrderCode;
|
|
|
}
|
|
|
|
|
|
private void dgWorkOrderInfo_LoadingRow(object sender, DataGridRowEventArgs e)
|
|
|
{
|
|
|
e.Row.Header = (e.Row.GetIndex() + 1).ToString();
|
|
|
}
|
|
|
|
|
|
|
|
|
private void btnConfirm_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
List<ChildProcess> listDetail = new List<ChildProcess>();
|
|
|
//if (lstBoxStep.SelectedItems.Count > 0)
|
|
|
//{
|
|
|
// foreach (var item in lstBoxStep.SelectedItems)
|
|
|
// {
|
|
|
// ChildProcess childProcess = new ChildProcess();
|
|
|
|
|
|
// childProcess.childprocess_code = (item as ChildProcess).childprocess_code;
|
|
|
// childProcess.childprocess_name = (item as ChildProcess).childprocess_name;
|
|
|
// childProcess.attr1 = (item as ChildProcess).attr1;
|
|
|
// listDetail.Add(childProcess);
|
|
|
// }
|
|
|
// if (dgUserInfo1.Items.Count > 0)
|
|
|
// {
|
|
|
// //this.lstSelectedStep.Items.Clear();
|
|
|
// this.dgUserInfo1.ItemsSource = null;
|
|
|
// dgUserInfo1.ItemsSource = listDetail.OrderBy(a => a.childprocess_code);
|
|
|
// this.btnSelectStep.IsChecked = false;
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// dgUserInfo1.ItemsSource = listDetail.OrderBy(a => a.childprocess_code);
|
|
|
// this.btnSelectStep.IsChecked = false;
|
|
|
// }
|
|
|
//}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.instance.log.Error("计件薪酬选择工序时发生异常:" + ex.Message);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void lstSelectedStep_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
this.msgBox.Text = "";
|
|
|
List<ChildProcess> listDetail = new List<ChildProcess>();
|
|
|
//if (lstSelectedStep.SelectedItems.Count > 0)
|
|
|
//{
|
|
|
// _childprocessCode = (lstSelectedStep.SelectedItem as ChildProcess).childprocess_code;
|
|
|
// _childprocessName = (lstSelectedStep.SelectedItem as ChildProcess).childprocess_name;
|
|
|
//}
|
|
|
// DataTable dt = prodDBService.GetUnitPriceInfo();
|
|
|
|
|
|
this.dgUserInfo.ItemsSource = null;
|
|
|
checkedRowsCache.Clear();
|
|
|
//Utils.userList.ForEach(t => t.IsChecked = false);
|
|
|
OnWorkUserList.ForEach(t => t.IsChecked = false);
|
|
|
dataSource = OnWorkUserList;// Utils.userList;
|
|
|
List<sys_user> usernumbers = new List<sys_user>();
|
|
|
// if (dataSource.Count!=0)
|
|
|
//{
|
|
|
// string num= prodDBService.GetUsernumbereData(_workOrderCode);
|
|
|
// foreach (var item in dataSource)
|
|
|
// {
|
|
|
// sys_user usernumber = new sys_user();
|
|
|
// usernumber.user_name = item.user_name;
|
|
|
// usernumber.nick_name = item.nick_name;
|
|
|
// usernumber.number =Convert.ToInt32(num).ToString();
|
|
|
// usernumbers.Add(usernumber);
|
|
|
// }
|
|
|
//}
|
|
|
this.dgUserInfo.ItemsSource = dataSource;
|
|
|
}
|
|
|
|
|
|
private void dgUserInfo_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
// 处理选中行的事件
|
|
|
//foreach (sys_user selectedItem in e.AddedItems)
|
|
|
//{
|
|
|
// // 在这里执行你的操作,YourDataType 是你的数据类型
|
|
|
// // selectedItem 包含当前选中行的数据
|
|
|
// selectedItem.IsChecked = true;
|
|
|
// int i = dgUserInfo.Items.IndexOf(selectedItem);
|
|
|
// (dgUserInfo.Items[i] as sys_user).IsChecked = true;
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
private void CheckBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
// 阻止事件继续传播,以防止默认行为
|
|
|
e.Handled = true;
|
|
|
}
|
|
|
|
|
|
private void CheckBox_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
CheckBox CBCheck = (CheckBox)sender;
|
|
|
try
|
|
|
{
|
|
|
List<sys_user> UsersList = dgUserInfo.SelectedItems as List<sys_user>;
|
|
|
if (UsersList != null)
|
|
|
{
|
|
|
foreach (sys_user item in UsersList)
|
|
|
{
|
|
|
if (item.IsChecked == true)
|
|
|
{ item.IsChecked = false; }
|
|
|
else
|
|
|
{ item.IsChecked = true; }
|
|
|
}
|
|
|
}
|
|
|
dgUserInfo.Items.Refresh();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
//从上下班的名单中找
|
|
|
List<sys_user> OnWorkUserList = new List<sys_user>();
|
|
|
//作为选中行的缓存
|
|
|
List<sys_user> checkedRowsCache = new List<sys_user>();
|
|
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
//新增将LineCode改为SAPCode的功能;20240325
|
|
|
DataSet ds = prodDBService.GetSapCode(_deviceCode);
|
|
|
if (ds == null)
|
|
|
{
|
|
|
CustomMessageBox.Show("请维护该线体对应的SAP编码!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
return;
|
|
|
}
|
|
|
_deviceCode = ds.Tables[0].Rows[0][0].ToString();
|
|
|
this.dgUserInfo1.ItemsSource = GetStepData();
|
|
|
GetUserData();
|
|
|
GetDataFZ();
|
|
|
GetData();
|
|
|
}
|
|
|
|
|
|
private void GetUserData()
|
|
|
{
|
|
|
OnWorkUserList = prodDBService.GetOnWorkUserList(_LineCode, LoginUser.WorkDate);
|
|
|
if (OnWorkUserList == null || OnWorkUserList.Count <= 0)
|
|
|
{
|
|
|
CustomMessageBox.Show("没有找到上班的人员信息!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void GetData()
|
|
|
{
|
|
|
DataTable dt = prodDBService.GetUnitPriceData(_deviceCode, LoginUser.WorkDate);
|
|
|
if (dt == null)
|
|
|
{
|
|
|
this.dgCreatedUserInfo.ItemsSource = null;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.dgCreatedUserInfo.ItemsSource = null;
|
|
|
this.dgCreatedUserInfo.ItemsSource = dt.DefaultView;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void btnCloseWin_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
if (CustomMessageBox.Show("确定要关闭此窗口吗?", CustomMessageBoxButton.OKCancel, CustomMessageBoxIcon.Question) == CustomMessageBoxResult.Cancel)
|
|
|
return;
|
|
|
this.Close();
|
|
|
}
|
|
|
|
|
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
List<sys_user> dataSource = new List<sys_user>();
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
if (dgCreatedUserInfo.SelectedItem != null)
|
|
|
{
|
|
|
DataRowView selectedItem = dgCreatedUserInfo.SelectedItem as DataRowView;
|
|
|
var bol = prodDBService.Updateremuneration(selectedItem["workorder_code_sap"].ToString(), selectedItem["nick_name"].ToString(), selectedItem["attr1"].ToString(), selectedItem["childprocess_code"].ToString());
|
|
|
GetData();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Console.WriteLine("未选择任何项。");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void cb_selectAll_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
// 获取点击的 CheckBox
|
|
|
CheckBox checkBox = sender as CheckBox;
|
|
|
|
|
|
// 检查是否成功获取到 CheckBox
|
|
|
if (checkBox != null)
|
|
|
{
|
|
|
// 遍历 DataGrid 的所有行
|
|
|
foreach (sys_user item in dgUserInfo.ItemsSource)
|
|
|
{
|
|
|
// 设置每行的 IsChecked 属性为全选 CheckBox 的 IsChecked 属性的值
|
|
|
item.IsChecked = checkBox.IsChecked ?? false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 全选/取消全选
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void cb_all_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
CheckBox cb = sender as CheckBox;
|
|
|
bool isChecked = cb.IsChecked == true;
|
|
|
|
|
|
foreach (var item in dgUserInfo.Items)
|
|
|
{
|
|
|
sys_user curRow = item as sys_user;
|
|
|
curRow.IsChecked = isChecked;
|
|
|
if (isChecked)
|
|
|
{
|
|
|
if (!checkedRowsCache.Contains(curRow))
|
|
|
{
|
|
|
checkedRowsCache.Add(curRow);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (checkedRowsCache.Contains(curRow))
|
|
|
{
|
|
|
checkedRowsCache.Remove(curRow);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
dgUserInfo.Items.Refresh();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 全选/取消全选
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void cf_all_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
CheckBox cb = sender as CheckBox;
|
|
|
bool isChecked = cb.IsChecked == true;
|
|
|
|
|
|
foreach (var item in MainGrid.Items)
|
|
|
{
|
|
|
sys_user curRow = item as sys_user;
|
|
|
curRow.IsChecked = isChecked;
|
|
|
if (isChecked)
|
|
|
{
|
|
|
if (!checkedRowsCache.Contains(curRow))
|
|
|
{
|
|
|
checkedRowsCache.Add(curRow);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (checkedRowsCache.Contains(curRow))
|
|
|
{
|
|
|
checkedRowsCache.Remove(curRow);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MainGrid.Items.Refresh();
|
|
|
}
|
|
|
|
|
|
|
|
|
private void dgUserInfo_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
|
|
{
|
|
|
if (alluser.IsChecked == true)
|
|
|
{
|
|
|
DataGrid dataGrid = sender as DataGrid;
|
|
|
|
|
|
if (e.EditAction == DataGridEditAction.Commit)
|
|
|
{
|
|
|
var editedElement = e.EditingElement as TextBox;
|
|
|
if (editedElement != null)
|
|
|
{
|
|
|
string newValue = editedElement.Text;
|
|
|
var binding = (e.Column as DataGridBoundColumn)?.Binding as Binding;
|
|
|
if (binding != null)
|
|
|
{
|
|
|
string propertyName = binding.Path.Path;
|
|
|
|
|
|
// 延迟调用更新方法,确保编辑状态完成
|
|
|
Dispatcher.BeginInvoke(new Action(() =>
|
|
|
{
|
|
|
UpdateAllRows(propertyName, newValue);
|
|
|
}), System.Windows.Threading.DispatcherPriority.Background);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void UpdateAllRows(string propertyName, string newValue)
|
|
|
{
|
|
|
foreach (var item in dgUserInfo.Items)
|
|
|
{
|
|
|
var property = item.GetType().GetProperty(propertyName);
|
|
|
if (property != null)
|
|
|
{
|
|
|
property.SetValue(item, Convert.ChangeType(newValue, property.PropertyType));
|
|
|
}
|
|
|
}
|
|
|
dgUserInfo.Items.Refresh();
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void cb_child_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
CheckBox cb = e.Source as CheckBox;
|
|
|
bool isChecked;
|
|
|
isChecked = cb.IsChecked == true ? true : false;
|
|
|
|
|
|
|
|
|
sys_user curRow = (dgUserInfo.CurrentItem as sys_user);
|
|
|
if (isChecked)
|
|
|
{
|
|
|
//this.chkPrintBatch.IsChecked = false;
|
|
|
foreach (var item in dgUserInfo.Items)
|
|
|
{
|
|
|
// DataGridTemplateColumn templeColumn = dgUserInfo.Columns[0] as DataGridTemplateColumn;
|
|
|
// FrameworkElement fwElement = dgUserInfo.Columns[0].GetCellContent(item);
|
|
|
// CheckBox cBox = templeColumn.CellTemplate.FindName("cb_child", fwElement) as CheckBox;
|
|
|
|
|
|
// //循环的行
|
|
|
// //DataRow tempRow = (item as DataRowView).Row;
|
|
|
// cBox.IsChecked = false;
|
|
|
|
|
|
}
|
|
|
checkedRowsCache.Add(curRow);
|
|
|
cb.IsChecked = true;
|
|
|
curRow.IsChecked = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
checkedRowsCache.Remove(curRow);
|
|
|
cb.IsChecked = false;
|
|
|
curRow.IsChecked = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void cf_child_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
CheckBox cb = e.Source as CheckBox;
|
|
|
bool isChecked;
|
|
|
isChecked = cb.IsChecked == true ? true : false;
|
|
|
|
|
|
|
|
|
sys_user curRow = (MainGrid.CurrentItem as sys_user);
|
|
|
if (isChecked)
|
|
|
{
|
|
|
//this.chkPrintBatch.IsChecked = false;
|
|
|
foreach (var item in MainGrid.Items)
|
|
|
{
|
|
|
// DataGridTemplateColumn templeColumn = dgUserInfo.Columns[0] as DataGridTemplateColumn;
|
|
|
// FrameworkElement fwElement = dgUserInfo.Columns[0].GetCellContent(item);
|
|
|
// CheckBox cBox = templeColumn.CellTemplate.FindName("cb_child", fwElement) as CheckBox;
|
|
|
|
|
|
// //循环的行
|
|
|
// //DataRow tempRow = (item as DataRowView).Row;
|
|
|
// cBox.IsChecked = false;
|
|
|
|
|
|
}
|
|
|
checkedRowsCache.Add(curRow);
|
|
|
cb.IsChecked = true;
|
|
|
curRow.IsChecked = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
checkedRowsCache.Remove(curRow);
|
|
|
cb.IsChecked = false;
|
|
|
curRow.IsChecked = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private CheckBox _previousCheckBox = null;
|
|
|
private void cb_child_Click_1(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
CheckBox clickedCheckBox = sender as CheckBox;
|
|
|
if (clickedCheckBox == null)
|
|
|
return;
|
|
|
|
|
|
// 如果之前有选中的CheckBox,取消其选中状态
|
|
|
if (_previousCheckBox != null && _previousCheckBox != clickedCheckBox)
|
|
|
{
|
|
|
_previousCheckBox.IsChecked = false;
|
|
|
}
|
|
|
|
|
|
// 记录当前选中的CheckBox
|
|
|
_previousCheckBox = clickedCheckBox;
|
|
|
|
|
|
// 获取当前选中项的值
|
|
|
var selectedItem = dgUserInfo1.SelectedItem as ChildProcess; // 替换 YourDataType 为实际的数据类型
|
|
|
if (selectedItem != null)
|
|
|
{
|
|
|
_childprocessCode = selectedItem.childprocess_code;
|
|
|
_childprocessName = selectedItem.childprocess_name;
|
|
|
btnQueryUser_Click(null, null);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.instance.log.Error("计件薪酬选择工序数据时发生异常:" + ex.Message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void btnQueryUser_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
string queryP = this.txtP.Text.Trim();
|
|
|
if (string.IsNullOrEmpty(queryP))
|
|
|
{
|
|
|
this.dgUserInfo.ItemsSource = OnWorkUserList;//Utils.userList;
|
|
|
return;
|
|
|
}
|
|
|
this.dgUserInfo.ItemsSource = null;
|
|
|
var queryList = OnWorkUserList.Where(t => t.nick_name.Contains(queryP) || t.user_name.Contains(queryP));//Utils.userList.Where(t => t.nick_name.Contains(queryP) || t.user_name.Contains(queryP));
|
|
|
|
|
|
this.dgUserInfo.ItemsSource = queryList;
|
|
|
}
|
|
|
|
|
|
private void txtP_TextChanged(object sender, TextChangedEventArgs e)
|
|
|
{
|
|
|
btnQueryUser_Click(null, null);
|
|
|
GetDataFZ();
|
|
|
}
|
|
|
|
|
|
private void btnUserConfirm_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (checkedRowsCache.Count == 0)
|
|
|
{
|
|
|
CustomMessageBox.Show("请选择人员", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
return;
|
|
|
}
|
|
|
if (dgUserInfo.SelectedIndex != -1)
|
|
|
{
|
|
|
number = (dgUserInfo.SelectedItem as sys_user).number;
|
|
|
}
|
|
|
decimal dj = 0;
|
|
|
if (dgUserInfo1.SelectedItem is ChildProcess ch)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
dj = Convert.ToDecimal(ch.attr1);
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
|
|
|
}
|
|
|
}
|
|
|
if (CustomMessageBox.Show("确定要生成该工序的数据吗?", CustomMessageBoxButton.OKCancel, CustomMessageBoxIcon.Question) == CustomMessageBoxResult.Cancel)
|
|
|
return;
|
|
|
List<string> CreateUnitPriceSqlList = new List<string>();
|
|
|
//if (prodDBService.IsExistData(_workOrderCode, _childprocessCode, _deviceCode))
|
|
|
//{
|
|
|
// string delSql = prodDBService.GetDelUnitPriceData(_workOrderCode, _childprocessCode, _deviceCode);
|
|
|
// CreateUnitPriceSqlList.Add(delSql);
|
|
|
// //prodDBService.DelUnitPriceData(_workOrderCode, _childprocessCode, _deviceCode);
|
|
|
//}
|
|
|
string name = "";
|
|
|
string Gong = "";
|
|
|
string sapCode = _deviceCode;//ds.Tables[0].Rows[0][0].ToString();
|
|
|
foreach (sys_user item in checkedRowsCache)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(item.number) || item.number == "0")
|
|
|
{
|
|
|
item.number = "0";
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(item.attr2) || item.attr2 == "0")
|
|
|
{
|
|
|
item.attr2 = "0";
|
|
|
}
|
|
|
string attr3 = "";
|
|
|
if (item.user_m_type == "f")
|
|
|
{
|
|
|
attr3 = "1";
|
|
|
}
|
|
|
decimal total = 0;
|
|
|
try
|
|
|
{
|
|
|
total = dj * Convert.ToDecimal(item.number);
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
|
|
|
}
|
|
|
string sql = prodDBService.GetCreateUnitPriceInfo(item, _workOrderCode, _sapWorkOrderCode, _productCode, _productName, _childprocessCode, _childprocessName, sapCode, item.number, LoginUser.WorkDate, item.attr2, item.post, attr3,total);
|
|
|
CreateUnitPriceSqlList.Add(sql);
|
|
|
}
|
|
|
//if (!name.IsNullOrEmpty())
|
|
|
//{
|
|
|
// CustomMessageBox.Show($"当前选择的人员[{name}][>报工总数<]为空或者为0,请填写数量后再提交!!!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
// return;
|
|
|
//}
|
|
|
//if (!Gong.IsNullOrEmpty())
|
|
|
//{
|
|
|
// CustomMessageBox.Show($"当前选择的人员[{Gong}][>工时<]为空或者为0,请填写数量后再提交!!!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
// return;
|
|
|
//}
|
|
|
//之前如果已经插入了,先删除,
|
|
|
|
|
|
//暂时不更新工单状态
|
|
|
//string updateSql = prodDBService.GetUpdateUnitPriceSql(_workOrderCode);
|
|
|
//CreateUnitPriceSqlList.Add(updateSql);
|
|
|
if (prodDBService.ExecuteCreateUnitPriceSql(CreateUnitPriceSqlList))
|
|
|
{
|
|
|
GetData();
|
|
|
foreach (sys_user item in dgUserInfo.Items)
|
|
|
{
|
|
|
if (item.IsChecked == true)
|
|
|
{
|
|
|
item.IsChecked = false;
|
|
|
}
|
|
|
dgUserInfo.Items.Refresh();
|
|
|
}
|
|
|
checkedRowsCache.Clear();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
CustomMessageBox.Show("插入失败,请重试!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
CustomMessageBox.Show("插入失败:" + ex.Message, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
LogHelper.instance.log.Error("写入计件薪酬数据时发生异常:" + ex.Message);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void btnSelectStep_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
//List<ChildProcess> list = new List<ChildProcess>();
|
|
|
//DataTable dt = prodDBService.GetProductStepListInfo(_deviceCode, _productCode);
|
|
|
|
|
|
//if (dt == null)
|
|
|
//{
|
|
|
// lstBoxStep.ItemsSource = null;
|
|
|
// lstBoxStep.Items.Clear();
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
// foreach (DataRow item in dt.Rows)
|
|
|
// {
|
|
|
// list.Add(new ChildProcess()
|
|
|
// {
|
|
|
// childprocess_code = item["childprocess_code"].ToString(),
|
|
|
// childprocess_name = item["childprocess_name"].ToString(),
|
|
|
// attr1 = TrimTrailingZeros(item["attr1"].ToString())
|
|
|
// });
|
|
|
// }
|
|
|
// lstBoxStep.ItemsSource = null;
|
|
|
// lstBoxStep.Items.Clear();
|
|
|
// lstBoxStep.ItemsSource = list;//dt.DefaultView;
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
|
|
private List<ChildProcess> GetStepData()
|
|
|
{
|
|
|
List<ChildProcess> list = new List<ChildProcess>();
|
|
|
DataTable dt = prodDBService.GetProductStepListInfo(_deviceCode, _productCode);
|
|
|
|
|
|
if (dt == null)
|
|
|
{
|
|
|
CustomMessageBox.Show("请配置工序数据之后再试!!!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Question);
|
|
|
|
|
|
//lstBoxStep.ItemsSource = null;
|
|
|
//lstBoxStep.Items.Clear();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
foreach (DataRow item in dt.Rows)
|
|
|
{
|
|
|
list.Add(new ChildProcess()
|
|
|
{
|
|
|
childprocess_code = item["childprocess_code"].ToString(),
|
|
|
childprocess_name = item["childprocess_name"].ToString(),
|
|
|
attr1 = TrimTrailingZeros(item["attr1"].ToString())
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
public string TrimTrailingZeros(string input)
|
|
|
{
|
|
|
if (input.Contains('.'))
|
|
|
{
|
|
|
// 去掉末尾的0
|
|
|
input = input.TrimEnd('0');
|
|
|
|
|
|
// 如果最后一个字符是小数点,去掉小数点
|
|
|
if (input.EndsWith("."))
|
|
|
{
|
|
|
input = input.TrimEnd('.');
|
|
|
}
|
|
|
}
|
|
|
return input;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int PageIndex = 0;
|
|
|
private int PageSize = 10;
|
|
|
private int PageMax = 0;
|
|
|
userDB usdb = new userDB();
|
|
|
FormingMachineService formingMachineService = new FormingMachineService();
|
|
|
List<sys_user> users;
|
|
|
private void QueryBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
PageIndex = 0;
|
|
|
GetDataFZ();
|
|
|
}
|
|
|
|
|
|
private void GetDataFZ()
|
|
|
{
|
|
|
string type = "f";
|
|
|
|
|
|
users = usdb.GetUsers("", type, 0, 10000);
|
|
|
string queryP = this.txtP.Text.Trim();
|
|
|
if (!string.IsNullOrEmpty(queryP))
|
|
|
{
|
|
|
users = users.Where(t => t.nick_name.Contains(queryP) || t.user_name.Contains(queryP)).ToList();
|
|
|
}
|
|
|
this.MainGrid.ItemsSource = users;
|
|
|
}
|
|
|
|
|
|
|
|
|
//private void LastPage_Click(object sender, RoutedEventArgs e)
|
|
|
//{
|
|
|
// PageIndex--;
|
|
|
// if (PageIndex == 0)
|
|
|
// {
|
|
|
// this.LastPage.IsEnabled = false;
|
|
|
// }
|
|
|
// this.NextPage.IsEnabled = true;
|
|
|
// GetDataFZ();
|
|
|
//}
|
|
|
|
|
|
//private void NextPage_Click(object sender, RoutedEventArgs e)
|
|
|
//{
|
|
|
// PageIndex++;
|
|
|
// if (PageMax == PageIndex)
|
|
|
// {
|
|
|
// this.NextPage.IsEnabled = false;
|
|
|
// }
|
|
|
// this.LastPage.IsEnabled = true;
|
|
|
// GetDataFZ();
|
|
|
//}
|
|
|
|
|
|
private void AddBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
var row = dgCreatedUserInfo.SelectedItem as DataRowView;
|
|
|
if (row == null)
|
|
|
{
|
|
|
MessageBox.Show("请选择订单!");
|
|
|
return;
|
|
|
}
|
|
|
string workorder_code = row["workorder_code"].ToString();
|
|
|
//订单编码
|
|
|
string workorder_code_sap = row["workorder_code_sap"].ToString();
|
|
|
//产品编号
|
|
|
string product_code = row["product_code"].ToString();
|
|
|
//产品名称
|
|
|
string product_name = row["product_name"].ToString();
|
|
|
//线体
|
|
|
string line_code = row["line_code"].ToString();
|
|
|
string childprocess_code = row["childprocess_code"].ToString();
|
|
|
string childprocess_name = row["childprocess_name"].ToString();
|
|
|
|
|
|
//报工数量
|
|
|
string attr1 = row["attr1"].ToString();
|
|
|
if (this.MainGrid.SelectedItem is sys_user user)
|
|
|
{
|
|
|
new AuxiliaryPersonnel(user, childprocess_code, childprocess_name, workorder_code, workorder_code_sap, product_code, product_name, line_code, attr1).ShowDialog();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("请选择人员!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
public class ChildProcess
|
|
|
{
|
|
|
public string childprocess_code { get; set; }
|
|
|
public string childprocess_name { get; set; }
|
|
|
|
|
|
public string attr1 { get; set; }
|
|
|
}
|
|
|
|
|
|
public class remuneration
|
|
|
{
|
|
|
public string workorder_code_sap { get; set; }
|
|
|
public string nick_name { get; set; }
|
|
|
public DateTime create_time { get; set; }
|
|
|
|
|
|
}
|
|
|
}
|