private void btnSave_Click(object sender, EventArgs e) { if (txtInput.Text == "" || txtInput.Text == "请输入新加项的内容") { UnitCommon.InfoMsg("请输入新添加项的内容!"); txtInput.Focus(); txtInput.SelectAll(); return; } Resources res = new Resources(); res.Name = txtInput.Text.Trim(); bool isOK = ResFactoryManager.Add(res, this.resType); if (isOK) { DataTable dt = ResFactoryManager.GetAllRes(resType); BindLstRes(dt); this.FormState = "查看"; } else { UnitCommon.ErrorMsg("保存资产信息失败!"); } }
private void btnDel_Click(object sender, EventArgs e) { if (lstInfo.SelectedIndex == -1) { return; //表示没有选择要删除的项 } Resources res = lstInfo.SelectedItem as Resources; if (res != null) { if (UnitCommon.ConfirmMsg("您确定要删除此条记录吗?")) { bool isok = ResFactoryManager.Del(res.Id, this.resType); if (isok) { DataTable dt = ResFactoryManager.GetAllRes(resType); this.BindLstRes(dt); this.FormState = "查看"; } else { UnitCommon.ErrorMsg("删除资产信息失败!"); } } } }
private void GetAllRes(object sender, EventArgs e) { //sender代表当前的button,即为btnName,获取btnName的Tag值 lblMessge.Text = ((Button)sender).Text.ToString(); resType = ((Button)sender).Tag.ToString(); DataTable dt = ResFactoryManager.GetAllRes(resType); this.BindLstRes(dt); }