Example #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (Dgv1.Rows.Count == 0)
            {
                TXMessageBoxExtensions.Info("没有可编辑的数据!");
                return;
            }
            if (Dgv1.CurrentRow.Index < 0)
            {
                TXMessageBoxExtensions.Info("请选择一行数据进行编辑!");
                return;
            }
            string unitid   = Dgv1.Rows[Dgv1.CurrentRow.Index].Cells[0].Value.ToString(); //当前unitid
            string unitType = Dgv1.Rows[Dgv1.CurrentRow.Index].Cells[1].Value.ToString(); //当前单位类型
            //BUG修复20170420,如果不选择左侧的单位类型会导致编辑传过去的单位类型为空,改为如果为空则传当前选中行的单位类型
            frmUnit      frm = new frmUnit(txtUnittype.Text == "" ? unitType : txtUnittype.Text, txtProjectNo.Text, unitid);
            DialogResult ret = frm.ShowDialog();  //open

            if (ret == DialogResult.OK)
            {
                MDL.T_Units unitMDL  = (new ERM.BLL.T_Units_BLL()).Find(unitid);
                string      unittype = frm.cboUnittype.SelectedValue.ToString();
                unitMDL.unittype = unittype;
                if (string.Compare(unittype, "unit12", true) == 0 || string.Compare(unittype, "unit13", true) == 0)
                {
                    unitMDL.dwmc   = frm.label5.Text;
                    unitMDL.fzr    = MyCommon.ToSqlString(frm.txtOther.Text.Trim());
                    unitMDL.fzrzs  = string.Empty;
                    unitMDL.xmjl   = string.Empty;
                    unitMDL.zzdj   = string.Empty;
                    unitMDL.zzzh   = string.Empty;
                    unitMDL.addr   = string.Empty;
                    unitMDL.tel    = string.Empty;
                    unitMDL.fax    = string.Empty;
                    unitMDL.remark = string.Empty;
                }
                else
                {
                    unitMDL.dwmc   = MyCommon.ToSqlString(frm.txtDwmc.Text.Trim());
                    unitMDL.fzr    = MyCommon.ToSqlString(frm.txtFzr.Text.Trim());
                    unitMDL.fzrzs  = MyCommon.ToSqlString(frm.txtFzrzs.Text.Trim());
                    unitMDL.xmjl   = MyCommon.ToSqlString(frm.txtXmjl.Text.Trim());
                    unitMDL.zzdj   = MyCommon.ToSqlString(frm.txtZzdj.Text.Trim());
                    unitMDL.zzzh   = MyCommon.ToSqlString(frm.txtZzzh.Text.Trim());
                    unitMDL.addr   = MyCommon.ToSqlString(frm.txtAddr.Text.Trim());
                    unitMDL.tel    = MyCommon.ToSqlString(frm.txtTel.Text.Trim());
                    unitMDL.fax    = MyCommon.ToSqlString(frm.txtFax.Text.Trim());
                    unitMDL.remark = MyCommon.ToSqlString(frm.txtRemark.Text.Trim());
                }
                (new ERM.BLL.T_Units_BLL()).Update(unitMDL);
                this.LoadDataFromView(txtUnittype.Text);
            }
        }
Example #2
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtProjectNo.Text.Trim()))
            {
                TXMessageBoxExtensions.Info("请先填写工程编号!");
                this.tabControl1.SelectedTab = tabPage1;
                this.txtProjectNo.Focus();
                return;
            }
            frmUnit frm = new frmUnit(txtUnittype.Text, txtProjectNo.Text, "");

            DialogResult ret = frm.ShowDialog();

            if (ret == DialogResult.OK)
            {
                string      unittype = frm.cboUnittype.SelectedValue.ToString();
                MDL.T_Units unitMDL  = new ERM.MDL.T_Units();
                unitMDL.UnitID    = Guid.NewGuid().ToString();
                unitMDL.unittype  = unittype;
                unitMDL.ProjectNO = txtProjectNo.Text;
                if (string.Compare(unittype, "unit12", true) == 0 || string.Compare(unittype, "unit13", true) == 0)
                {
                    unitMDL.dwmc   = frm.label5.Text;
                    unitMDL.fzr    = MyCommon.ToSqlString(frm.txtOther.Text.Trim());
                    unitMDL.fzrzs  = string.Empty;
                    unitMDL.xmjl   = string.Empty;
                    unitMDL.zzdj   = string.Empty;
                    unitMDL.zzzh   = string.Empty;
                    unitMDL.addr   = string.Empty;
                    unitMDL.tel    = string.Empty;
                    unitMDL.fax    = string.Empty;
                    unitMDL.remark = string.Empty;
                }
                else
                {
                    unitMDL.dwmc   = MyCommon.ToSqlString(frm.txtDwmc.Text.Trim());
                    unitMDL.fzr    = MyCommon.ToSqlString(frm.txtFzr.Text.Trim());
                    unitMDL.fzrzs  = MyCommon.ToSqlString(frm.txtFzrzs.Text.Trim());
                    unitMDL.xmjl   = MyCommon.ToSqlString(frm.txtXmjl.Text.Trim());
                    unitMDL.zzdj   = MyCommon.ToSqlString(frm.txtZzdj.Text.Trim());
                    unitMDL.zzzh   = MyCommon.ToSqlString(frm.txtZzzh.Text.Trim());
                    unitMDL.addr   = MyCommon.ToSqlString(frm.txtAddr.Text.Trim());
                    unitMDL.tel    = MyCommon.ToSqlString(frm.txtTel.Text.Trim());
                    unitMDL.fax    = MyCommon.ToSqlString(frm.txtFax.Text.Trim());
                    unitMDL.remark = MyCommon.ToSqlString(frm.txtRemark.Text.Trim());
                }
                (new BLL.T_Units_BLL()).Add(unitMDL);
                this.LoadDataFromView(txtUnittype.Text);
            }
        }