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 { /// /// CheckUserWin.xaml 的交互逻辑 /// 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 ExecReportWorkWin() { InitializeComponent(); } public ExecReportWorkWin(string workOrder, string quantity,string workOrdercode) { InitializeComponent(); this.workOrdercode = workOrdercode; this.lbCurrOrderNo.Content = workOrder; this.txtQuantity.Text = quantity; } 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; 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("没有维护成本中心,请联系管理员!", CustomMessageBoxIcon.Warning); return; } List listCostCenter = Utils.ToDataList(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("没有找到批次号,请联系管理员!", CustomMessageBoxIcon.Warning); return; } List strings =new List(); strings.Add(""); foreach (System.Data.DataRow row in dt.Rows) { strings.Add(row[0].ToString()); } List listCostCenter = Utils.ToDataList(dt); //comboDryRoomInfo.SelectedValuePath = "quipName"; //comboDryRoomInfo.DisplayMemberPath = "quipCode"; //comboDryRoomInfo.ItemsSource = listEquip; //绑定 pici.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; } } }