/// <summary> /// 添加用户 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { if (this.checkInput()) { int result = SysUserMgr.Add(this.txtUserId.Text, this.txtPass.Text, this.txtName.Text, this.cbxDepart.SelectedValue.ToString() , this.txtTel.Text, this.txtEmail.Text, this.cbxPower.Text); if (result == -1) { untCommon.InfoMsg("添加用户失败"); return; } if (result != -2)//既添加用户又 添加默认权限 { untCommon.InfoMsg("添加用户成功,并成功的设置了权限。"); this.cleartxt(); //清空文本框 this.lvwUser.Items.Clear(); this.InitUser(); } else { if (untCommon.QuestionMsg("添加用户成功,但自动设置权限失败。是否要手动设置权限?")) { this.lvwUser.Items.Clear(); this.InitUser(); frmPowerSet power = new frmPowerSet(); power.ShowDialog(); return; } } } }
private void frmUpdateSysUserInfo_Load(object sender, EventArgs e) { this.txtLoginId.Text = this._loginid;//加载登录id DataTable dt = SysUserMgr.GetOneUser(this._loginid); DataTable dtDepart = DepartMgr.GetAllDepartment(); this.cbxDepart.DataSource = dtDepart; this.cbxDepart.DisplayMember = dtDepart.Columns[0].ToString(); this.cbxDepart.ValueMember = dtDepart.Columns[1].ToString(); if (dt != null) { this.txtName.Text = dt.Rows[0][2].ToString(); this.cbxDepart.Text = DepartMgr.GetNameFromId(dt.Rows[0][3].ToString()); this.txtTel.Text = dt.Rows[0][4].ToString(); this.txtEmail.Text = dt.Rows[0][5].ToString(); } if (this._isother) { this.txtOldPass.PasswordChar = new char(); this.txtOldPass.Text = SysUserMgr.GetPass(this._loginid); //自己不可更改自身所在部门,只有由其他人进行更改才行 this.cbxDepart.Enabled = true; } }
private void btnLogin_Click(object sender, EventArgs e) { if (checkInput()) { sydata = SysUserMgr.Login(this.txtUser.Text, txtPass.Text); _user = sydata[0]; _depart = sydata[1]; _power = sydata[2]; if (_user != null) { if (_user != "-1") { this.DialogResult = DialogResult.OK; } else { untCommon.InfoMsg("用户名或密码错误,请核实以后再输入"); } } else { untCommon.ErrorMsg("登录失败。\r\n信息:连接不到服务器。"); } } }
private void frmEqAdd_Load(object sender, EventArgs e) { initcbx(this.cbxFunds, "Funds"); initcbx(this.cbxPriceType, "PriceType"); initcbx(this.cbxUsage, "Usage"); initcbx(this.cbxDirection, "Direction"); initcbx(this.cbxBuyWay, "BuyWay"); initcbx(this.cbxGetWay, "GetWay"); initcbx(this.cbxCarUse, "CarUse"); initcbx(this.cbxCarBP, "CarBP"); initcbx(this.cbxFormation, "Formation"); initcbx(this.cbxPR, "Pr"); initcbx(this.cbxCertNature, "CertNature"); initcbx(this.cbxStructure, "Structure"); initcbx(this.cbxUnit, "Unit"); initcbx(this.cbxKeepPlace, "KeepPlace"); initcbx(this.cbxRelicLv, "RelicLv"); initcbx(this.cbxCampus, "Campus"); this.txtDepartment.Text = SysUserMgr.GetDepartmentIDByUser(this._user); this.txtDepartment.Text = DepartMgr.GetNameFromId(this.txtDepartment.Text); this.dtpAddDate.Text = DateTime.Now.ToShortDateString(); this.txtAgent.Text = this._user; //cbxEqKeeper的初始化与其他不同,其ValueMember和DisplayMember是不一样的 initcbxEmployee(this.cbxEqKeeper); initcbxEmployee(this.cbxPurchaser); }
/// <summary> /// 删除用户 /// </summary> private void Del() { if (this.lvwUser.SelectedItems.Count == 0) { untCommon.InfoMsg("请选择所要删除的系统用户。"); return; } if (untCommon.QuestionMsg("您确定要删除该用户吗?"))//确认删除 { if (this.lvwUser.SelectedItems[0].Tag.ToString() == this._loginname) { untCommon.ErrorMsg("错误,您不能删除您自己。"); return; } if (SysUserMgr.Del(this.lvwUser.SelectedItems[0].Tag.ToString())) { lvwUser.Items.Clear(); InitUser(); } else { untCommon.InfoMsg("删除失败。"); } } }
/// <summary> /// 添加用户 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { ; if (this.checkInput()) { int result = SysUserMgr.Add(this.txtUsername.Text, this.txtPass.Text, this.txtName.Text, this.chkDefaultPower.Checked); if (result == -2) { untCommon.InfoMsg("添加用户失败"); return; } if (result == -5)//只添加用户 { untCommon.InfoMsg("添加用户成功"); this.cleartxt(); //清空文本框 return; } if (result != -3)//既添加用户又 添加默认权限 { untCommon.InfoMsg("添加用户成功,并成功的设置了默认权限。"); this.cleartxt(); //清空文本框 } else { if (untCommon.QuestionMsg("添加用户成功,但自动设置权限失败。是否要手动设置权限?")) { frmPowerSet power = new frmPowerSet(); power.ShowDialog(); return; } } } }
public void initListbox() { DataTable dt = SysUserMgr.GetAllLoginName(); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { lstUser.Items.Add(dt.Rows[i][0].ToString()); } } }
/// <summary> /// 得到某用户的权限(所能做的操作),并表现出来 /// </summary> private void GetFuncByUser(string id) { this.list = SysUserMgr.GetOneListByUser(id); for (int i = 0; i < tvwFunc.Nodes.Count; i++) { tvwFunc.Nodes[i].Checked = false; } for (int i = 0; i < tvwFunc.Nodes.Count; i++) { this.GetNodes(this.tvwFunc.Nodes[i]); } }
/// <summary> /// 得到某用户的权限(所能做的操作),并表现出来 /// </summary> private void GetFuncByUser() { this.list = SysUserMgr.GetOneListByUser(this.lstUser.SelectedItem.ToString()); for (int i = 0; i < tvwFunc.Nodes.Count; i++) { tvwFunc.Nodes[i].Checked = false; } for (int i = 0; i < tvwFunc.Nodes.Count; i++) { this.GetNodes(this.tvwFunc.Nodes[i]); } }
private void frmMain_Load(object sender, EventArgs e) { this.MenuList = SysUserMgr.GetPower(_loginname); //得到登录用户的权限(可执行的操作) this.initMenu(); //加载菜单 this.initToolBar(); //加载资产管理的工具栏 this.InitDbgEq(); //加载资产表 this.BuilTree(); //加载树 this.tvwEqSeach.Nodes[0].Expand(); //展开树的第一层节点 this.InitStatusInfo(); //加载状态栏 TotalPage = this.getTotalPage(); //得到数据的总页数 this.lblTotalpage.Text = "共" + TotalPage.ToString() + "页"; }
/// <summary> /// 将所有用户都绑定到listveiw上 /// </summary> private void InitUser() { DataTable dt = SysUserMgr.GetAllUser(); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { ListViewItem item = new ListViewItem(); item.Text = dt.Rows[i][1].ToString(); item.Tag = dt.Rows[i][0].ToString(); item.ImageIndex = 0; lvwUser.Items.Add(item); } } }
public void initListbox() { DataTable dt = SysUserMgr.GetAllLoginName(); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { lstUser.Items.Add(dt.Rows[i][0].ToString()); } //这三个用户和sa一样是不可改动的,用于存储三个级别用户的默认权限,不对外开放 lstUser.Items.Remove("一级用户"); lstUser.Items.Remove("二级用户"); lstUser.Items.Remove("三级用户"); } }
/// <summary> /// 构造功能节点 /// </summary> /// <param name="parent"></param> private void Buildfunc(TreeNode parent) { int menuid = int.Parse(parent.Tag.ToString()); DataTable dt = SysUserMgr.GetFuncList(menuid); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { TreeNode node = new TreeNode(); node.Text = dt.Rows[i][1].ToString(); node.Tag = dt.Rows[i][0].ToString(); parent.Nodes.Add(node); } } }
/// <summary> /// 选中不同的用户,得到用户的真实姓名 /// 并且得到用户的权限 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lstUser_SelectedIndexChanged(object sender, EventArgs e) { string name = ""; if (lstUser.SelectedIndex != -1) { name = SysUserMgr.GetANameByLoginName(lstUser.SelectedItems[0].ToString()); } if (name != "") { this.lblnamee.Visible = true; this.lblName.Text = name; } this.GetFuncByUser();//得到权限 }
/// <summary> /// 选中不同的用户,得到用户的真实姓名 /// 并且得到用户的权限 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lstUser_SelectedIndexChanged(object sender, EventArgs e) { string id = ""; if (lstUser.SelectedIndex != -1) { id = SysUserMgr.GetIdByLoginName(lstUser.SelectedItems[0].ToString()); } if (id != "") { this.label3.Visible = true; this.lblid.Text = id; } this.panelCheck.Enabled = true; this.rbtnFree.Checked = true; this.GetFuncByUser(this.lblid.Text);//得到权限 }
/// <summary> /// 构造树 /// </summary> /// <param name="parentNode"></param> /// <param name="parentid"></param> private void BuildTree(TreeNode parentNode, int parentid) { DataTable dt = SysUserMgr.GetFuncList(parentid); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { TreeNode node = new TreeNode(); node.Text = dt.Rows[i][1].ToString(); node.Tag = dt.Rows[i][0].ToString(); // node.Nodes.Add("正在加载..."); tvwFunc.Nodes.Add(node); this.Buildfunc(tvwFunc.Nodes[i]); this.tvwFunc.ExpandAll(); } } }
private void btnOk_Click(object sender, EventArgs e) { //修改资料(不修改密码) if (this.chkPass.Checked == false) { if (this.txtName.Text.Trim() == "") { untCommon.InfoMsg("请输入真实姓名。"); return; } if (SysUserMgr.UpdateNoPass(this.txtLoginId.Text, this.txtName.Text, this.txtTel.Text, this.txtEmail.Text, this.cbxDepart.SelectedValue.ToString())) { untCommon.InfoMsg("修改成功。"); } else { untCommon.InfoMsg("修改失败"); } } else { if (this.checkInput())//修改密码 { int result = SysUserMgr.UpdatePass(this.txtLoginId.Text, this.txtOldPass.Text, this.txtNewPass.Text, this.txtName.Text, this.txtTel.Text, this.txtEmail.Text, this.cbxDepart.SelectedValue.ToString()); if (result > 0) { untCommon.InfoMsg("修改成功。"); this.Cleartxt(); this.chkPass.Checked = false; } else { if (result == -1) { untCommon.InfoMsg("原密码错误,请确认后在输入。修改失败。"); this.Cleartxt(); return; } untCommon.InfoMsg("修改失败"); } } } }
private void btnOk_Click(object sender, EventArgs e) { //�����ϣ��������룩 if (this.chkPass.Checked == false) { if (this.txtName.Text.Trim() == "") { untCommon.InfoMsg("��������ʵ������"); return; } if (SysUserMgr.UpdateNoPass(this.txtLoginname.Text, this.txtName.Text)) { untCommon.InfoMsg("�ijɹ���"); } else { untCommon.InfoMsg("��ʧ��"); } } else { if (this.checkInput())//������ { int result = SysUserMgr.UpdatePass(this.txtLoginname.Text, this.txtOldPass.Text, this.txtNewPass.Text, this.txtName.Text); if (result > 0) { untCommon.InfoMsg("�ijɹ���"); this.Cleartxt(); this.chkPass.Checked = false; } else { if (result == -1) { untCommon.InfoMsg("ԭ���������ȷ�Ϻ������롣��ʧ�ܡ�"); this.Cleartxt(); return; } untCommon.InfoMsg("��ʧ��"); } } } }
/// <summary> /// 将所有用户都绑定到listveiw上 /// </summary> private void InitUser() { DataTable dt = SysUserMgr.GetAllUser(); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { ListViewItem item = new ListViewItem(); item.Text = dt.Rows[i][1].ToString(); item.Tag = dt.Rows[i][0].ToString(); item.ImageIndex = 0; //这三个用户时为了保存默认权限所设置的,并不对外开放 if (item.Text == "一级用户" || item.Text == "二级用户" || item.Text == "三级用户") { continue; } lvwUser.Items.Add(item); } } }
/// <summary> /// 构造清理人树 /// </summary> private void BuidTree() { TreeNode Root = new TreeNode(); Root.Text = "清理人"; Root.ImageIndex = 0; Root.ImageIndex = 0; tvwClearer.Nodes.Add(Root); tvwClearer.ExpandAll(); DataTable dt = SysUserMgr.GetAllName(); if (dt != null)//构造子节点(清理人名单) { for (int i = 0; i < dt.Rows.Count; i++) { TreeNode clearer = new TreeNode(); clearer.Text = dt.Rows[i][0].ToString(); clearer.ImageIndex = 1; clearer.SelectedImageIndex = 1; Root.Nodes.Add(clearer); } } }
private void btnSave_Click(object sender, EventArgs e) { int error = 0; if (this.lstUser.SelectedIndex == -1) { untCommon.InfoMsg("请选择用户。"); return; } if (this.lstUser.SelectedItems[0].ToString() == this._loginid) { untCommon.ErrorMsg("错误,您不能设置自己的权限。"); return; } if (this.lstUser.SelectedItems[0].ToString() == "sa") { untCommon.ErrorMsg("错误,您不能设置用户" + "sa" + "的权限。用户" + "sa" + "对本系统具有完全控制权"); GetFuncByUser(this.lblid.Text); return; } string loginid = this.lblid.Text; //把节点的checkbox选中的节点tag放到Lastlist中(跟节点除外) for (int i = 0; i < tvwFunc.Nodes.Count; i++) { GetNodesLast(this.tvwFunc.Nodes[i]); } if (!untCommon.QuestionMsg("您确定要更改用户" + this.lstUser.SelectedItem.ToString() + "的权限吗?")) { return; } // 如果list中的某个元素在lastlist中不存在,用户则删除了该功能 for (int i = 0; i < list.Count; i++) { if (Lastlist.Contains(list[i]) == false) { if (SysUserMgr.Del(loginid, int.Parse(list[i].ToString())) == false) { error++;//发生错误 } } } //如果lastlistt中的某个元素在list中不存在,用户则添加了该功能 for (int i = 0; i < Lastlist.Count; i++) { if (list.Contains(Lastlist[i]) == false) { if (SysUserMgr.Add(loginid, int.Parse(Lastlist[i].ToString())) == false) { error++; //发生错误 } } } if (error == 0) { untCommon.InfoMsg("权限更改成功。"); } else { untCommon.InfoMsg("权限更改失败。"); error = 0; GetFuncByUser(this.lblid.Text); } }
/// <summary> /// 添加资产 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolEqAdd_Click(object sender, EventArgs e) { if (this.checkInput()) { this.SetNo(); //生成随机编号 int error = 0; //错误标志 Equipment eq = new Equipment(); eq.EqName = this.txtEqName.Text; eq.EduNo = this.txtEduNo.Text; eq.EqType = this.cbxEqType.Text; eq.Gb = this.txtGB.Text; eq.Usage = this.cbxUsage.Text; eq.Unit = this.cbxUnit.Text; eq.Direction = this.cbxDirection.Text; eq.BuyWay = this.cbxBuyWay.Text; eq.GetWay = this.cbxGetWay.Text; eq.Purchaser = this.cbxPurchaser.Text; eq.Agent = this.txtAgent.Text; eq.Brand = this.txtBrand.Text; eq.Model = this.txtModel.Text; eq.Country = this.txtCountry.Text; eq.Mfrs = this.txtMfrs.Text; eq.ProductNo = this.txtProductNo.Text; eq.Supplier = this.txtSupplier.Text; eq.PriceType = this.cbxPriceType.Text; eq.EqKeeper = this.cbxEqKeeper.Text; eq.Department = DepartMgr.GetIdFromName(this.txtDepartment.Text); eq.Campus = this.cbxCampus.Text; eq.KeepPlace = this.cbxKeepPlace.Text; eq.Cn = this.txtCN.Text; eq.InvNo = this.txtInvNo.Text; eq.Funds = this.cbxFunds.Text; eq.BelongTo = ""; eq.Photo = this.photoPath; eq.Remark = this.txtRemark.Text; if (this.dtpGetDate.Checked == true) { eq.GetDate = this.dtpGetDate.Value.ToShortDateString(); } else { eq.GetDate = ""; } if (dtpAddDate.Checked == true) { eq.AddDate = this.dtpAddDate.Value.ToShortDateString(); } else { eq.AddDate = ""; } if (this.dtpBirthday.Checked == true) { eq.Birthday = this.dtpBirthday.Value.ToShortDateString(); } else { eq.Birthday = ""; } if (this.dtpSvcDate.Checked == true) { eq.SvcDate = this.dtpSvcDate.Value.ToShortDateString(); } else { eq.SvcDate = ""; } /*****************************根据资产类别判断所要填的项********************************************/ //资产类别为“土地、房屋及构筑物”时 if (eq.EqType == "土地、房屋及构筑物") { eq.Pr = this.cbxPR.Text; eq.Address = this.txtAddress.Text; eq.CertNature = this.cbxCertNature.Text; eq.Structure = this.cbxStructure.Text; //有产权时以下四项才可以被填写 if (eq.Pr == "有产权") { if (this.txtCertNo.Text.Trim() == "") { untCommon.InfoMsg("请输入权属证号"); return; } else { eq.CertNo = this.txtCertNo.Text; } if (this.dtpIssueDate.Checked == false) { untCommon.InfoMsg("请选择发证日期"); return; } else { eq.IssueDate = this.dtpIssueDate.Value.ToShortDateString(); } if (this.txtCertProve.Text.Trim() == "") { untCommon.InfoMsg("请输入权属证明"); return; } else { eq.CertProve = this.txtCertProve.Text; } try { eq.CertLim = int.Parse(this.txtCertLim.Text); } catch (FormatException) { untCommon.ErrorMsg("权属年限请输入数字。"); return; } } else { eq.CertNo = ""; eq.IssueDate = ""; eq.CertProve = ""; eq.CertLim = 0; } try { eq.Area = double.Parse(this.txtArea.Text); } catch (FormatException) { untCommon.ErrorMsg("建筑/土地面积请输入数字。"); return; } try { eq.TenuArea = double.Parse(this.txtTenuArea.Text); } catch (FormatException) { untCommon.ErrorMsg("自用面积请输入数字。"); return; } try { eq.TenuPrice = double.Parse(this.txtTenuPrice.Text); } catch (FormatException) { untCommon.ErrorMsg("自用价值请输入数字。"); return; } } else { eq.Pr = ""; eq.CertNo = ""; eq.IssueDate = ""; eq.CertProve = ""; eq.Address = ""; eq.CertNature = ""; eq.Structure = ""; eq.Area = 0; eq.TenuArea = 0; eq.TenuPrice = 0; eq.CertLim = 0; } //资产类别为"通用设备(车辆)" if (eq.EqType == "通用设备(车辆)") { eq.CarUse = this.cbxCarUse.Text; eq.CarBP = this.cbxCarBP.Text; eq.LicNo = this.txtLicNo.Text; eq.Dspl = this.txtDSPL.Text; eq.EngNo = this.txtEngNo.Text; eq.Formation = this.cbxFormation.Text; } else { eq.CarUse = ""; eq.CarBP = ""; eq.LicNo = ""; eq.Dspl = ""; eq.EngNo = ""; eq.Formation = ""; } //资产类别为"无形资产" if (eq.EqType == "无形资产") { eq.RegAuz = this.txtRegAuz.Text; eq.PatNo = this.txtPatNo.Text; eq.ApvNo = this.txtApvNo.Text; eq.MgtAgency = this.txtMgtAgency.Text; if (this.dtpRegTime.Checked == true) { eq.RegTime = this.dtpRegTime.Value.ToShortDateString(); } else { eq.RegTime = ""; } } else { eq.RegAuz = ""; eq.RegTime = ""; eq.PatNo = ""; eq.ApvNo = ""; eq.MgtAgency = ""; } //资产类别为"文物和陈列品" if (eq.EqType == "文物和陈列品") { eq.RelicLv = this.cbxRelicLv.Text; } else { eq.RelicLv = ""; } /*************************************判断结束******************************************************/ try { count = int.Parse(this.txtCount.Text); } catch (FormatException) { untCommon.ErrorMsg("数量请输入数字。"); return; } try { eq.Price = double.Parse(this.txtPrice.Text); } catch (FormatException) { untCommon.ErrorMsg("价值请输入数字。"); return; } try { if (this.txtUSDPrice.Text.Trim() != "") { eq.UsdPrice = double.Parse(this.txtUSDPrice.Text); } else { eq.UsdPrice = 0; } } catch (FormatException) { untCommon.ErrorMsg("美金单价请输入数字。"); return; } if (_power == "0" || _power == "1") { int tempCount = EqMgr.getTempAssetCount(); int allCount = EqMgr.getAllAssetCount(); int eqCount = EqMgr.getAllEqCount(); int assetCount = allCount - tempCount + 1; eq.State = "入库"; for (int j = 1; j <= count; j++) { eq.EqNo = DateTime.Now.Year.ToString() + string.Format("{0:D6}", eqCount + j); eq.AssetNo = SysUserMgr.GetDepartmentIDByUser(this._user) + DateTime.Now.Year.ToString() + string.Format("{0:D4}", assetCount); if (EqMgr.Add(eq)) { /*if (!SqlFileMgr.PhotoAdd(eq.EqNo, photoPath)) * error++; * if (!WriteAttachment(eq.EqNo)) * error++;*/ } else { error++; } } } else { for (int i = 1; i <= count; i++) { eq.EqNo = "TE" + random + string.Format("{0:000}", i); eq.AssetNo = "TA" + random + string.Format("{0:000}", count); eq.State = "新增待审核"; //if (this.pbPhoto.Image != null) //photoPath = this.pbPhoto.ImageLocation; if (EqMgr.Add(eq)) { /*if (!SqlFileMgr.PhotoAdd(eq.EqNo, photoPath)) * error++; * if (!WriteAttachment(eq.EqNo)) * error++;*/ } else { error++; } } } if (error == 0) { untCommon.InfoMsg("添加成功"); ClearInput(); this.SetNo(); this.Close(); } else { untCommon.InfoMsg("错误数目:" + error.ToString()); this.SetNo(); } } }