Ejemplo n.º 1
0
 private void FrmSetInfoEdit_Load(object sender, EventArgs e)
 {
     if (_id != 0)
     {
         SetOrd model = _dal.GetModel(_id);
         txtSetText.Text      = model.SetOrdText;
         txtSetValue.Text     = model.SetOrdKey;
         txtSetValue.ReadOnly = true;
     }
 }
Ejemplo n.º 2
0
 private void btnDeleteOrd_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count == 0)
     {
         MessageBox.Show(@"请选择要删除的记录");
         return;
     }
     if (dataGridView1.CurrentRow != null)
     {
         int    id    = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString().Trim());
         SetOrd model = _ordDal.GetModel(id);
         model.State = 0;
         bool flag = _ordDal.Update(model);
         if (flag)
         {
             MessageBox.Show(@"删除成功");
             frmSetInfo_Load(null, null);
             dataGridView1_CellClick(null, null);
         }
     }
 }
Ejemplo n.º 3
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtSetValue.Text.Trim() == string.Empty)
     {
         MessageBox.Show(@"请输入代码");
         txtSetValue.Select();
         return;
     }
     if (txtSetText.Text.Trim() == string.Empty)
     {
         MessageBox.Show(@"请输入名称");
         txtSetText.Select();
         return;
     }
     if (_id != 0)//修改
     {
         //已经存在
         DataSet ds = _dal.GetList("State=1 and id!=" + _id + "  and SetOrdKey='" + txtSetValue.Text.Trim() + "' ");
         if (ds != null && ds.Tables[0].Rows.Count > 0)
         {
             MessageBox.Show(@"该代码已经存在");
             txtSetValue.Select();
         }
         else
         {
             SetOrd model = _dal.GetModel(_id);
             model.SetOrdKey  = txtSetValue.Text.Trim();
             model.SetOrdText = txtSetText.Text.Trim();
             bool flag = _dal.Update(model);
             if (flag)
             {
                 DialogResult = DialogResult.OK;
                 Close();
             }
         }
     }
     else
     {
         //已经存在
         DataSet ds = _dal.GetList("State=1   and  SetOrdKey='" + txtSetValue.Text.Trim() + "' ");
         if (ds != null && ds.Tables[0].Rows.Count > 0)
         {
             MessageBox.Show(@"该代码已经存在");
             txtSetValue.Select();
         }
         else
         {
             SetOrd model = new SetOrd
             {
                 SetOrdText = txtSetText.Text.Trim(),
                 SetOrdKey  = txtSetValue.Text.Trim(),
                 State      = 1
             };
             int res = _dal.Add(model);
             if (res >= 0)
             {
                 DialogResult = DialogResult.OK;
                 Close();
             }
         }
     }
 }