/// <summary> /// 保存单位 /// </summary> /// <returns></returns> private void SaveUnit() { List <T_Units> unitMDL = new List <T_Units>(); T_Units_BLL units_bll = new T_Units_BLL(); unitMDL.Add(new T_Units() { dwmc = this.txtJsdw.Text, ProjectNO = this.txtProjectNo.Text, unittype = "unit1", UnitID = Guid.NewGuid().ToString() }); unitMDL.Add(new T_Units() { dwmc = this.txtSjdw.Text, ProjectNO = this.txtProjectNo.Text, unittype = "unit3", UnitID = Guid.NewGuid().ToString() }); unitMDL.Add(new T_Units() { dwmc = this.txtSgdw.Text, ProjectNO = this.txtProjectNo.Text, unittype = "unit4", UnitID = Guid.NewGuid().ToString() }); unitMDL.Add(new T_Units() { dwmc = this.txtJldw.Text, ProjectNO = this.txtProjectNo.Text, unittype = "unit6", UnitID = Guid.NewGuid().ToString() }); unitMDL.Add(new T_Units() { dwmc = this.txtKcdw.Text, ProjectNO = this.txtProjectNo.Text, unittype = "unit2", UnitID = Guid.NewGuid().ToString() }); unitMDL.Add(new T_Units() { dwmc = this.txtLxpzdw.Text, ProjectNO = this.txtProjectNo.Text, unittype = "unit15", UnitID = Guid.NewGuid().ToString() }); foreach (var item in unitMDL) { if (units_bll.Exists1(item)) { units_bll.Updates(item); } else { units_bll.Insert(item); } } }
private void btnConfirm_Click(object sender, EventArgs e) { if (string.Compare(cboUnittype.SelectedValue.ToString(), "unit12", true) == 0 || string.Compare(cboUnittype.SelectedValue.ToString(), "unit13", true) == 0) { if (txtOther.Text.Trim() == "") { TXMessageBoxExtensions.Info("请填写姓名!"); txtOther.Focus(); return; } } else { if (txtDwmc.Text.Trim() == "") { TXMessageBoxExtensions.Info("单位名称必须填写!"); txtDwmc.Focus(); return; } } T_Units_BLL unitBLL = new T_Units_BLL(); T_Units unitsList = new T_Units(); unitsList.ProjectNO = ProjectNO; unitsList.unittype = this.cboUnittype.SelectedValue.ToString(); DataSet ds = unitBLL.GetList(unitsList); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { TXMessageBoxExtensions.Info("该工程已经存在相同类型单位,不能重复添加!"); return; } } this.DialogResult = DialogResult.OK; }