/// <summary> /// 添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(textBox1.Text.Trim())) { KPS.Model.Manufacturer manufacterInfo = new Model.Manufacturer(); manufacterInfo.manufacturerName = textBox1.Text.Trim(); if (isSelUnit) { //调用BLL获取所有的用户列表 KPS.BLL.ManufacturerManager manager = new BLL.ManufacturerManager(); RecordList = manager.GetModelList(string.Format("manufacturerName like '%{0}%'", manufacterInfo.manufacturerName)); ReaLoadSpList();//重新加载列表 } else { //调用BLL获取所有的用户列表 KPS.BLL.ManufacturerManager manager = new BLL.ManufacturerManager(); if (manager.Add(manufacterInfo)) { manufacterInfo.manufacturerID = manager.GetMaxId(); } if (manufacterInfo.manufacturerID != null && manufacterInfo.manufacturerID != 0) { if (RecordList == null) { RecordList = new List<Manufacturer>(); } RecordList.Add(manufacterInfo); ReaLoadSpList(); MessageBox.Show("添加成功!"); } else { MessageBox.Show("添加失败!"); } } } else { MessageBox.Show("名称不可为空!"); } }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { if (!isSelUnit) { this.DialogResult = DialogResult.OK; } else { if (this._RecordListView.SelectedObjects != null && this._RecordListView.SelectedObjects.Count > 0) { selfacturerInfo = (Manufacturer)this._RecordListView.SelectedObjects[0]; this.DialogResult = DialogResult.OK; } else { MessageBox.Show("您未选择任何项,请选择对应项后再试!"); } } }