public void BindDict() { Code.Services.DictService service = new Code.Services.DictService(); cbbDict.DataSource = service.GetDictList(); cbbDict.DisplayMember = "PlaceName"; cbbDict.ValueMember = "PlaceName"; }
private void btnSave_Click(object sender, EventArgs e) { Code.Services.DictService service = new Code.Services.DictService(); string distNo = txtDistNo.Text.Trim(); string code = txtCode.Text.Trim(); string area = txtArea.Text.Trim(); string pinyin = txtPinyin.Text.Trim(); if (string.IsNullOrWhiteSpace(area)) { MessageBox.Show("请输入地区!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (string.IsNullOrWhiteSpace(pinyin)) { MessageBox.Show("请输入简拼!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (string.IsNullOrWhiteSpace(distNo)) { MessageBox.Show("请输入区号!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (string.IsNullOrWhiteSpace(code)) { MessageBox.Show("请输入邮编!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } bool res = false; if (Status == 0) { res = service.AddDist(distNo, area, code, pinyin); } else { res = service.UpdateDist(distNo, area, code, pinyin, currentDistNo, currentArea); } if (res) { if (Status == 0) { BindGridDataSource(); } else { dataGridView1.CurrentRow.SetValues(area, distNo, code, pinyin); } MessageBox.Show("保存成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("保存失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void BindDist() { Code.Services.DictService service = new Code.Services.DictService(); cbbArea.DropDownStyle = ComboBoxStyle.DropDownList; DataTable dt = service.GetAreaList(); cbbArea.DataSource = dt; cbbArea.DisplayMember = "Name"; cbbArea.ValueMember = "Name"; cbbArea.SelectedIndex = -1; }
private void btnDel_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 0) { MessageBox.Show("请选择需要删除的记录!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Code.Services.DictService service = new Code.Services.DictService(); if (service.DelDist(currentDistNo, currentArea, currentCode, currentPinyin)) { BindGridDataSource(); MessageBox.Show("删除成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); txtArea.Text = ""; txtCode.Text = ""; txtDistNo.Text = ""; txtPinyin.Text = ""; } else { MessageBox.Show("删除失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void BindGridDataSource(string key = "") { Code.Services.DictService service = new Code.Services.DictService(); dataGridView1.DataSource = service.GetDictList2(key); }