|
|
using CommonFunc;
|
|
|
using CommonFunc.Tools;
|
|
|
|
|
|
using HandyControl.Tools.Extension;
|
|
|
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.Dats.DBServiceFinishProd;
|
|
|
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 = "";
|
|
|
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;
|
|
|
listDetail.Add(childProcess);
|
|
|
}
|
|
|
if (lstSelectedStep.Items.Count > 0)
|
|
|
{
|
|
|
//this.lstSelectedStep.Items.Clear();
|
|
|
this.lstSelectedStep.ItemsSource = null;
|
|
|
lstSelectedStep.ItemsSource = listDetail.OrderBy(a => a.childprocess_code);
|
|
|
this.btnSelectStep.IsChecked = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
lstSelectedStep.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;
|
|
|
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.lstSelectedStep.ItemsSource = GetStepData();
|
|
|
GetUserData();
|
|
|
GetData();
|
|
|
}
|
|
|
|
|
|
private void GetUserData()
|
|
|
{
|
|
|
OnWorkUserList = prodDBService.GetOnWorkUserList(_LineCode);
|
|
|
if (OnWorkUserList == null || OnWorkUserList.Count <= 0)
|
|
|
{
|
|
|
CustomMessageBox.Show("没有找到上班的人员信息!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void GetData()
|
|
|
{
|
|
|
DataTable dt = prodDBService.GetUnitPriceData(_deviceCode);
|
|
|
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 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 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);
|
|
|
}
|
|
|
|
|
|
private void btnUserConfirm_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (CustomMessageBox.Show("确定要生成该工序的数据吗?", CustomMessageBoxButton.OKCancel, CustomMessageBoxIcon.Question) == CustomMessageBoxResult.Cancel)
|
|
|
return;
|
|
|
if (checkedRowsCache.Count == 0)
|
|
|
{
|
|
|
CustomMessageBox.Show("请选择人员", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
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 sapCode = _deviceCode;//ds.Tables[0].Rows[0][0].ToString();
|
|
|
foreach (sys_user item in checkedRowsCache)
|
|
|
{
|
|
|
string sql = prodDBService.GetCreateUnitPriceInfo(item, _workOrderCode, _sapWorkOrderCode, _productCode, _productName, _childprocessCode, _childprocessName, sapCode);
|
|
|
CreateUnitPriceSqlList.Add(sql);
|
|
|
}
|
|
|
//之前如果已经插入了,先删除,
|
|
|
|
|
|
//暂时不更新工单状态
|
|
|
//string updateSql = prodDBService.GetUpdateUnitPriceSql(_workOrderCode);
|
|
|
//CreateUnitPriceSqlList.Add(updateSql);
|
|
|
if (prodDBService.ExecuteCreateUnitPriceSql(CreateUnitPriceSqlList))
|
|
|
{
|
|
|
CustomMessageBox.Show("插入成功!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
|
|
|
GetData();
|
|
|
foreach (sys_user item in dgUserInfo.Items)
|
|
|
{
|
|
|
if (item.IsChecked == true)
|
|
|
{
|
|
|
item.IsChecked = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
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()
|
|
|
});
|
|
|
}
|
|
|
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()
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
}
|
|
|
public class ChildProcess
|
|
|
{
|
|
|
public string childprocess_code { get; set; }
|
|
|
public string childprocess_name { get; set; }
|
|
|
}
|
|
|
}
|