private void tsbResetPass_Click(object sender, EventArgs e) { //Confirm if (Dlg.ShowConfirmInfo("确认要重置密码吗?") == DialogResult.No) { return; } if (dgvRY.SelectedRows.Count < 1) { Dlg.ShowErrorInfoAndHelp("请先选择要重置的用户"); return; } int gh = Convert.ToInt32(dgvRY.SelectedRows[0].Cells["ColGH"].Value); using (FrmInput mForm = new FrmInput()) { if (mForm.ShowDialog() == DialogResult.OK) { string strPass = mForm.txtInput.Text.Trim(); strPass = MD5.Md5Encrypt(strPass); string mSql = string.Format("update ptry set mm='{0}' where gh='{1}'", strPass, gh); int ret = SqlHelper.ExecuteNonQuery(mSql); if (ret > 0) { Dlg.ShowOKInfo("重置成功!"); } else { Dlg.ShowErrorInfo("重置失败!"); } } } }
private void tsbRYDel_Click(object sender, EventArgs e) { if (dgvRY.SelectedRows.Count == 0) { return; } string loginName = dgvRY.SelectedRows[0].Cells[ColLoginName.Index].Value.ToString(); if (loginName == "admin") { Dlg.ShowErrorInfoAndHelp("admin不能进行删除!"); return; } //Confirm if (Dlg.ShowConfirmInfo("确认要删除该用户吗?") == DialogResult.No) { return; } long id = Convert.ToInt64(dgvRY.SelectedRows[0].Cells[ColID.Index].Value); string mSql = string.Format("delete from t_users where id='{0}'", id); int ret = SqlHelper.ExecuteNonQuery(mSql); if (ret > 0) { InitRY(); } }
private void toolStripButton4_Click(object sender, EventArgs e) { if (tvRYZ.SelectedNode == null) { Dlg.ShowErrorInfoAndHelp("请选择用户的角色以分配权限!"); return; } if (tvRYZ.SelectedNode.Text == "管理员") { Dlg.ShowErrorInfoAndHelp("管理员角色不允许修改权限!"); return; } int ryzbh = Convert.ToInt32(tvRYZ.SelectedNode.Tag); List <string> mSqls = new List <string>(); mSqls.Add(string.Format("delete from ptzqx where ryzbh={0} and MKBH in (select MKBH from PTcd where MKBH <> '0000' and (cardtype in (-1,-2) or cardtype ={1}))", ryzbh, CommonClass.SttIC.iCardType)); foreach (TreeNode tn in tvRight.Nodes) { AddSqlStr(ref mSqls, tn, ryzbh); } int ret = SqlHelper.ExecuteSqls(mSqls.ToArray()); if (ret == 0) { Dlg.ShowOKInfo("保存成功"); return; } else { Dlg.ShowErrorInfo("保存失败"); return; } }
private void tsbModify_Click(object sender, EventArgs e) { if (tvRYZ.SelectedNode == null) { Dlg.ShowErrorInfo("未选择要修改的角色!"); return; } if (tvRYZ.SelectedNode.Text == "管理员") { Dlg.ShowErrorInfo("管理员角色不允许修改!"); return; } using (FrmInput mForm = new FrmInput()) { mForm.txtInput.Text = tvRYZ.SelectedNode.Text; int zbh = Convert.ToInt32(tvRYZ.SelectedNode.Tag); if (mForm.ShowDialog() == DialogResult.OK) { string sSql = string.Format("select count(*) from ptryz where zmc='{0}'", mForm.txtInput.Text.Trim()); int iRet = (int)SqlHelper.ExecuteScalar(sSql); if (iRet == -1) { return; } if (iRet != 0) { Dlg.ShowErrorInfoAndHelp(string.Format("输入的新角色名称“{0}”已存在,不能修改!", mForm.txtInput.Text.Trim())); return; } sSql = string.Format("update ptryz set zmc='{0}' where zbh={1}", mForm.txtInput.Text.Trim(), zbh); int ret = SqlHelper.ExecuteNonQuery(sSql); InitRYZ(); } } }
private void tsbRYSave_Click(object sender, EventArgs e) { if ((dgvRY.SelectedRows.Count < 1) || (txtID.Text == "")) { Dlg.ShowErrorInfoAndHelp("请先选择要保存的用户"); return; } if (txtLoginName.Text.Trim() == string.Empty) { toolTip1.Show("登录名不能为空", txtLoginName, 0, txtLoginName.Height, 2000); return; } if (txtUserName.Text.Trim() == string.Empty) { toolTip1.Show("姓名不能为空", txtUserName, 0, txtUserName.Height, 2000); return; } ry ry = new ry(); ry.ID = Convert.ToInt64(txtID.Text); ry.LoginName = txtLoginName.Text; ry.UserName = txtUserName.Text.Trim(); ry.AreaCode = txtAreaCode.Text.Trim(); ry.IntDepartmentID = Convert.ToInt32(cmbDepart.SelectedValue); ry.IntRoleID = Convert.ToInt32(cmbRole.SelectedValue); ry.DepartmentName = cmbDepart.Text.Trim(); //部门名称 ry.OperRight = cmbRole.Text.Trim(); //权限名称 int ret = Convert.ToInt32(SqlHelper.ExecuteScalar(string.Format("select count(1) from t_users where loginName='{0}' and id <> {1}", ry.LoginName, ry.ID))); if (ret > 0) { toolTip1.Show("该登陆名已存在,请重新输入", txtLoginName, 0, txtLoginName.Height, 2000); txtLoginName.Focus(); return; } if ((ry.LoginName.ToLower() == "admin")) { Dlg.ShowErrorInfoAndHelp("员工admin不允许修改!"); return; } //string mSql = string.Format("update t_users set loginName='{0}',UserName='******',userChar='{2}',intdepartmentID='{3}',IntRoleID={4} where id='{5}'", ry.LoginName, ry.UserName, ry.AreaCode,ry.IntDepartmentID,ry.IntRoleID,ry.ID); //添加部门名称和权限名称字段 string mSql = string.Format("update t_users set loginName='{0}',UserName='******',userChar='{2}',intdepartmentID='{3}',IntRoleID={4},DepartmentName='{6}',OperRight='{7}' where id='{5}'", ry.LoginName, ry.UserName, ry.AreaCode, ry.IntDepartmentID, ry.IntRoleID, ry.ID, ry.DepartmentName, ry.OperRight); ret = SqlHelper.ExecuteNonQuery(mSql); if (ret > 0) { InitRY(); SelectRow(ry.ID); Dlg.ShowOKInfo("修改成功!"); } }
private void toolStripButton3_Click(object sender, EventArgs e) { if (Dlg.ShowConfirmInfo("确认要删除该模块吗?") == DialogResult.Yes) { string MKBH; if (tvRight.SelectedNode == null) { Dlg.ShowErrorInfoAndHelp("请选择要删除的模块!"); return; } MKBH = ((ModuleList)tvRight.SelectedNode.Tag).MKBH; List <string> mSqls = new List <string>(); string mSql = string.Format("delete from ptcd where mkbh='{0}'", MKBH); mSqls.Add(mSql); mSql = string.Format("delete from ptzqx where mkbh='{0}'", MKBH); mSqls.Add(mSql); int ret = SqlHelper.ExecuteSqls(mSqls.ToArray()); if (ret == 0) { Dlg.ShowOKInfo("删除成功!"); ClearForm(); InitRight(); } } }
private void btnAudit_Click(object sender, EventArgs e) { if (DialogResult.Yes == MessageBox.Show("确认复核通过?", "提示", MessageBoxButtons.YesNo)) { int ret = 0; string auditString = ""; foreach (DataGridViewRow mRow in dgvNoTicketAudit.Rows) { if (Convert.ToBoolean(mRow.Cells["ColumnChecked"].Value) == true) { auditString += mRow.Cells["idDataGridViewTextBoxColumn"].Value + ","; } } auditString = auditString.TrimEnd(','); if (auditString == "") { Dlg.ShowErrorInfoAndHelp("没有选择要复核的记录"); return; } string mSql = string.Format("UPDATE T_NoTicket SET P2 = '{0}',P3 = '{1}', AuditDate = GETDATE() WHERE Id IN ({2})", "复核已通过", Classes.PubClass.UserId, auditString); ret = SqlHelper.ExecuteNonQuery(mSql); if (ret > 0) { Dlg.ShowOKInfo("保存成功"); //刷新页面 refresh(); } else { Dlg.ShowErrorInfo("保存失败"); } } }
private object addControl(string senderName, string _sTitle = "") { try { Control mCT = null; if (PnlClient.Controls.Find(senderName, false).Length > 0) //该页面已存在 { mCT = PnlClient.Controls.Find(senderName, false)[0]; } else { Assembly myAs = Assembly.GetExecutingAssembly(); Type mType = myAs.GetType(senderName); if (mType == null) { Dlg.ShowErrorInfoAndHelp("没有找到窗体"); return(1); } if (mType.BaseType.Name == "UserControl" || mType.BaseType.Name == "UserControlBase") { mCT = (Control)Activator.CreateInstance(mType); mCT.Name = senderName; } SetDoubleBuffered(mCT); PnlClient.Controls.Add(mCT); // mCT.Parent = panel1; //将控件加载到标签页上 } if (mCT != null) { mCT.Dock = System.Windows.Forms.DockStyle.Fill; mCT.BringToFront(); mCT.Select(); } if (string.IsNullOrEmpty(_sTitle)) { LblTip.Text = senderName; } else { LblTip.Text = _sTitle; } } catch (Exception ex) { Dlg.ShowErrorInfo(string.Format("异常:\n{0}", ex.Message)); return(1); } return(0); //0成功 }
private void btnAudit2_Click(object sender, EventArgs e) { if (DialogResult.Yes == MessageBox.Show("确认审批不通过?", "提示", MessageBoxButtons.YesNo)) { int ret = 0; string auditString = ""; foreach (DataGridViewRow mRow in dgvNoTicketAudit.Rows) { if (Convert.ToBoolean(mRow.Cells["ColumnChecked"].Value) == true) { auditString += mRow.Cells["idDataGridViewTextBoxColumn"].Value + ","; } } auditString = auditString.TrimEnd(','); if (auditString == "") { Dlg.ShowErrorInfoAndHelp("没有选择要审批的记录"); return; } string mSql = string.Format("UPDATE T_NoTicket SET Status = '{0}',AuditId = '{1}', AuditDate = GETDATE() WHERE (Id IN ({2}))", "审批未通过", Classes.PubClass.UserId, auditString); ret = SqlHelper.ExecuteNonQuery(mSql); if (ret > 0) { Dlg.ShowOKInfo("保存成功!"); //修改页面显示2016.9.6 refresh(); //foreach (DataGridViewRow mRow in dgvExAllocation.Rows) //{ // if (Convert.ToBoolean(mRow.Cells["ColumnChecked"].Value) == true) // { // dgvExAllocation.Rows.Remove(mRow); // } //} } else { Dlg.ShowErrorInfo("保存失败"); } } }
private void tsbRYDel_Click(object sender, EventArgs e) { if (dgvRY.SelectedRows.Count == 0) { return; } int gh = Convert.ToInt32(dgvRY.SelectedRows[0].Cells["ColGH"].Value); if (gh == 1001) { Dlg.ShowErrorInfoAndHelp("工号1001不能进行删除!"); return; } //检查用户是否过做业务 DbAccess DbAcs = new DbAccess(CommonClass.ConnStr); DbAcs.m_sSQL = string.Format("select count(*) from XTtradelist where operaterid='{0}'", gh); DataSet DS = DbAcs.GetDataSet(); if (DS.ExtendedProperties["ReturnFlag"].ToString() != "0") { Dlg.ShowErrorInfo(DS.ExtendedProperties["ReturnFlag"].ToString()); return; } if (DS.Tables[0].Rows[0][0].ToString() != "0") { Dlg.ShowErrorInfo("该用户已经做过业务,不能删除!"); return; } //Confirm if (Dlg.ShowConfirmInfo("确认要删除该用户吗?") == DialogResult.No) { return; } string mSql = string.Format("delete from ptry where gh='{0}'", gh); int ret = SqlHelper.ExecuteNonQuery(mSql); if (ret > 0) { InitRY(); } }
private void tsbAddRole_Click(object sender, EventArgs e) { using (FrmInput mForm = new FrmInput()) { if (mForm.ShowDialog() == DialogResult.OK) { int iRet = Convert.ToInt32(SqlHelper.ExecuteScalar(string.Format("select count(*) from ptryz where ZMC='{0}'", mForm.txtInput.Text.Trim()))); if (iRet > 0) { Dlg.ShowErrorInfoAndHelp("该角色已存在,请重新创建!"); return; } iRet = SqlHelper.ExecuteNonQuery(string.Format("insert into ptryz(zmc)values('{0}')", mForm.txtInput.Text.Trim())); InitRYZ(); if (iRet != 0) { Dlg.ShowOKInfo("创建成功!"); } } } }
private void TSMenuItemHelp_Click(object sender, EventArgs e) { string sHelpFileName = string.Format(@"{0}\一卡多表管理系统使用手册.chm", Application.StartupPath); string sHelpFileName_PDF = string.Format(@"{0}\一卡多表管理系统使用手册.pdf", Application.StartupPath); if (File.Exists(sHelpFileName)) { System.Diagnostics.Process.Start(sHelpFileName); } else { if (File.Exists(sHelpFileName_PDF)) { System.Diagnostics.Process.Start(sHelpFileName_PDF); } else { Dlg.ShowErrorInfoAndHelp(string.Format("帮助文件“{0}”不存在!", sHelpFileName)); } } }
private void tsbLock_Click(object sender, EventArgs e) { if (dgvRY.SelectedRows.Count < 1) { Dlg.ShowErrorInfoAndHelp(string.Format("请选择要锁定的员工!")); return; } int gh = Convert.ToInt32(dgvRY.SelectedRows[0].Cells["ColGH"].Value); if (gh == 1001) { Dlg.ShowErrorInfoAndHelp("工号1001不能进行锁定!"); return; } string mSql = string.Format("update ptry set zt ='1' where gh='{0}'", gh); int ret = SqlHelper.ExecuteNonQuery(mSql); InitRY(); tsbUnlock.Enabled = true; tsbLock.Enabled = false; SelectRow(gh); }
private void tsbLock_Click(object sender, EventArgs e) { if (dgvRY.SelectedRows.Count < 1) { Dlg.ShowErrorInfoAndHelp(string.Format("请选择要锁定的员工!")); return; } string loginName = dgvRY.SelectedRows[0].Cells[ColLoginName.Index].Value.ToString(); if (loginName.ToLower() == "admin") { Dlg.ShowErrorInfoAndHelp("admin不能进行锁定!"); return; } long Id = Convert.ToInt64(dgvRY.SelectedRows[0].Cells[ColLoginName.Index].Value); string mSql = string.Format("update t_users set userstatus ='停用' where id='{0}'", Id); int ret = SqlHelper.ExecuteNonQuery(mSql); InitRY(); tsbUnlock.Enabled = true; tsbLock.Enabled = false; SelectRow(Id); }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { try { if (blZhuxiao == false) { if (Dlg.ShowConfirmInfo("确定退出系统?") == System.Windows.Forms.DialogResult.No) { e.Cancel = true; return; } else { e.Cancel = false; //return; #region 取数据库备份参数 int backupMode; string backupPath; string lsql = string.Format("SELECT IntCode,VcParam1 from SysParam where IntType=1"); using (DataTable dt = SqlHelper.GetData(lsql)) { if (dt.Rows.Count == 0) { Dlg.ShowErrorInfoAndHelp("第一次使用,请设置数据库备份参数!"); e.Cancel = true; return; } else { backupMode = Utils.StrToIntDef(dt.Rows[0]["IntCode"].ToString(), -1); backupPath = Convert.ToString(dt.Rows[0]["VcParam1"]).Trim(); } if ((backupMode < 0) || (backupMode > 2)) { Dlg.ShowErrorInfo("数据库“备份选项”不正确,请设置!"); e.Cancel = true; return; } if (backupMode != 2) { if (string.IsNullOrEmpty(backupPath) == true) { if (Dlg.ShowConfirmInfo("数据库备份路径为空,请设置!") == System.Windows.Forms.DialogResult.Yes) { e.Cancel = true; return; } } if ((!Directory.Exists(backupPath)) && CommonClass.SttDb.iDBType == 0) { if (Dlg.ShowConfirmInfo("数据库备份路径在本机不存在,请设置!") == System.Windows.Forms.DialogResult.Yes) { e.Cancel = true; return; } } } } #endregion #region 备份 if (CommonClass.SttDb.iDBType == 0) { string dbFullName = Application.StartupPath + @"\DbMeter.mdb"; Cursor.Current = Cursors.WaitCursor; CopyFileClass.Backup(backupMode, dbFullName, backupPath); Cursor.Current = Cursors.Default; } else { if (backupMode == 0) { if (Dlg.ShowConfirmInfo("是否备份数据库") == System.Windows.Forms.DialogResult.Yes) { Cursor.Current = Cursors.WaitCursor; string dbFullName = backupPath + "\\dbmeter" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bak"; System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\(.*?\)"); string dbName = regex.Match(CommonClass.SttDb.sDbInfo).ToString().Trim('(', ')'); string mSql = string.Empty; mSql = string.Format(@"BACKUP DATABASE {0} TO DISK = N'{1}' WITH INIT , NOUNLOAD , NAME = N'{0}备份',NOSKIP , STATS = 10, NOFORMAT", dbName, dbFullName); SqlHelper.ExecuteNonQuery(mSql); Cursor.Current = Cursors.Default; } } else if (backupMode == 1) { Cursor.Current = Cursors.WaitCursor; string dbFullName = backupPath + "\\dbmeter" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bak"; System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\(.*?\)"); string dbName = regex.Match(CommonClass.SttDb.sDbInfo).ToString().Trim('(', ')'); string mSql = string.Empty; mSql = string.Format(@"BACKUP DATABASE {0} TO DISK = N'{1}' WITH INIT , NOUNLOAD , NAME = N'{0}备份',NOSKIP , STATS = 10, NOFORMAT", dbName, dbFullName); SqlHelper.ExecuteNonQuery(mSql); Cursor.Current = Cursors.Default; } } #endregion //关闭启动窗体 myLogin.Close(); } } } catch (Exception ex) { Dlg.ShowErrorInfo(ex.Message); e.Cancel = true; return; } }
private object addControl(string senderName, ModuleList mModule) { try { Control mCT = null; string sCtrlName = mModule.MKHSM; if (PnlClient.Controls.Find(sCtrlName, false).Length > 0) //该页面已存在 { mCT = PnlClient.Controls.Find(sCtrlName, false)[0]; } else { Assembly myAs; string sDllFile = mModule.MKWJM; if (File.Exists(sDllFile)) { myAs = Assembly.LoadFrom(sDllFile); } else { myAs = Assembly.GetExecutingAssembly(); } if (myAs == null) { Dlg.ShowErrorInfoAndHelp(string.Format("未找到程序集({0})", mModule.MKWJM)); return(null); } Type mType = myAs.GetType(sCtrlName); if (mType == null) { Dlg.ShowErrorInfoAndHelp(string.Format("没有找到窗体({0})!", sCtrlName)); return(1); } mCT = (Control)Activator.CreateInstance(mType); mCT.Name = sCtrlName; //if (mType.BaseType.Name != "Form" ) //{ // mCT.BackColor = System.Drawing.Color.Transparent; //} SetDoubleBuffered(mCT); //SetBackColorTransParent(mCT); mCT.Dock = System.Windows.Forms.DockStyle.Fill; if (mCT is Form) { mCT.Show(); } else { mCT.Tag = mModule; //PnlClient.Controls.Clear(); foreach (Control ctrl in PnlClient.Controls) { ctrl.Dispose(); } PnlClient.Controls.Add(mCT); } // mCT.Parent = panel1; } if (mCT != null) { //for (int i = 0; i < panel1.Controls.Count; i++) //{ // panel1.Controls[i].Dispose(); //} mCT.BringToFront(); mCT.Select(); } LblTip.Text = senderName; } catch (Exception ex) { Dlg.ShowErrorInfo(string.Format("异常:\n{0}", ex.Message)); return(1); } return(0); //0成功 }
private void LoadModuleListFromXml() { XmlDocument mXml = new XmlDocument(); if (System.IO.File.Exists("System.xml") == false) { Dlg.ShowErrorInfoAndHelp("没有发现配置文档"); return; } mXml.Load("System.xml"); XmlNode mConfigNode = mXml.SelectSingleNode("/Config/ConfigFile"); if (mConfigNode == null) { Dlg.ShowErrorInfoAndHelp("配置文件有误"); return; } if (System.IO.File.Exists(mConfigNode.Attributes["FileName"].Value) == false) { Dlg.ShowErrorInfoAndHelp("没有发现配置文档"); return; } mXml.Load(mConfigNode.Attributes["FileName"].Value); XmlNodeList mNodeList = mXml.SelectNodes("/Config/menus"); for (int i = 0; i < mNodeList.Count; i++) { XmlNode mNode = mNodeList[i]; Image imageTemp = null; string strText = "缺省值"; string strName; if (mNode.Attributes["imagePath"].Value != null) { imageTemp = Image.FromFile(mNode.Attributes["imagePath"].Value); } else { imageTemp = Image.FromFile(@"Images\1.png"); } if (mNode.Attributes["text"].Value != null) { strText = mNode.Attributes["text"].Value; } if (mNode.Attributes["name"].Value != null) { strName = mNode.Attributes["name"].Value; } else { strName = new Guid().ToString(); } ToolStripButton tsbMain = new ToolStripButton(strText, imageTemp, new EventHandler(mtoolStripButton1_Click), strName); //新建菜单主项按钮 tsbMain.DisplayStyle = ToolStripItemDisplayStyle.Image; tsbMain.TextImageRelation = TextImageRelation.ImageAboveText; ToolStrip tsTemp = new ToolStrip(); // 新建侧边栏 tsTemp.Name = "ts" + mNode.Attributes["text"].Value; tsTemp.Visible = false; tsTemp.ImageScalingSize = new Size(32, 32); tsTemp.BackColor = System.Drawing.Color.FromArgb(192, 220, 255); tsTemp.Dock = DockStyle.Fill; tsTemp.GripStyle = ToolStripGripStyle.Hidden; tsTemp.LayoutStyle = ToolStripLayoutStyle.VerticalStackWithOverflow; tsTemp.Parent = splitContainer1.Panel1; //新建菜单栏 ToolStripMenuItem tsmiTemp = new ToolStripMenuItem(mNode.Attributes["text"].Value); tsmiTemp.Name = "tsmi" + mNode.Attributes["text"].Value; MenuMain.Items.Insert(0, tsmiTemp); //menuStrip1.Items.Add(mItem); //toolStripM.Items.Add(tsbMain); //菜单主项按钮添加到主toolstrip XmlNodeList mChildNodes = mNode.ChildNodes; for (int j = 0; j < mChildNodes.Count; j++) { XmlNode mChildNode = mChildNodes[j]; Image imageChildTemp = null; string strChildText = "缺省值"; string strChildName; if (mChildNode.Attributes["imagePath"].Value != null) { imageChildTemp = Image.FromFile(mChildNode.Attributes["imagePath"].Value); } else { imageChildTemp = Image.FromFile(@"Images\1.png"); } if (mChildNode.Attributes["text"].Value != null) { strChildText = mChildNode.Attributes["text"].Value; } if (mChildNode.Attributes["name"].Value != null) { strChildName = mChildNode.Attributes["name"].Value; } else { strChildName = new Guid().ToString(); } ToolStripButton tsbTemp = new ToolStripButton(strChildText, imageChildTemp, new EventHandler(t2toolStripButton1_Click), strChildName);//新建业务按钮 ModuleList myModule = new ModuleList(); tsbTemp.ImageScaling = ToolStripItemImageScaling.SizeToFit; tsbTemp.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; tsbTemp.TextImageRelation = TextImageRelation.ImageAboveText; myModule.MKHSM = mChildNode.Attributes["class"].Value; //获取类名 myModule.MKWJM = mChildNode.Attributes["dllName"].Value; //获取程序集名称 tsbTemp.Tag = myModule; myModuleList.Add(myModule); tsTemp.Items.Add(tsbTemp); //业务按钮添加到控件上 //添加菜单子项 ToolStripMenuItem tsmiSubTemp = new ToolStripMenuItem(strChildText, imageChildTemp, new EventHandler(t2toolStripButton1_Click)); tsmiSubTemp.Tag = myModule; tsmiTemp.DropDownItems.Add(tsmiSubTemp); } } }
private void tsbRYAdd_Click(object sender, EventArgs e) { TrimTextBox(); if (TBGH.Text.Trim() == string.Empty) { toolTip1.Show("工号不能为空", TBGH, 0, TBGH.Height, 2000); return; } if (TBXM.Text.Trim() == string.Empty) { toolTip1.Show("姓名不能为空", TBXM, 0, TBXM.Height, 2000); return; } if (Utils.StrToIntDef(TBGH.Text, -1) == -1) { Dlg.ShowErrorInfoAndHelp("请输入四位数字工号,且不能与已有工号重复!"); TBGH.SelectAll(); TBGH.Focus(); return; } if (TBDH.Text != "") { if (Utils.StrToIntDef(TBDH.Text, -1) == -1) { Dlg.ShowErrorInfoAndHelp("请输入正确的电话号码数字!"); TBDH.SelectAll(); TBDH.Focus(); return; } } ry ry = new ry(); ry.GH = Convert.ToInt32(TBGH.Text); ry.XM = TBXM.Text.Trim(); ry.XB = "男"; ry.DH = TBDH.Text.Trim(); ry.SH = Convert.ToInt32(CBoxSH.SelectedValue); ry.RYZ = Convert.ToInt32(CBoxRole.SelectedValue); if (rbFemale.Checked == true) { ry.XB = "女"; } int ret = Convert.ToInt32(SqlHelper.ExecuteScalar(string.Format("select count(1) from ptry where gh='{0}'", ry.GH))); if (ret > 0) { toolTip1.Show("该工号已存在,请重新输入", TBGH, 0, TBGH.Height, 2000); TBGH.Focus(); return; } string mSql = string.Format("insert into ptry(gh,xm,xb,dh,sh,jb,zt,mm) values ({0},'{1}','{2}','{3}',{4},{5},'0','{6}')", ry.GH, ry.XM, ry.XB, ry.DH, ry.SH, ry.RYZ, MD5.Md5Encrypt("1001")); ret = SqlHelper.ExecuteNonQuery(mSql); if (ret > 0) { InitRY(); SelectRow(ry.GH); Dlg.ShowOKInfo("添加成功,初始密码1001!"); } }
private void tsbModify_Click(object sender, EventArgs e) { string MKBH; if (tvRight.SelectedNode == null) { Dlg.ShowErrorInfoAndHelp("请选择要修改的模块!"); return; } MKBH = ((ModuleList)tvRight.SelectedNode.Tag).MKBH; ModuleList ml = new ModuleList(); ml.MKBH = txtMKBH.Text.Trim(); ml.MKMC = txtMKMC.Text.Trim(); ml.MKTP = cmbTP.Text; ml.BBH = txtBBH.Text.Trim(); ml.CardType = Convert.ToInt32(cmbCardType.SelectedValue); if (ml.MKBH == "") { toolTip1.Show("模块编号不能为空!", txtMKBH, 0, txtMKBH.Height, 2000); return; } if (ml.MKMC == "") { toolTip1.Show("模块名称不能为空!", txtMKMC, 0, txtMKMC.Height, 2000); return; } if (ml.BBH == "") { toolTip1.Show("模块版本号不能为空!", txtBBH, 0, txtBBH.Height, 2000); return; } int ret; string mSql; List <string> mSqls = new List <string>(); if (MKBH != ml.MKBH) { ret = Convert.ToInt32(SqlHelper.ExecuteScalar(string.Format("select count(1) from ptcd where mkbh='{0}'", ml.MKBH))); if (ret > 0) { toolTip1.Show("该模块编号已存在!", txtMKBH, 0, txtMKBH.Height, 2000); return; } } if (rbZCD.Checked == true) { ml.MKWJM = ""; ml.MKHSM = ""; ml.MKJB = 1; ml.MKFCD = "0000"; ml.FastStart = "0"; } else { if (ml.MKWJM == "") { toolTip1.Show("模块文件名不能为空!", txtMKWJM, 0, txtMKWJM.Height, 2000); return; } if (ml.MKHSM == "") { toolTip1.Show("模块函数名不能为空!", txtMKWJM, 0, txtMKWJM.Height, 2000); return; } ml.FastStart = Convert.ToInt32(cbFastStart.Checked).ToString(); ml.MKJB = 2; ml.MKFCD = cmbFCD.SelectedValue.ToString(); ml.MKWJM = txtMKWJM.Text.Trim(); ml.MKHSM = txtMKHSM.Text.Trim(); } mSql = string.Format("update ptcd set mkbh='{0}',mkmc='{1}',mkjb='{2}',mkfcd='{3}',mktp='{4}',mkwjm='{5}',mkhsm='{6}',faststart='{7}',bbh='{8}',cardtype={9} where mkbh='{10}'", ml.MKBH, ml.MKMC, ml.MKJB, ml.MKFCD, ml.MKTP, ml.MKWJM, ml.MKHSM, ml.FastStart, ml.BBH, ml.CardType, MKBH); mSqls.Add(mSql); mSql = string.Format("update ptcd set mkfcd ='{0}' where mkfcd='{1}'", ml.MKBH, MKBH); mSqls.Add(mSql); ret = SqlHelper.ExecuteSqls(mSqls.ToArray()); if (ret == 0) { InitRight(); //tvRight.BeginUpdate(); //try //{ // TreeNode[] mNodes = tvRight.Nodes.Find(ml.MKBH, true); // if (mNodes.Length > 0) // tvRight.SelectedNode = mNodes[0]; //} //finally //{ // tvRight.EndUpdate(); //} Dlg.ShowOKInfo("修改成功!"); } }
private void tsbRYSave_Click(object sender, EventArgs e) { if (dgvRY.SelectedRows.Count < 1) { Dlg.ShowErrorInfoAndHelp("请先选择要保存的用户"); return; } if (TBGH.Text.Trim() == string.Empty) { toolTip1.Show("工号不能为空", TBGH, 0, TBGH.Height, 2000); return; } if (TBXM.Text.Trim() == string.Empty) { toolTip1.Show("姓名不能为空", TBXM, 0, TBXM.Height, 2000); return; } ry ry = new ry(); ry.GH = Convert.ToInt32(TBGH.Text); ry.XM = TBXM.Text.Trim(); ry.XB = "男"; ry.DH = TBDH.Text.Trim(); ry.SH = Convert.ToInt32(CBoxSH.SelectedValue); ry.RYZ = Convert.ToInt32(CBoxRole.SelectedValue); if (rbFemale.Checked == true) { ry.XB = "女"; } int gh = Convert.ToInt32(dgvRY.SelectedRows[0].Cells["ColGH"].Value); int ret; if (gh != ry.GH) { Dlg.ShowErrorInfoAndHelp("已经创建的员工不允许修改其工号!"); return; //if (gh == 1001) //{ // Dlg.ShowErrorInfoAndHelp("员工1001不允许修改工号!"); // return; //} //ret = Convert.ToInt32(SqlHelper.ExecuteScalar(string.Format("select count(1) from ptry where gh={0}", ry.GH))); //if (ret > 0) //{ // toolTip1.Show("该工号已存在,请重新输入", TBGH, 0, TBGH.Height, 2000); // TBGH.Focus(); // return; //} } if ((gh == 1001) && (ry.RYZ != (int)dgvRY.SelectedRows[0].Cells["ColJB"].Value)) { Dlg.ShowErrorInfoAndHelp("员工1001不允许修改权限!"); return; } string mSql = string.Format("update ptry set gh='{0}',xm='{1}',xb='{2}',dh='{3}',sh={4},jb={5} where gh='{6}'", ry.GH, ry.XM, ry.XB, ry.DH, ry.SH, ry.RYZ, gh); ret = SqlHelper.ExecuteNonQuery(mSql); if (ret > 0) { InitRY(); SelectRow(ry.GH); Dlg.ShowOKInfo("修改成功!"); } }