private void ANM_Entry_choose_Load(object sender, EventArgs e) { try { Form_main owner = (Owner as Form_main); btn_OK.Text = owner.language.GetValue("entrySelect", "OK", "OK"); btn_Cancel.Text = owner.language.GetValue("entrySelect", "Cancel", "Cancel"); this.Text = owner.language.GetValue("entrySelect", "choose_entry", "choose entry"); StreamReader fs = new StreamReader(str_anm_desFile); string ln = fs.ReadLine(); string flag = owner.config_command.GetValue(owner.ver_thtk, "thanm_entry_flag", "Name:"); this.BackgroundImage = owner.BackgroundImage; this.Opacity = owner.Opacity; while (ln != null) { int ind = ln.IndexOf(flag); if (ind >= 0) { list_entry.Items.Add(ln.Substring(ind + flag.Length).Trim(' ')); } ln = fs.ReadLine(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "From thtk_gui", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); } }
protected void button1_Click(object sender, EventArgs e) { if (!CheckTM()) { this.ShowError(); return; } if (!CheckSL()) { this.ShowError(); return; } MySqlTransaction tr = Form_main.Connection.BeginTransaction(); string db = GetDatabaseName(); string s; try { Form_main f = this.Owner as Form_main; if (db == "rk")//区分rk与rk_temp表 { s = string.Format("update goods set kc=kc+{0} where tm='{1}'", this.textBox_sl.Text.Trim(), this.textBox_tm.Text.Trim()); command.CommandText = s; command.ExecuteNonQuery();//更新库存 } s = string.Format("insert into {0}(rq,tm,czy,sl) values('{1}','{2}','{3}',{4})", this.GetDatabaseName(), DateTime.Now.ToString(), this.textBox_tm.Text, f.worker.bh, this.textBox_sl.Text); command.CommandText = s; command.ExecuteNonQuery();//添加入库操作记录 tr.Commit(); } catch (Exception se) { tr.Rollback(); MessageBox.Show(se.Message, "出错提示"); this.ShowError(); return; } string label = string.Format("本次:【{0}】,【{1}】,【{2}】件)。", this.textBox_tm.Text.Trim(), this.textBox_pm.Text.Trim(), this.textBox_sl.Text.Trim()); this.ShowMessage(); this.textBox_tm.Clear(); this.textBox_pm.Clear(); this.textBox_jj.Clear(); this.textBox_sj.Clear(); this.textBox_sl.Text = "1"; this.textBox_tm.Select(); }
void form_mainWindow_FormClosed(object sender, FormClosedEventArgs e) { if (form_mainWindow.WndClosed) { this.Close(); } else { form_mainWindow.FormClosed -= form_mainWindow_FormClosed; form_mainWindow = null; } }
public static void Log(string LogName, string LogPassword, Form_log log) { if (ControCenter.LogIn(LogName, LogPassword)) { log.Visible = false; ControCenter.LoadObjData(); Form_main f = new Form_main(); } else { MessageBox.Show("密码错误!"); } }
private void button1_Click(object sender, EventArgs e) { if (!this.textBox_tm.ReadOnly) { MessageBox.Show("条码输入完毕后请按回车键,以便系统检索商品是否存在!"); this.textBox_tm.Select(); this.textBox_tm.SelectAll(); return; } if (!CheckSL()) { return; } if (this.textBox_pm.TextLength < 1) { return; } Form_main f = this.Owner as Form_main; string s = string.Format("update goods set kc=kc-{0} where tm='{1}'", this.textBox_sl.Text, tm); command.CommandText = s; MySqlTransaction tr = command.Connection.BeginTransaction(); try { command.ExecuteNonQuery(); s = string.Format("insert into ck(rq,tm,czy,sl,bz) values('{0}','{1}','{2}',{3},'{4}')", DateTime.Now.ToString(), tm, f.worker.bh, this.textBox_sl.Text, this.yy); command.CommandText = s; command.ExecuteNonQuery(); tr.Commit(); } catch (Exception se) { tr.Rollback(); MessageBox.Show(se.Message, "出错提示"); return; } this.tm = ""; this.textBox_tm.Clear(); this.textBox_pm.Clear(); this.textBox_jj.Clear(); this.textBox_sj.Clear(); this.textBox_sl.Clear(); this.textBox_tm.ReadOnly = false; this.textBox_tm.Select(); }
public void ShowMainWindow() { if (form_mainWindow == null || form_mainWindow.IsDisposed) { form_mainWindow = new GUI.Form_main(); form_mainWindow.Gestures = m_gestures; form_mainWindow.Engine = m_engine; form_mainWindow.SetListView(); form_mainWindow.FormClosed += this.form_mainWindow_FormClosed; form_mainWindow.Translate(); } form_mainWindow.Show(); form_mainWindow.ShowMainForm(); }
private void Form_yggl_Shown(object sender, EventArgs e) { Form_main mf = this.Owner as Form_main; if (mf.worker.qx == "高") { this.comboBox1.Items.AddRange(new string[] { "低", "中" }); } else if (mf.worker.qx == "中") { this.comboBox1.Items.AddRange(new string[] { "低" }); } this.comboBox1.SelectedIndex = 0; }
public void Start(string projectPath, Form_main mainForm) { form = new Form_Process(); form.Show(); try { Thread thread = new Thread(() => StartThread(projectPath, mainForm)); thread.Start(); } catch (Exception e) { ExceptionHandler.ShowError("创建线程", e); } }
virtual protected void button1_Click(object sender, EventArgs e) { if (!this.textBox_tm.ReadOnly) { MessageBox.Show("条码输入完毕后请按回车键,以便系统检索商品是否存在!"); this.textBox_tm.Select(); this.textBox_tm.SelectAll(); return; } if (!CheckSL()) { return; } MySqlTransaction tr = Form_main.Connection.BeginTransaction(); string db = GetDatabaseName(); string s; try { Form_main f = this.Owner as Form_main; if (db == "zp_rk")//区分rk与rk_temp表 { s = string.Format("update zp_goods set kc=kc+{0} where tm='{1}'", this.textBox_sl.Text.Trim(), this.textBox_tm.Text.Trim()); command.CommandText = s; command.ExecuteNonQuery();//更新库存 } s = string.Format("insert into {0}(rq,tm,czy,sl) values('{1}','{2}','{3}',{4})", db, DateTime.Now.ToString(), this.textBox_tm.Text, f.worker.bh, this.textBox_sl.Text); command.CommandText = s; command.ExecuteNonQuery();//添加入库操作记录 tr.Commit(); } catch (Exception se) { tr.Rollback(); MessageBox.Show(se.Message, "出错提示"); return; } this.textBox_tm.Clear(); this.textBox_pm.Clear(); this.textBox_jj.Clear(); this.textBox_sj.Clear(); this.textBox_sl.Clear(); this.textBox_tm.ReadOnly = false; this.textBox_tm.Select(); }
public void Find(string tj, string lr) { if (this.isFinded || this.dataGridView.RowCount < 1) { return; } int index = -1; foreach (DataGridViewColumn c in this.dataGridView1.Columns) { if (c.HeaderText == tj) { index = c.Index; break; } } if (index < 0) { MessageBox.Show("未查找到目标,过滤条件设置对否?"); return; } DataTable dt = this.dataGridView.DataSource as DataTable; myTable = dt; dt = myTable.Clone(); Form_main main = this.MdiParent as Form_main; for (int i = 0; i < myTable.Rows.Count; i++) { if (myTable.Rows[i][index].ToString() == lr) { DataRow dr = dt.NewRow(); dr.ItemArray = myTable.Rows[i].ItemArray; dt.Rows.Add(dr); } } if (dt.Rows.Count > 0) { this.dataGridView.DataSource = dt; this.isFinded = true; this.AddRowHeaderNumber(); this.dataGridView.ClearSelection(); main.textBox_lr.Clear(); } }
private void Form_MDIChild_Enter(object sender, EventArgs e) { Form_main main = this.MdiParent as Form_main; if (this.items.Count > 0) { main.comboBox_tj.Enabled = true; main.comboBox_tj.Items.Clear(); main.comboBox_tj.Items.AddRange(this.items.ToArray <string>()); main.comboBox_tj.SelectedIndex = 0; } else { main.comboBox_tj.Items.Clear(); main.comboBox_tj.Text = ""; } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); IRapidPassiveEngine rapidPassiveEngine = ESPlus.Rapid.RapidEngineFactory.CreatePassiveEngine(); Form_main mainForm = new Form_main(); Form_login loginForm = new Form_login(rapidPassiveEngine, mainForm); //在LoginForm中初始化客户端引擎RapidPassiveEngine if (loginForm.ShowDialog() != DialogResult.OK) { } else { mainForm.InitMain(rapidPassiveEngine); Application.Run(mainForm); } }
private void textBox1_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Return: if (this.comboBox1.SelectedIndex < 0) { MessageBox.Show("请从列表框中选择用户。"); this.textBox1.Clear(); this.comboBox1.SelectedIndex = 0; this.comboBox1.Select(); return; } if (this.textBox1.Text.Trim().Length == 6) { Worker w = comboBox1.Items[comboBox1.SelectedIndex] as Worker; if (w.mm == textBox1.Text.Trim()) { if (w.qx != "低" && w.qx != "中" && w.qx != "高") { MessageBox.Show("权限错误!请从列表框中选择用户。"); return; } Form_main f = this.Owner as Form_main; f.worker = w; this.DialogResult = DialogResult.OK; this.Close(); } } this.textBox1.SelectAll(); break; case Keys.Escape: this.DialogResult = DialogResult.Cancel; Close(); break; default: break; } }
private void button_confirm_Click(object sender, EventArgs e) { if (textBox_symbol.Text == "" || comboBox_proto.Text == "" || textBox_localPort.Text == "") { MessageBox.Show("录入参数出错,请检查录入。\r\n1、英文标识应为2-5位英文\r\n2、网络协议应在http、https、tcp中三选一\r\n3、域名应为2-5位英文\r\n4、当网络协议为tcp时,域名可以为空\r\n5、网络端口应为1-65535之间正整数", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning ); return; } Form_main mainform = (Form_main)this.Owner; mainform.listView_ngrok.BeginUpdate(); if (tunnelMode == "addNew") { ListViewItem item = mainform.listView_ngrok.Items.Add((tunnelIndex + 1).ToString()); item.SubItems.Add(textBox_symbol.Text); item.SubItems.Add(comboBox_proto.Text); item.SubItems.Add(textBox_localPort.Text); item.SubItems.Add(textBox_serverPort.Text); item.SubItems.Add(textBox_subdomain.Text); item.EnsureVisible(); mainform.textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "网络穿透隧道添加成功!" + "\r\n"); } else { if (mainform.listView_ngrok.SelectedItems.Count > 0) { mainform.listView_ngrok.SelectedItems[0].SubItems[1].Text = textBox_symbol.Text; mainform.listView_ngrok.SelectedItems[0].SubItems[2].Text = comboBox_proto.Text; mainform.listView_ngrok.SelectedItems[0].SubItems[3].Text = textBox_localPort.Text; mainform.listView_ngrok.SelectedItems[0].SubItems[4].Text = textBox_serverPort.Text; mainform.listView_ngrok.SelectedItems[0].SubItems[5].Text = textBox_subdomain.Text; mainform.textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "网络穿透隧道修改成功!" + "\r\n"); } } mainform.listView_ngrok.EndUpdate(); this.Dispose(); }
private void Form_editWorker_Load(object sender, EventArgs e) { Form_main mf = this.Owner as Form_main; if (mf.worker.qx == "高") { this.comboBox1.Items.AddRange(new string[] { "低", "中", "高" }); } else if (mf.worker.qx == "中") { this.comboBox1.Items.AddRange(new string[] { "中", "低" }); } else if (mf.worker.qx == "低") { this.comboBox1.Items.Add("低"); } this.comboBox1.SelectedIndex = 0; string s = string.Format("select xm,mm,qx,dh from worker where(bh='{0}')", mf.worker.bh); command.CommandText = s; MySqlDataReader dr = command.ExecuteReader(); if (dr.Read()) { this.textBox_bh.Text = mf.worker.bh; this.textBox_bh.ReadOnly = true; this.textBox_xm.Text = dr.GetString(0); this.textBox_mm.Text = dr.GetString(1); this.comboBox1.Text = dr.GetString(2); this.textBox_dh.Text = dr.GetString(3); } else { MessageBox.Show("未知错误!"); } dr.Close(); }
public void RefreshData() { if (this.Text == "本日时段") { return; } myTable.Clear(); Form_main.Command.CommandText = _sql; MySqlDataAdapter da = new MySqlDataAdapter(Form_main.Command); this.dataGridView.SuspendLayout(); DataTable dt = new DataTable(); da.Fill(dt); this.dataGridView.DataSource = dt; this.dataGridView.ResumeLayout(); Form_main mf = this.MdiParent as Form_main; mf.DataGridView1 = this.dataGridView; mf.SetColumnsWidth(); this.isFinded = false; }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Link_Form link = new Link_Form(); link.Show(); Application.DoEvents(); XmlDocument doc = new XmlDocument(); link.label1.Text = "正在读取配置文件 ……"; Application.DoEvents(); doc.Load(Application.StartupPath + "\\yuan.xml"); XmlNode root = doc.SelectSingleNode("config"); string s = string.Format("data source={0};user id={1};password={2};database={3}", root.SelectSingleNode("ip").InnerText, root.SelectSingleNode("user").InnerText, root.SelectSingleNode("password").InnerText, root.SelectSingleNode("database").InnerText); Form_main.xp_printer = root.SelectSingleNode("printer").InnerText; Form_main.printer = root.SelectSingleNode("tm_printer").InnerText; Form_main.shop = root.SelectSingleNode("shop").InnerText; if (Form_main.shop == null) { throw new ArgumentNullException("Form_main.shop"); } XmlNode temp = root.SelectSingleNode("/config/font/title"); Form_main.title = new Font(temp.InnerText, float.Parse(temp.Attributes["size"].Value)); temp = root.SelectSingleNode("/config/font/font"); Form_main.font = new Font(temp.InnerText, float.Parse(temp.Attributes["size"].Value)); temp = root.SelectSingleNode("/config/font/height"); Form_main.fontHeight = float.Parse(temp.InnerText); temp = root.SelectSingleNode("/config/position/x1"); Form_main.x1 = float.Parse(temp.InnerText); temp = root.SelectSingleNode("/config/position/x2"); Form_main.x2 = float.Parse(temp.InnerText); temp = root.SelectSingleNode("/config/position/x3"); Form_main.x3 = float.Parse(temp.InnerText); Form_main.windowtitle = root.SelectSingleNode("/config/shop").InnerText; Form_main.address = root.SelectSingleNode("/config/address").InnerText; link.label1.Text = "配置完毕,正在连接数据库 ……"; Application.DoEvents(); try { Form_main.Connection = new MySqlConnection(s); Form_main.Command = Form_main.Connection.CreateCommand(); Form_main.Connection.Open(); link.label1.Text = "数据库连接成功,启动主程序 ……"; Application.DoEvents(); Form mf = new Form_main(); mf.Show(); link.Close(); Application.Run(mf); } catch (MySqlException) { MessageBox.Show("连接到门店电脑数据库时错误!\r\n网络是否正常?", "连接错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } }
private void StartThread(string projectPath, Form_main mainForm) { string phase = "创建.vscode目录"; UpdateFormText(phase); try { string jsonPath = projectPath + @"\.vscode"; if (!Directory.Exists(jsonPath)) { Directory.CreateDirectory(jsonPath); } phase = "写出json文件"; UpdateFormText(phase); File.WriteAllBytes(jsonPath + "\\c_cpp_properties.json", Resource.c_cpp_properties); File.WriteAllBytes(jsonPath + "\\launch.json", Resource.launch); File.WriteAllBytes(jsonPath + "\\tasks.json", Resource.tasks); UpdateProcess(5); phase = "写出MinGW编译器文件"; UpdateFormText(phase); string szPath = Path.GetTempPath() + "\\MinGW.7z"; File.WriteAllBytes(szPath, Resource.MinGW); UpdateProcess(10); phase = "创建文件索引"; UpdateFormText(phase); SevenZipExtractor extractor = new SevenZipExtractor(szPath); string targetPath = @"C:\MinGW"; List <string> files = new List <string>(); foreach (var file in extractor.ArchiveFileData) { if (!file.IsDirectory) { if (!File.Exists(targetPath + "\\" + file.FileName)) { files.Add(file.FileName); } } } extractor.FileExtractionStarted += new EventHandler <FileInfoEventArgs>((s, e) => { UpdateProcess(10 + (int)(e.PercentDone * 0.7)); }); phase = "解压MinGW编译器文件"; UpdateFormText(phase); extractor.ExtractFiles(targetPath, files.ToArray()); if (File.Exists(Path.GetTempPath() + "\\MinGW.7z")) { File.Delete(Path.GetTempPath() + "\\MinGW.7z"); } phase = "设置环境变量"; UpdateFormText(phase); string pathVar = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User); Console.WriteLine(pathVar); if (!pathVar.Contains("C:\\MinGW\\bin")) { if (!pathVar.EndsWith(";") && pathVar != string.Empty) { pathVar += ";"; } pathVar += "C:\\MinGW\\bin;"; Environment.SetEnvironmentVariable("PATH", pathVar, EnvironmentVariableTarget.User); } UpdateProcess(90); phase = "安装Vscode C/C++插件"; UpdateFormText(phase); string strOutPut = ExecuteOutCmd("code --install-extension ms-vscode.cpptools"); if (!strOutPut.Contains("was successfully installed") && !strOutPut.Contains("is already installed")) { string tip = "未能成功安装C/C++插件" + "\n" + strOutPut + "\n可能安装VScode后未重启计算机?" + "\n该错误并不影响配置过程。您可以在启动VS code后手动安装C/C++插件"; MessageBox.Show(tip, "哎呦被玩坏了", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } UpdateProcess(100); MessageBox.Show("已完成全部操作\n[]~( ̄▽ ̄)~*" + "\n若仍然调试失败,请尝试重启VS code" + "\n如果该软件对您有帮助,欢迎点击左下角文字到B站三连~", "提示"); form.Close(); ExecuteOutCmd("code -a " + projectPath); mainForm.Visible = true; // Environment.Exit(0); } catch (Exception e) { ResetAllFiles(projectPath); ExceptionHandler.ShowError(phase, e); } }
private void 撤回此出库ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.Text != "出库明细") { return; } if (MessageBox.Show("将撤回此出库,是吗?", "提示", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } Form_main mf = this.MdiParent as Form_main; if (mf.worker.qx != "高") { return; } if (this.dataGridView.Rows.Count < 1) { return; } DataGridViewRow row = this.dataGridView.CurrentRow; if (row == null) { return; } if (row.Index < 0 || row.Index >= this.dataGridView.Rows.Count) { return; } string tm = row.Cells["条码"].Value.ToString(); string sl = row.Cells["数量"].Value.ToString(); string date = row.Cells["日期"].Value.ToString(); MySqlCommand command = Form_main.Command; MySqlConnection connection = Form_main.Connection; MySqlTransaction tr = connection.BeginTransaction(); string sql; int ret; try { sql = string.Format("delete from ck where tm='{0}' and rq='{1}'", tm, date); command.CommandText = sql; ret = command.ExecuteNonQuery(); if (ret == 0) { MessageBox.Show("删除失败,无此记录,请重新打开出库明细表!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (ret != 1) { throw new Exception("删除出错!mdichild.cs line 304."); } sql = string.Format("update goods set kc=kc+{0} where tm='{1}'", sl, tm); command.CommandText = sql; ret = command.ExecuteNonQuery(); if (ret != 1) { throw new Exception("修改库存出错!mdichild.cs line 310."); } tr.Commit(); } catch (Exception se) { MessageBox.Show(se.Message + "\r\n开始回滚!", "出错提示:", MessageBoxButtons.OK); tr.Rollback(); return; } MessageBox.Show("删除出库明细,及修改库存数据成功!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); }
private void button1_Click(object sender, EventArgs e) { if (textBox_bh.Text.Trim().Length != 7 && textBox_bh.Text.Trim().Length != 8) { MessageBox.Show("会员编号为7或8位"); textBox_bh.Select(); textBox_bh.SelectAll(); return; } if (textBox_xm.Text.Trim().Length < 2) { MessageBox.Show("姓名必须2个字以上"); textBox_xm.Select(); textBox_xm.SelectAll(); return; } string s = "select ifnull(count(*),0) from people where bh='"; s += textBox_bh.Text + "'"; command.CommandText = s; int count = int.Parse(command.ExecuteScalar().ToString()); if (count != 0) { MessageBox.Show("此会员已存在!"); textBox_bh.Select(); textBox_bh.SelectAll(); return; } if (this.textBox_sj.Text.Trim().Length != 11) { MessageBox.Show("手机号为11位"); textBox_sj.Select(); textBox_sj.SelectAll(); return; } foreach (char c in textBox_sj.Text) { if (!char.IsNumber(c)) { MessageBox.Show("手机号,输入了非数字!"); textBox_sj.Select(); textBox_sj.SelectAll(); return; } } Form_main main = this.Owner as Form_main; s = "insert into people(bh,xm,xb,dh,rq,czy) values('"; s += textBox_bh.Text.Trim() + "','"; s += textBox_xm.Text.Trim() + "','"; s += "女','"; s += textBox_sj.Text.Trim() + "','"; s += DateTime.Now.ToString() + "','"; s += main.worker.bh + "')"; command.CommandText = s; try { command.ExecuteNonQuery(); } catch { MessageBox.Show("添加新会员出错,请检查输入是否正确!"); return; } MessageBox.Show("添加新会员成功!"); this.textBox_bh.Clear(); this.textBox_xm.Clear(); this.textBox_sj.Clear(); this.textBox_bh.Select(); }
private void button1_Click(object sender, EventArgs e) { if (this.textBox_bh.TextLength != 4) { MessageBox.Show("编号为四位字符(字符或数字)"); this.textBox_bh.Select(); this.textBox_bh.SelectAll(); return; } if (this.textBox_xm.TextLength < 1) { this.textBox_xm.Select(); this.textBox_xm.SelectAll(); return; } if (this.textBox_mm.TextLength != 6) { MessageBox.Show("密码长度为6位!"); this.textBox_mm.Select(); this.textBox_mm.SelectAll(); return; } if (this.textBox_dh.TextLength < 7) { MessageBox.Show("请输入电话号码!"); this.textBox_dh.Select(); this.textBox_dh.SelectAll(); return; } if (this.comboBox1.SelectedIndex < 0) { MessageBox.Show("请从列表框选择权限"); this.comboBox1.Select(); this.comboBox1.SelectedIndex = 0; return; } if (this.comboBox1.Text != "低" && this.comboBox1.Text != "中" && this.comboBox1.Text != "高") { MessageBox.Show("检查权限设置是否正确!"); this.comboBox1.Select(); return; } string s = "select count(*) from worker where bh='" + this.textBox_bh.Text.Trim() + "'"; command.CommandText = s; int count = int.Parse(command.ExecuteScalar().ToString()); if (count == 1) { MessageBox.Show("此编号已使用,要修改该帐号资料,请先使用该帐号登录!"); this.textBox_bh.SelectAll(); return; } Form_main main = this.Owner as Form_main; s = string.Format("insert into worker(bh,xm,mm,qx,dh,rq) values('{0}','{1}','{2}','{3}','{4}','{5}')", this.textBox_bh.Text, this.textBox_xm.Text, this.textBox_mm.Text, this.comboBox1.Text, this.textBox_dh.Text, DateTime.Now.ToString()); command.CommandText = s; command.ExecuteNonQuery(); MessageBox.Show("添加新员工成功!"); this.textBox_bh.Clear(); this.textBox_xm.Clear(); this.textBox_mm.Clear(); this.textBox_dh.Clear(); this.textBox_bh.Select(); }
private void button1_Click(object sender, EventArgs e) { //检查所有文本框内容是否符合要求 if (this.textBox_bh.TextLength != 4) { MessageBox.Show("编号为四位字符(字符或数字)"); this.textBox_bh.Select(); this.textBox_bh.SelectAll(); return; } if (this.textBox_xm.TextLength < 1) { this.textBox_xm.Select(); this.textBox_xm.SelectAll(); return; } if (this.textBox_mm.TextLength != 6) { MessageBox.Show("密码长度为6位!"); this.textBox_mm.Select(); this.textBox_mm.SelectAll(); return; } if (this.textBox_dh.TextLength < 7) { MessageBox.Show("请输入电话号码!"); this.textBox_dh.Select(); this.textBox_dh.SelectAll(); return; } if (this.comboBox1.Text != "低" && this.comboBox1.Text != "中" && this.comboBox1.Text != "高") { MessageBox.Show("检查权限设置是否正确!"); this.comboBox1.Select(); return; } //要修改的是否是已登录的当前用户,并且表中存在此记录,才接受修改请求 Form_main mf = this.Owner as Form_main; if (mf.worker.bh == this.textBox_bh.Text.Trim() || mf.worker.qx == "中" || mf.worker.qx == "高") { string s; s = string.Format("update worker set xm='{0}',mm='{1}',dh='{2}',qx='{3}' where bh='{4}'", this.textBox_xm.Text, this.textBox_mm.Text, this.textBox_dh.Text, this.comboBox1.Text, this.textBox_bh.Text); command.CommandText = s; command.ExecuteNonQuery(); MessageBox.Show("修改成功!"); this.Close(); return; } else { MessageBox.Show("修改员工资料时,请先使用该员工帐号登录,或者当前操作员具有中级以上权限!"); this.textBox_bh.SelectAll(); } }