/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { if (this.checkBox1.Checked) { Borrow br = new Borrow(); DataTable Empdt = EmployeeMgr.GetAllName(); br.RAgent = this.name2ID(Empdt, this._user, "name"); br.RDate = this.dtpBDate1.Value; br.rRemark = this.textRRemark.Text; string eqno = this.textEqNO.Text; if (_power == "0" || _power == "1") { bool flag = BoroowMgr.RUpdateWithoutVerify(_id, br); flag = EqMgr.ReturnEq(eqno); untCommon.InfoMsg("归还成功。"); } else { bool flag = BoroowMgr.RUpdate(_id, br); untCommon.InfoMsg("归还待审核。"); } } this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// 按照类型将DataGridView的内容筛选为DataTable /// </summary> /// <param name="dgv"></param> /// <param name="ppy">所要筛选的属性数组</param> /// <param name="type">类型</param> /// <returns></returns> public static DataTable GetTable(DataGridView dgv, List <string> headers, string type) { DataTable dt = new DataTable(); DataColumn dc; DataRow dr; //过滤用的字符串,比headers多的一列是“单号”,单号是过滤的依据 string[] filter = new string[headers.Count + 1]; //如果表头长度只为1,则直接返回一个空的dataTable if (headers.Count == 1) { return(dt); } //根据属性生成表头 for (int count = 0; count < headers.Count; count++) { filter[count] = headers[count]; dc = new DataColumn(headers[count]); dt.Columns.Add(dc); } //filter最后一列 filter[headers.Count] = "单号"; dc = new DataColumn("单号"); dt.Columns.Add(dc); for (int row = 0; row < dgv.Rows.Count; row++) { if (dgv["资产类别", row].Value.ToString() != type) { continue; } dr = dt.NewRow(); for (int index = 0; index < filter.Length; index++) { for (int column = 0; column < dgv.Columns.Count; column++) { if (dgv.Columns[column].HeaderText == filter[index]) { dr[index] = Convert.ToString(dgv.Rows[row].Cells[column].Value); } } } //总表里是没有数量这一列的,需要自行添加 dr["数量"] = EqMgr.AssetCount(dr["单号"].ToString()).ToString(); dt.Rows.Add(dr); } //根据单号去重 dt = GetDistinctSelf(dt, "单号"); dt.Columns.Remove("单号"); return(dt); }
/// <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(); } }
public static DataTable GetTable(DataTable dtsource, List <string> headers, string type) { DataTable dtInNeed = new DataTable(); DataTable dtThisType = new DataTable(); DataRow dr; //过滤用的字符串,比headers多的一列是“单号”,单号是过滤的依据 string[] filter = new string[headers.Count + 1]; //如果表头长度只为1,则直接返回一个空的dataTable if (headers.Count == 1) { return(dtInNeed); } for (int count = 0; count < headers.Count; count++) { filter[count] = headers[count]; } //filter最后一列 filter[headers.Count] = "单号"; //这一步是为了将dtsource的列名直接赋给dtThisType,缺少这一步的话dtThisType是没有列名的,也不能筛选 dtThisType = dtsource.Clone(); dtThisType.Clear(); for (int index = 0; index < dtsource.Rows.Count; index++) { if (dtsource.Rows[index]["资产类别"].ToString() != type) { continue; } dr = dtsource.Rows[index]; dr["数量"] = EqMgr.AssetCount(dtsource.Rows[index]["单号"].ToString()); dtThisType.ImportRow(dr); } dtInNeed = GetFilterTable(dtThisType, filter); dtInNeed = GetDistinctSelf(dtInNeed, "单号"); dtInNeed.Columns.Remove("单号"); return(dtInNeed); }
/// <summary> /// 自动生成资产编码 /// </summary> private static string SetEqNo() { string No = EqMgr.GetLastEqNo(); string yy = DateTime.Now.Year.ToString(); string eqno = ""; if (No != "") { //如果从数据库中查到有值,就在原有编号后自加1 eqno = (int.Parse(No) + 1).ToString(); } else { eqno = yy + "000001"; } return(eqno); }
public void GetInfo() { DataTable dt = EqMgr.GetOneBaseInfo(this._eqno); if (dt != null) { if (dt.Rows.Count != 0) { this.lblLabel.Text = dt.Rows[0][1].ToString(); this.lblPrice.Text = dt.Rows[0][2].ToString(); this.lblBirth.Text = dt.Rows[0][3].ToString(); this.lblModel.Text = dt.Rows[0][4].ToString(); this.lblPluse.Text = dt.Rows[0][5].ToString();//5%1%a%s%p%x this.lblUseTime.Text = dt.Rows[0][6].ToString(); this.lblMaker.Text = dt.Rows[0][7].ToString(); //将查出来的相片放在图片框内 const int oleTypeStart = 20; const int oleTypeLength = 12; MemoryStream photoStream; // MessageBox.Show(dt.Rows[0][16]) if (!(dt.Rows[0][8] is DBNull)) { byte[] imageBytes = (byte[])(dt.Rows[0][8]); if (imageBytes == null || imageBytes.Length == 0) { return; } string type = System.Text.Encoding.ASCII.GetString(imageBytes, oleTypeStart, oleTypeLength); photoStream = new MemoryStream(imageBytes, 0, imageBytes.Length); this.pictureBox1.Image = Image.FromStream(photoStream); } else { this.pictureBox1.Image = imageList1.Images[0]; } } } }
/// <summary> /// 导入Excel表格 /// </summary> /// <param name="filePath"></param> /// <returns></returns> public static bool ImportExcel(string filePath, string type) { Equipment eq; FileStream fileStream = new FileStream(@filePath, FileMode.Open); try { using (ExcelPackage package = new ExcelPackage(fileStream)) { for (int index = 1; index <= package.Workbook.Worksheets.Count; index++) { ExcelWorksheet sheet = package.Workbook.Worksheets[index]; for (int srow = sheet.Dimension.Start.Row + 1, erow = sheet.Dimension.End.Row; srow <= erow; srow++) { List <string> list = new List <string> { }; for (int scolumn = sheet.Dimension.Start.Column, ecolumn = sheet.Dimension.End.Column; scolumn <= ecolumn; scolumn++) { if (sheet.GetValue <string>(srow, scolumn) != null) { list.Add(sheet.GetValue <string>(srow, scolumn)); } else { list.Add(""); } } eq = EqMgr.SetEq(list); EqMgr.Add(eq); } } } fileStream.Close(); return(true); } catch (Exception e) { fileStream.Close(); return(false); } }
/// <summary> /// 按单号初始化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public frmEqUpdate(string _user, string Asset, string power, int update_mode) { InitializeComponent(); this.asset = Asset; if (update_mode == 2) { DataTable dt = EqMgr.GetAssetInfo(Asset); this.eqno = dt.Rows[0]["资产编码"].ToString(); } else { this.eqno = Asset.Replace('A', 'E'); } this._user = _user; this._power = power; this.mode = update_mode; SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景. SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲 }
/// <summary> /// 进入资产领用界面 /// </summary> private bool IsEqAvailable(string eqno) { DataTable dt = EqMgr.GetOneEqInfo(eqno); if (dt != null) { string status = dt.Rows[0]["State"].ToString(); if (status.Equals("入库")) { return(true); } else { return(false); } } else { return(false); } }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { if (this.checkBox1.Checked) { Fix fix = new Fix(); DataTable Empdt = EmployeeMgr.GetAllName(); fix.RAgent = this.name2ID(Empdt, this._user, "name"); fix.EqNo = this.textEqNO.Text; fix.RDate = this.dtpBDate1.Value; fix.rRemark = this.textRRemark.Text; if (_power == "0" || _power == "1") { bool flag = FixMgr.RUpdateWithoutVerify(_id, fix); flag = EqMgr.ReturnEq(fix.EqNo); } else { bool flag = FixMgr.RUpdate(_id, fix); } } this.DialogResult = DialogResult.OK; this.Close(); }
private void frmRemark_Load(object sender, EventArgs e) { if (view_only) { this.label1.Text = "审核意见:"; switch (tab_index) { case 0: textBox1.Text = EqMgr.GetAuditFromID(ID); break; case 1: textBox1.Text = ClearMgr.GetAuditFromID(ID); break; case 2: textBox1.Text = EqMgr.GetAuditFromID(ID); break; default: break; } } }
/// <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(); } } }
/// <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; } }
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; }