/// <summary> /// 删除部门 /// </summary> private void Del() { if (tvwDepart.SelectedNode == null) { untCommon.InfoMsg("请选择所要删除的部门"); return; } if (tvwDepart.SelectedNode.Parent == null) { untCommon.InfoMsg("您不能删除该节点"); return; } if (untCommon.QuestionMsg("您确定要删除该部门吗?")) { if (DepartMgr.Del(int.Parse(tvwDepart.SelectedNode.Tag.ToString()))) { this.tvwDepart.SelectedNode.Remove(); //this.BuidTree(); } else { untCommon.ErrorMsg("删除失败。"); } } }
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 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 Initdepart() { DataTable dt = DepartMgr.Getdepart(); if (dt != null) { this.cbxDepart.DataSource = dt; this.cbxDepart.DisplayMember = dt.Columns[1].ToString(); this.cbxDepart.ValueMember = dt.Columns[0].ToString(); } }
/// <summary> /// 领用资产 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { Borrow br = new Borrow(); br.ID = this.textSerialNO.Text; br.EqNo = this.textEqNO.Text; br.EqName = this.textName.Text; DataTable Empdt = EmployeeMgr.GetAllName(); DataTable Depdt = DepartMgr.GetAllDepartment(); br.Department = this.name2ID(Depdt, this.textDepartment.Text, "departName"); br.KeepPlace = this.textKeepPlace.Text; br.Keeper = this.name2ID(Empdt, this.textKeeper.Text, "name"); br.BAgent = this.name2ID(Empdt, _user, "name"); br.Borrower = this.cbxborrower.SelectedValue.ToString(); br.BDate = this.dtpBDate.Value; br.RDate = this.dtpRDate.Value; br.bRemark = this.textBorrowRemark.Text; bool flag; if (updata_flag) { flag = BoroowMgr.BUpdate(ID, br); } else { if (IsEqAvailable(this.textEqNO.Text)) { if (_power == "0" || _power == "1") { flag = BoroowMgr.AddWithoutVerify(br); } else { flag = BoroowMgr.Add(br); } flag = EqMgr.BorrowEq(br.EqNo); if (flag) { untCommon.InfoMsg("出借成功。"); } else { untCommon.InfoMsg("出借失败。"); } } else { untCommon.InfoMsg("该资产状态已改变,无法修改该信息。"); } } this.DialogResult = DialogResult.OK; }
/// <summary> /// 加载资产的资料; /// </summary> private void LoadEqInfo() { DataTable dt = EqMgr.GetOneEqInfo(this._eqno); if (dt != null) { this.textSerialNO.Text = DateTime.Now.ToString("yyyyMMddHHmmss"); this.textEqNO.Text = dt.Rows[0]["EqNo"].ToString(); this.textName.Text = dt.Rows[0]["EqName"].ToString(); this.textKeepPlace.Text = dt.Rows[0]["KeepPlace"].ToString(); this.textDepartment.Text = DepartMgr.GetNameFromId(dt.Rows[0]["Department"].ToString()); this.textKeeper.Text = dt.Rows[0]["EqKeeper"].ToString(); } }
private void AddThdDepart() { int flag = 0; string departId = ""; string parentId = ""; //GetNodes(RootNode); for (int i = 0; i < newsubdepartlist.Count; i++) { if (newsubdepartlist[i].ToString() == "请输入新部门名称") { flag++; } } if (flag > 0) { untCommon.ErrorMsg("添加失败,请输入合法的部门名称。"); return; } else { for (int i = 0; i < newsubdepartlist.Count; i += 2) { parentId = newsubdepartlist[i + 1].ToString(); departId = string.Format("{0:000}", DepartMgr.ThirdCount() + 1); departId = parentId.Substring(0, 2) + departId; //循环向数据库中添加 if (DepartMgr.Add(departId, newsubdepartlist[i].ToString(), parentId)) { flag = 0; tvwDepart.LabelEdit = false;//关闭节点编辑 tvwDepart.Nodes.Clear(); btnCancel.Enabled = false; btnSave.Enabled = false; btnUpdate.Enabled = true; btnDel.Enabled = true; btnAddSub.Enabled = true; this.BuidTree(); } else { untCommon.InfoMsg(newdepartlist[i].ToString() + " 添加失败。"); } } } }
/// <summary> /// 构造本单位树的三级部门节点 /// </summary> /// <param name="parent"></param> private void BuildThirdDepart(TreeNode parent) { string parentId = parent.Tag.ToString(); DataTable dt = DepartMgr.GetThirdOrder(parentId); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { TreeNode depart = new TreeNode(); depart.Text = dt.Rows[i][1].ToString(); depart.Tag = dt.Rows[i][0].ToString(); depart.ImageIndex = 1; depart.SelectedImageIndex = 1; parent.Nodes.Add(depart); } } }
/// <summary> /// 构造本单位树的部门节点 /// </summary> /// <param name="parent"></param> /// private void BuildNodesDepart(TreeNode parent) { DataTable dt = DepartMgr.GetAll(); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { TreeNode depart = new TreeNode(); depart.Text = dt.Rows[i][1].ToString(); depart.Tag = dt.Rows[i][0].ToString(); depart.ImageIndex = 1; depart.SelectedImageIndex = 1; parent.Nodes.Add(depart); } tvwDepart.ExpandAll(); } }
/// <summary> /// 初始化部门列表 /// </summary> private void InitDepaert() { DataTable dt = DepartMgr.GetAll(); if (dt != null) { //初始化新员工注册界面的部门列表 this.cbxNewDepart.Items.Clear(); this.cbxNewDepart.DataSource = dt; this.cbxNewDepart.DisplayMember = dt.Columns[1].ToString(); this.cbxNewDepart.ValueMember = dt.Columns[0].ToString(); //初始化修改信息界面的部门列表 this.cbxDepart.Items.Clear(); this.cbxDepart.DataSource = dt; this.cbxDepart.DisplayMember = dt.Columns[1].ToString(); this.cbxDepart.ValueMember = dt.Columns[0].ToString(); } }
private void AddSecondDepart() { int flag = 0; string departId = ""; for (int i = 0; i < newdepartlist.Count; i++) { if (newdepartlist[i].ToString() == "请输入新部门名称") { flag++; } } if (flag > 0) { untCommon.ErrorMsg("添加失败,请输入合法的部门名称。"); return; } else { for (int i = 0; i < newdepartlist.Count; i++) { departId = string.Format("{0:00}", DepartMgr.SecondCount() + 1) + "000"; //循环向数据库中添加 if (DepartMgr.Add(departId, newdepartlist[i].ToString(), "0")) { flag = 0; tvwDepart.LabelEdit = false;//关闭节点编辑 tvwDepart.Nodes.Clear(); btnCancel.Enabled = false; btnSave.Enabled = false; btnUpdate.Enabled = true; btnDel.Enabled = true; btnAddSub.Enabled = true; this.BuidTree(); } else { untCommon.InfoMsg(newdepartlist[i].ToString() + " 添加失败。"); } } } }
/// <summary> /// 出示化部门节点 /// </summary> /// <param name="parent">父节点</param> private void InitTreeDepart(TreeNode parent) { DataTable dt = DepartMgr.GetAll(); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { TreeNode deprt = new TreeNode(); deprt.Text = dt.Rows[i][1].ToString(); deprt.Tag = dt.Rows[i][0].ToString(); deprt.ImageIndex = 1; deprt.SelectedImageIndex = 1; parent.Nodes.Add(deprt); this.InitEmp(int.Parse(deprt.Tag.ToString()), deprt);//加载树员工节点 } } }
private void AddDepart() { int flag = 0; GetNodes(RootNode); for (int i = 0; i < newdepartlist.Count; i++) { if (newdepartlist[i].ToString() == "请输入新部门名称") { flag++; } } if (flag > 0) { untCommon.ErrorMsg("添加失败,请输入合法的部门名称。"); return; } else { for (int i = 0; i < newdepartlist.Count; i++) { //循环向数据库中添加 if (DepartMgr.Add(newdepartlist[i].ToString())) { flag = 0; tvwDepart.LabelEdit = false;//关闭节点编辑 tvwDepart.Nodes.Clear(); btnCancel.Enabled = false; btnSave.Enabled = false; btnUpdate.Enabled = true; btnDel.Enabled = true; this.contextMenuStrip1.Items[2].Enabled = true; this.contextMenuStrip1.Items[4].Enabled = true; this.BuidTree(); } else { untCommon.InfoMsg(newdepartlist[i].ToString() + " 添加失败。"); } } } }
/// <summary> /// 向数据库中跟新数据 /// </summary> private void Updatedepart() { selecttxt = tvwDepart.SelectedNode.Text; if (DepartMgr.Update(tvwDepart.SelectedNode.Text, tvwDepart.SelectedNode.Tag.ToString())) { // untCommon.InfoMsg("修改成功。"); btnSave.Enabled = false; btnUpdate.Enabled = true; btnAdd.Enabled = true; btnAddSub.Enabled = true; tvwDepart.LabelEdit = false; btnDel.Enabled = true; } else { untCommon.InfoMsg("修改失败。"); tvwDepart.SelectedNode.Text = selecttxt; tvwDepart.SelectedNode.BeginEdit(); } }
/// <summary> /// 向数据库中跟新数据 /// </summary> private void Updatedepart() { selecttxt = tvwDepart.SelectedNode.Text; if (DepartMgr.Update(tvwDepart.SelectedNode.Text, int.Parse(tvwDepart.SelectedNode.Tag.ToString()))) { // untCommon.InfoMsg("修改成功。"); btnSave.Enabled = false; btnUpdate.Enabled = true; btnAdd.Enabled = true; tvwDepart.LabelEdit = false; btnDel.Enabled = true; this.contextMenuStrip1.Items[0].Enabled = true; this.contextMenuStrip1.Items[2].Enabled = true; } else { untCommon.InfoMsg("修改失败。"); tvwDepart.SelectedNode.Text = selecttxt; tvwDepart.SelectedNode.BeginEdit(); } }
private void btnOK_Click(object sender, EventArgs e) { Fix fix = new Fix(); fix.ID = this.textSerialNO.Text; fix.EqNo = this.textEqNO.Text; fix.EqName = this.textName.Text; DataTable Empdt = EmployeeMgr.GetAllName(); DataTable Depdt = DepartMgr.GetAllDepartment(); fix.Department = this.name2ID(Depdt, this.textDepartment.Text, "departName"); fix.KeepPlace = this.textKeepPlace.Text; fix.Keeper = this.name2ID(Empdt, this.textKeeper.Text, "name"); fix.Maintainer = this.cbxMaintainer.Text; fix.MAgent = this.name2ID(Empdt, _user, "name"); fix.MDate = this.dtpMDate.Value; fix.RDate = this.dtpRDate.Value; fix.mRemark = this.textFixRemark.Text; bool flag; if (updata_flag) { flag = FixMgr.MUpdate(ID, fix); if (flag) { untCommon.InfoMsg("修改成功。"); } else { untCommon.InfoMsg("修改失败。"); } } else { if (IsEqAvailable(this.textEqNO.Text)) { if (_power == "0" || _power == "1") { flag = FixMgr.AddWithoutVerify(fix); } else { flag = FixMgr.Add(fix); } flag = EqMgr.FixEq(fix.EqNo); if (flag) { untCommon.InfoMsg("送修成功。"); } else { untCommon.InfoMsg("送修失败。"); } } else { untCommon.InfoMsg("该资产状态已改变,无法修改该信息。"); } } this.DialogResult = DialogResult.OK; }
/// <summary> /// 检查输入是否合法 /// </summary> /// <returns></returns> private bool checkInput() { if (this.txtEqName.Text.Trim() == "") { untCommon.InfoMsg("请输入资产名称"); return(false); } if (this.cbxEqType.Text.Trim() == "") { untCommon.InfoMsg("请选择资产类别"); return(false); } if (this.txtGB.Text.Trim() == "") { untCommon.InfoMsg("请输入国标码"); return(false); } if (this.txtCount.Text.Trim() == "") { untCommon.InfoMsg("请输入资产的数量。"); return(false); } if (this.txtPrice.Text.Trim() == "") { untCommon.InfoMsg("请输入资产的价值。"); return(false); } if (this.txtDepartment.Text.Trim() == "") { untCommon.InfoMsg("请输入部门名称"); return(false); } else { string depart = DepartMgr.GetIdFromName(this.txtDepartment.Text); if (depart == "") { untCommon.InfoMsg("没有这个部门"); return(false); } } if (double.Parse(this.txtPrice.Text) <= 0) { untCommon.InfoMsg("价值请输入大于零的数字"); return(false); } if (int.Parse(this.txtCount.Text) <= 0) { untCommon.InfoMsg("价值请输入大于零的数字"); return(false); } if (this.txtUSDPrice.Text.Trim() != "" && double.Parse(this.txtUSDPrice.Text) <= 0) { untCommon.InfoMsg("美金单价请输入大于零的数字"); return(false); } if (this.txtArea.Text.Trim() != "" && double.Parse(this.txtArea.Text) <= 0) { untCommon.InfoMsg("土地/建筑面积请输入大于零的数字"); return(false); } if (this.txtTenuArea.Text.Trim() != "" && double.Parse(this.txtTenuArea.Text) <= 0) { untCommon.InfoMsg("自用面积请输入大于零的数字"); return(false); } if (this.txtTenuPrice.Text.Trim() != "" && double.Parse(this.txtTenuPrice.Text) <= 0) { untCommon.InfoMsg("自用价值请输入大于零的数字"); return(false); } if (this.txtCertLim.Text.Trim() != "" && double.Parse(this.txtCertLim.Text) <= 0) { untCommon.InfoMsg("权属年限请输入大于零的数字"); return(false); } return(true); }
/// <summary> /// 初始化资产信息表 /// </summary> private void DataLoad() { DataTable dt = EqMgr.GetOneEqInfo(this.eqno); if (dt != null && dt.Rows.Count != 0) { this.txtEqNo.Text = this.eqno; this.txtEqName.Text = dt.Rows[0][1].ToString(); this.txtEduNo.Text = dt.Rows[0][2].ToString(); this.txtAssetNo.Text = dt.Rows[0][3].ToString(); this.cbxEqType.Text = dt.Rows[0][4].ToString(); this.txtGB.Text = dt.Rows[0][5].ToString(); this.cbxCampus.Text = dt.Rows[0][28].ToString(); DataTable Depdt = DepartMgr.GetAllDepartment(); this.txtDepartment.Text = this.ID2name(Depdt, dt.Rows[0][26].ToString(), "id"); //第8位是部门的id,这里不显示 this.cbxKeepPlace.Text = dt.Rows[0][29].ToString(); this.cbxEqKeeper.Text = dt.Rows[0][25].ToString(); this.cbxPurchaser.Text = dt.Rows[0][13].ToString(); this.txtAgent.Text = dt.Rows[0][14].ToString(); this.cbxUnit.Text = dt.Rows[0][7].ToString(); this.cbxFunds.Text = dt.Rows[0][32].ToString(); this.cbxPriceType.Text = dt.Rows[0][22].ToString(); this.txtPrice.Text = dt.Rows[0][23].ToString(); this.txtUSDPrice.Text = dt.Rows[0][24].ToString(); this.txtBrand.Text = dt.Rows[0][15].ToString(); this.txtModel.Text = dt.Rows[0][16].ToString(); this.txtCountry.Text = dt.Rows[0][17].ToString(); this.txtMfrs.Text = dt.Rows[0][18].ToString(); this.txtProductNo.Text = dt.Rows[0][19].ToString(); this.txtSupplier.Text = dt.Rows[0][21].ToString(); this.cbxUsage.Text = dt.Rows[0][6].ToString(); this.cbxDirection.Text = dt.Rows[0][8].ToString(); this.cbxBuyWay.Text = dt.Rows[0][9].ToString(); this.cbxGetWay.Text = dt.Rows[0][10].ToString(); this.txtCN.Text = dt.Rows[0][30].ToString(); this.txtInvNo.Text = dt.Rows[0][31].ToString(); this.cbxRelicLv.Text = dt.Rows[0][33].ToString(); this.txtRegAuz.Text = dt.Rows[0][34].ToString(); this.txtPatNo.Text = dt.Rows[0][36].ToString(); this.txtApvNo.Text = dt.Rows[0][37].ToString(); this.txtMgtAgency.Text = dt.Rows[0][38].ToString(); this.cbxCarUse.Text = dt.Rows[0][39].ToString(); this.cbxCarBP.Text = dt.Rows[0][40].ToString(); this.txtLicNo.Text = dt.Rows[0][41].ToString(); this.txtDSPL.Text = dt.Rows[0][42].ToString(); this.txtEngNo.Text = dt.Rows[0][43].ToString(); this.cbxFormation.Text = dt.Rows[0][44].ToString(); this.txtArea.Text = dt.Rows[0][45].ToString(); this.cbxPR.Text = dt.Rows[0][46].ToString(); this.txtCertNo.Text = dt.Rows[0][47].ToString(); this.txtCertLim.Text = dt.Rows[0][49].ToString(); this.txtCertProve.Text = dt.Rows[0][50].ToString(); this.txtAddress.Text = dt.Rows[0][51].ToString(); this.cbxCertNature.Text = dt.Rows[0][52].ToString(); this.txtTenuArea.Text = dt.Rows[0][53].ToString(); this.txtTenuPrice.Text = dt.Rows[0][54].ToString(); this.cbxStructure.Text = dt.Rows[0][55].ToString(); this.txtBelongTo.Text = dt.Rows[0][56].ToString(); //57是图片 this.txtRemark.Text = dt.Rows[0][59].ToString(); if (dt.Rows[0][11].ToString() != "") { this.dtpGetDate.Value = DateTime.Parse(dt.Rows[0][11].ToString()); this.dtpGetDate.Checked = true; } if (dt.Rows[0][12].ToString() != "") { this.dtpAddDate.Value = DateTime.Parse(dt.Rows[0][12].ToString()); this.dtpAddDate.Checked = true; } if (dt.Rows[0][20].ToString() != "") { this.dtpBirthday.Value = DateTime.Parse(dt.Rows[0][20].ToString()); this.dtpBirthday.Checked = true; } if (dt.Rows[0][27].ToString() != "") { this.dtpSvcDate.Value = DateTime.Parse(dt.Rows[0][27].ToString()); this.dtpSvcDate.Checked = true; } if (dt.Rows[0][35].ToString() != "") { this.dtpRegTime.Value = DateTime.Parse(dt.Rows[0][35].ToString()); this.dtpRegTime.Checked = true; } if (dt.Rows[0][48].ToString() != "") { this.dtpIssueDate.Value = DateTime.Parse(dt.Rows[0][48].ToString()); this.dtpIssueDate.Checked = true; } } DataTable dtPhoto = EqMgr.GetPhoto(this.eqno); MemoryStream photoStream; if (dtPhoto != null) { if (!(dtPhoto.Rows[0][0] is DBNull)) { byte[] imageBytes = (byte[])(dtPhoto.Rows[0][0]); if (imageBytes == null || imageBytes.Length == 0) { return; } photoStream = new MemoryStream(imageBytes, 0, imageBytes.Length); this.pbPhoto.Image = Image.FromStream(photoStream); } else { this.pbPhoto.Image = null; } } else { this.pbPhoto.Image = null; } }
//保存修改的信息 private void toolEqUpdate_Click(object sender, EventArgs e) { if (this.checkInput()) { Equipment eq = new Equipment(); eq.EqNo = this.txtEqNo.Text; eq.EqName = this.txtEqName.Text; eq.AssetNo = this.txtAssetNo.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 = ""; eq.Remark = this.txtRemark.Text; eq.Photo = this.getPhotoPath(); 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; } //判断更新模式 switch (this.mode) { case 0: this.DialogResult = DialogResult.OK; break; //直接修改 case 1: { int error = 0; //0级和1级用户直接更新 if (_power == "0" || _power == "1") { foreach (string field in eqnoList) { eq.EqNo = field; eq.State = "入库"; if (EqMgr.Update(eq)) { // } else { error++; } } if (error == 0) { untCommon.InfoMsg("更新成功"); this.DialogResult = DialogResult.OK; this.Close(); } else { untCommon.InfoMsg("操作失败,失败数目为:" + error.ToString()); this.DialogResult = DialogResult.OK; this.Close(); } } else { DataTable Empdt = EmployeeMgr.GetAllName(); foreach (string field in eqnoList) { eq.EqNo = "U" + this.Loginid + DateTime.Now.ToString("yyyyMMddHHmmss") + field; eq.State = "更新待审核"; if (EqMgr.Add(eq)) { // } else { error++; } } if (error == 0) { untCommon.InfoMsg("更新成功,请等待审核"); this.DialogResult = DialogResult.OK; this.Close(); } else { untCommon.InfoMsg("操作失败,失败数目为:" + error.ToString()); this.DialogResult = DialogResult.OK; this.Close(); } } break; } //直接批量修改 case 2: { string question = "确定要更改这单数量为: "; question += EqMgr.AssetCount(this.asset).ToString() + " 的资产吗?"; if (untCommon.QuestionMsg(question)) { if (_power == "0" || _power == "1") { eq.State = "入库"; if (EqMgr.UpdateByAsset(eq, asset)) { untCommon.InfoMsg("更新成功"); this.DialogResult = DialogResult.OK; this.Close(); } else { untCommon.InfoMsg("更新失败。"); this.DialogResult = DialogResult.OK; this.Close(); } } else { List <string> list = EqMgr.GetEqNoByAssetNo(this.asset); DataTable Empdt = EmployeeMgr.GetAllName(); int error = 0; if (list != null) { foreach (string field in list) { eq.EqNo = "U" + this.name2ID(Empdt, this._user, "name") + DateTime.Now.ToString("yyyyMMddHHmmss") + field; eq.State = "更新待审核"; if (EqMgr.Add(eq)) { } else { error++; } } } if (error == 0) { untCommon.InfoMsg("更新信息提交成功,请等待审核"); this.DialogResult = DialogResult.OK; this.Close(); } else { untCommon.InfoMsg("更新信息发生错误\n" + "失败数为: " + error.ToString()); this.DialogResult = DialogResult.OK; this.Close(); } } } break; } //从新增审核处修改 case 3: { eq.State = "新增待审核"; if (EqMgr.UpdateByAsset(eq, asset)) { untCommon.InfoMsg("更新信息提交成功,请等待审核"); this.DialogResult = DialogResult.OK; this.Close(); } else { untCommon.InfoMsg("更新失败。"); this.DialogResult = DialogResult.OK; this.Close(); } break; } //从更新审核处修改 case 4: { int error = 0; DataTable Empdt = EmployeeMgr.GetAllName(); foreach (string field in eqnoList) { eq.EqNo = field; eq.State = "更新待审核"; if (EqMgr.Update(eq)) { // } else { error++; } } if (error == 0) { untCommon.InfoMsg("更新成功,请等待审核"); this.DialogResult = DialogResult.OK; this.Close(); } else { untCommon.InfoMsg("操作失败,失败数目为:" + error.ToString()); this.DialogResult = DialogResult.OK; this.Close(); } break; } } } }
private void btnOk_Click(object sender, EventArgs e) { if (view_only) { untCommon.InfoMsg("当前无法修改。"); } else { Clear clear = new Clear(); clear.ID = this.textSerialNO.Text; clear.EqNo = this.textEqNO.Text; clear.EqName = this.textName.Text; DataTable Empdt = EmployeeMgr.GetAllName(); DataTable Depdt = DepartMgr.GetAllDepartment(); clear.Department = this.name2ID(Depdt, this.textDepartment.Text, "departName"); clear.KeepPlace = this.textKeepPlace.Text; clear.Keeper = this.name2ID(Empdt, this.textKeeper.Text, "name"); clear.CType = this.cbxClearType.Text; clear.CAgent = this.name2ID(Empdt, _user, "name"); clear.CDate = this.dtpDate.Value; clear.Remark = this.textRemark.Text; bool flag; if (updata_flag) { flag = ClearMgr.CUpdate(ID, clear); if (flag) { untCommon.InfoMsg("修改成功。"); } else { untCommon.InfoMsg("修改失败。"); } } else { if (IsEqAvailable(this.textEqNO.Text)) { if (_power == "0" || _power == "1") { flag = ClearMgr.AddWithoutVerify(clear); untCommon.InfoMsg("注销成功。"); } else { flag = ClearMgr.Add(clear); untCommon.InfoMsg("注销成功待审核。"); } flag = EqMgr.ClearEq(clear.EqNo); if (!flag) { untCommon.InfoMsg("注销失败。"); } } else { untCommon.InfoMsg("该资产状态已改变,无法修改该信息。"); } } this.DialogResult = DialogResult.OK; } }
/// <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(); } } }