示例#1
0
文件: fmUnit.cs 项目: tanzw/114-
 private void btnDel_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count == 0)
     {
         MessageBox.Show("请选择您要删除的记录!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         if (MessageBox.Show("确定删除?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
         {
             Code.Services.UnitService service = new Code.Services.UnitService();
             Code.Common.Result        result  = service.CheckHasUser(int.Parse(lbRowID.Text));
             if (result.Status == Code.Common.ResultStatus.Success)
             {
                 if (service.Delete(int.Parse(lbRowID.Text)))
                 {
                     MessageBox.Show("删除成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     BindGridDataSource();
                     txtName.Text          = "";
                     txtPinyin.Text        = "";
                     cbbDict.SelectedIndex = -1;
                 }
                 else
                 {
                     MessageBox.Show("删除失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             else
             {
                 MessageBox.Show("删除失败," + result.Message, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
示例#2
0
文件: fmUnit.cs 项目: tanzw/114-
 public void BindGridDataSource()
 {
     Code.Services.UnitService service = new Code.Services.UnitService();
     foreach (DataGridViewColumn col in this.dataGridView1.Columns)
     {
         col.SortMode = DataGridViewColumnSortMode.NotSortable;
     }
     dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
     dataGridView1.RowsDefaultCellStyle.Alignment          = DataGridViewContentAlignment.MiddleCenter;
     dataGridView1.DataSource = service.GetDepartmentList();
     dataGridView1.SelectedRows[0].Selected = false;
 }
示例#3
0
文件: Form1.cs 项目: tanzw/114-
        private void BindUnit(string area = "")
        {
            Code.Services.UnitService service = new Code.Services.UnitService();
            dtUnit = service.GetDepartmentList();
            cbbUnit.DropDownStyle = ComboBoxStyle.DropDown;
            if (area == "")
            {
                cbbUnit.DataSource = dtUnit;
            }
            else
            {
                var unit = dtUnit.Where(x => x.Dict == area).OrderBy(x => x.ID).OrderBy(x => x.Code).ToList();
                cbbUnit.DataSource = unit;
            }

            cbbUnit.DisplayMember = "Department";
            cbbUnit.ValueMember   = "ID";
            cbbUnit.SelectedIndex = -1;
        }
示例#4
0
文件: fmUnit.cs 项目: tanzw/114-
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count == 0)
     {
         MessageBox.Show("请选择您要修改的记录!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         Code.Services.UnitService service = new Code.Services.UnitService();
         if (service.Update(int.Parse(lbRowID.Text), txtName.Text.Trim(), txtPinyin.Text.Trim(), cbbDict.SelectedValue.ToString()))
         {
             MessageBox.Show("修改成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             //BindGridDataSource();
             dataGridView1.CurrentRow.SetValues(dataGridView1.CurrentRow.Cells[0].Value, int.Parse(lbRowID.Text), txtName.Text.Trim(), cbbDict.SelectedValue.ToString(), txtPinyin.Text.Trim());
         }
         else
         {
             MessageBox.Show("修改失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }