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.

249 lines
8.4 KiB
C#

using CommonFunc.Tools;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
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 Xceed.Wpf.DataGrid;
using XGL.Data;
using XGL.Dats.DBServiceFinishProd;
namespace XGLFinishPro.Views
{
/// <summary>
/// CheckUserWin.xaml 的交互逻辑
/// </summary>
public partial class ExecReportWorkWin : Window
{
FinishProdDBService userDbWareHouse = new FinishProdDBService();
public bool loginFlag;
public string _workTime = "";
public string _useMan = "";
public string _costCenter = "";
public string _workQuntity = "";
public string workOrdercode = "";
public string batchCode = "";
public bool? _isEndReport = false;
public ExecReportWorkWin()
{
InitializeComponent();
}
public ExecReportWorkWin(string workOrder, string quantity,string workOrdercode,string batch_code)
{
InitializeComponent();
this.workOrdercode = workOrdercode;
this.lbCurrOrderNo.Content = workOrder;
this.txtQuantity.Text = quantity;
this.comboBoxBatch.Text = batch_code;
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
this.Close();
}
private void btnOK_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(this.txtQuantity.Text))
{
this.tbMsg.Content = "报工数量不能为空";
this.txtQuantity.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtWorkTime.Text))
{
this.tbMsg.Content = "工时数量不能为空";
this.txtWorkTime.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtUserCount.Text))
{
this.tbMsg.Content = "人数数量不能为空";
this.txtUserCount.Focus();
return;
}
if (string.IsNullOrEmpty(this.comboBoxCostCenter.SelectedValue.ToString()))
{
this.tbMsg.Content = "成本中心不能为空";
this.comboBoxCostCenter.Focus();
return;
}
if (!Regex.IsMatch(this.txtQuantity.Text, @"^\d+(\.\d+)?$"))
{
// 输入是一个有效的数字,包括小数
this.tbMsg.Content = "报工数量非法字符!";
this.txtQuantity.Focus();
return;
}
if (!Regex.IsMatch(this.txtWorkTime.Text, @"^\d+(\.\d+)?$"))
{
// 输入是一个有效的数字,包括小数
this.tbMsg.Content = "工时含有非法字符!";
this.txtWorkTime.Focus();
return;
}
if (!Regex.IsMatch(this.txtUserCount.Text, @"^\d+$"))
{
// 输入是一个有效的数字,包括小数
this.tbMsg.Content = "人数含有非法字符!";
this.txtUserCount.Focus();
return;
}
_useMan = this.txtUserCount.Text;
_workTime = this.txtWorkTime.Text;
_costCenter = this.comboBoxCostCenter.SelectedValue.ToString();
_workQuntity = this.txtQuantity.Text;
batchCode = this.comboBoxBatch.Text;
_isEndReport = this.xuanze9.IsChecked;
if (string.IsNullOrEmpty(batchCode))
{
CustomMessageBoxResult result = CustomMessageBox.Show("您确定要按整单报工么?最终报工:" + (_isEndReport == true ? "是" : "否"), CustomMessageBoxButton.OKCancel, CustomMessageBoxIcon.Warning);
if (result == CustomMessageBoxResult.OK)
{
this.DialogResult = true;
}
}
else
{
CustomMessageBoxResult result = CustomMessageBox.Show("您确定要按批次报工么?当前批次号:"+ batchCode + " 最终报工:" + (_isEndReport == true ? "是" : "否"), CustomMessageBoxButton.OKCancel, CustomMessageBoxIcon.Warning);
if (result == CustomMessageBoxResult.OK)
{
this.DialogResult = true;
}
}
}
private void pw_PasswordChanged(object sender, RoutedEventArgs e)
{
tbMsg.Content = "";
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
InitComBoboxData();
piciInitComBoboxData();
}
private void txtQuantity_TextChanged(object sender, TextChangedEventArgs e)
{
if (!Regex.IsMatch(this.txtQuantity.Text, @"^\d+(\.\d+)?$"))
{
// 输入是一个有效的数字,包括小数
this.tbMsg.Content = "报工数量非法字符!";
this.txtQuantity.Focus();
return;
}
else
{
this.tbMsg.Content = "";
}
}
private void txtWorkTime_TextChanged(object sender, TextChangedEventArgs e)
{
if (!Regex.IsMatch(this.txtWorkTime.Text, @"^\d+(\.\d+)?$"))
{
// 输入是一个有效的数字,包括小数
this.tbMsg.Content = "工时含有非法字符!";
this.txtWorkTime.Focus();
return;
}
else
{
this.tbMsg.Content = "";
}
}
private void txtUserCount_TextChanged(object sender, TextChangedEventArgs e)
{
if (!Regex.IsMatch(this.txtUserCount.Text, @"^\d+$"))
{
// 输入是一个有效的数字,包括小数
this.tbMsg.Content = "人数含有非法字符!";
this.txtUserCount.Focus();
return;
}
else
{
this.tbMsg.Content = "";
}
}
private void InitComBoboxData()
{
DataTable dt = userDbWareHouse.GetCostCenter();
if (dt == null)
{
CustomMessageBox.Show("没有维护成本中心,请联系管理员!",CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return;
}
List<CostCenter> listCostCenter = Utils.ToDataList<CostCenter>(dt);
//comboDryRoomInfo.SelectedValuePath = "quipName";
//comboDryRoomInfo.DisplayMemberPath = "quipCode";
//comboDryRoomInfo.ItemsSource = listEquip;
//绑定
comboBoxCostCenter.ItemsSource = listCostCenter;
comboBoxCostCenter.SelectedValuePath = "factory_code";
comboBoxCostCenter.DisplayMemberPath = "factory_name";
comboBoxCostCenter.SelectedIndex = 0;
}
private void piciInitComBoboxData()
{
DataTable dt = userDbWareHouse.piciGetCostCenter(this.workOrdercode);
if (dt == null)
{
CustomMessageBox.Show("没有找到批次号,请联系管理员!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return;
}
List<string> strings =new List<string>();
2 years ago
strings.Add("");
foreach (System.Data.DataRow row in dt.Rows)
{
strings.Add(row[0].ToString());
}
//List<CostCenter> listCostCenter = Utils.ToDataList<CostCenter>(dt);
//comboDryRoomInfo.SelectedValuePath = "quipName";
//comboDryRoomInfo.DisplayMemberPath = "quipCode";
//comboDryRoomInfo.ItemsSource = listEquip;
//绑定
comboBoxBatch.ItemsSource = strings;
}
private void comboBoxCostCenter_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
}
public class CostCenter
{
public string factory_code { get; set; }
public string factory_name { get; set; }
}
}