using System.Drawing; using System.Data; using System.Windows.Forms; using UAS_MES_NEW.Entity; using UAS_MES_NEW.PublicMethod; using UAS_MES_NEW.PublicForm; namespace UAS_MES_NEW.CustomControl.TextBoxWithIcon { public partial class SnCollectionBox : EnterTextBox { public SnCollectionBox() { InitializeComponent(); } public override string Text { get { if (SystemInf.UpperCollection && !base.Text.Contains("CHANGEUSER:")) return base.Text.ToUpper(); else return base.Text; } set { base.Text = value; } } private void SnCollectionBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (this.FindForm().Tag.ToString() == "Make!Make_RepairBookLabelPrint" || this.FindForm().Tag.ToString() == "Make.Make_ColorBoxLoadPrintSH" || this.FindForm().Tag.ToString() == "Make!ColorBoxWeigh" || this.FindForm().Tag.ToString() == "Make!TestCollection" || this.FindForm().Tag.ToString() == "Make!ColorBoxLabelPrint" || this.FindForm().Tag.ToString() == "Make!SNLabelCheckSH" || this.FindForm().Tag.ToString() == "Make!SNLabelCheckBXK" || this.FindForm().Tag.ToString() == "Make!SNLabelCheckColorBox" || this.FindForm().Tag.ToString() == "Make!SNLabelCheckMidBox" || this.FindForm().Tag.ToString() == "Packing!ProdWeightSetMidBox" || this.FindForm().Tag.ToString() == "Make!FeedingCollection" || this.FindForm().Tag.ToString() == "Make!SNLabelCheckDark" || this.FindForm().Tag.ToString() == "Make_ColorBoxLabelPrintMidBox" || this.FindForm().Tag.ToString() == "Make!Repair") { DataTable dt = (DataTable)SystemInf.dh.ExecuteSql("select nvl(pr_alllength,0)pr_alllength,pr_suffix,pr_prefix,nvl(pr_length,0)pr_length from product where " + "pr_code ='" + Str + "'", "select"); if (dt.Rows.Count > 0) { string pr_prefix = dt.Rows[0]["pr_prefix"].ToString(); string pr_suffix = dt.Rows[0]["pr_suffix"].ToString(); int pr_length; int pr_alllength; if (int.TryParse(dt.Rows[0]["pr_length"].ToString(), out pr_length) && int.TryParse(dt.Rows[0]["pr_alllength"].ToString(), out pr_alllength)) { if (pr_alllength > 0) { if (pr_alllength == Text.Length) { } } if (pr_length > 0) { if (Text.StartsWith(pr_prefix) && Text.EndsWith(pr_suffix)) { Text = Text.Replace(pr_prefix, ""); if (!(Text.Length >= pr_length)) { Text = Text.Substring(0, pr_length); } } } } } } this.SelectAll(); //切换账号功能 if (Text.Contains("CHANGEUSER:")) { string UserCode = Text.Replace("CHANGEUSER:", "").Split('|')[0]; string Password = Text.Replace("CHANGEUSER:", "").Split('|')[1]; string oErr = ""; if (!LogicHandler.CheckUserLogin(UserCode, Password, out oErr)) { SetUserChange set = new SetUserChange(oErr, Color.Red); BaseUtil.SetFormCenter(set); set.ShowDialog(); ; return; } if (!LogicHandler.CheckUserAndResourcePassed(UserCode, User.UserSourceCode, out oErr)) { SetUserChange set = new SetUserChange(oErr, Color.Red); BaseUtil.SetFormCenter(set); set.ShowDialog(); ; return; } string[] field = { "em_code,em_depart,em_type,em_name,em_position,em_professname,em_type,ug_code,ug_name" }; DataTable UserInf = SystemInf.dh.getFieldsDataByCondition("Employee left join cs$userresource on ur_emcode=em_code left join cs$usergroup on ug_code=ur_groupcode", field, "upper(em_code)='" + UserCode.ToUpper() + "' or em_mobile='" + UserCode + "'"); //通过Source表关联岗位资源编号查询出当前的执行工序 User.UserCode = UserInf.Rows[0]["em_code"].ToString(); User.UserName = UserInf.Rows[0]["em_name"].ToString(); Control ctl = BaseUtil.GetControl(this, "Main"); if (ctl != null) { Main Main = (Main)ctl; Main.Inf_username_label.Caption = "姓名 : " + User.UserName; SetUserChange set = new SetUserChange("切换人员:" + User.UserName, Color.Green); BaseUtil.SetFormCenter(set); set.ShowDialog(); } Clear(); return; } } } } }