/// <summary> /// 修改数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripMenuItem_DataGridViewRowModify_Click(object sender, EventArgs e) { Form_WelderBelong_Update myForm = new Form_WelderBelong_Update(); myForm.myClass_WelderBelong = new Class_WelderBelong(); myForm.myClass_WelderBelong.WelderBelongID = (long )this.dataGridView_Data.CurrentRow.Cells["WelderBelongID"].Value; if (myForm.myClass_WelderBelong.FillData()) { myForm.bool_Add = false; if (myForm.ShowDialog() == DialogResult.OK) { Class_Data myClass_Data = (Class_Data)Class_Public.myHashtable[Enum_DataTable.WelderBelong.ToString()]; myClass_Data.RefreshData(true, this.myDataTable); this.RefreshData(true); } } else { MessageBox.Show("该行数据已被删除!"); } }
/// <summary> /// 添加数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripMenuItem_DataGridViewRowAdd_Click(object sender, EventArgs e) { if (this.myEventArgs_Unit == null || (string.IsNullOrEmpty(this.myEventArgs_Unit.EmployerHPID) && string.IsNullOrEmpty(this.myEventArgs_Unit.DepartmentHPID) && string.IsNullOrEmpty(this.myEventArgs_Unit.WorkPlaceHPID))) { MessageBox.Show("请选择单位!"); return; } Form_WelderBelong_Update myForm = new Form_WelderBelong_Update(); myForm.myClass_WelderBelong = new Class_WelderBelong(); myForm.myClass_WelderBelong.myClass_BelongUnit.EmployerHPID = this.myEventArgs_Unit.EmployerHPID; myForm.myClass_WelderBelong.myClass_BelongUnit.DepartmentHPID = this.myEventArgs_Unit.DepartmentHPID; myForm.myClass_WelderBelong.myClass_BelongUnit.WorkPlaceHPID = this.myEventArgs_Unit.WorkPlaceHPID; myForm.bool_Add = true; if (myForm.ShowDialog() == DialogResult.OK) { Class_Data myClass_Data = (Class_Data)Class_Public.myHashtable[Enum_DataTable.WelderBelong.ToString()]; this.dataGridView_Data.DataSource = null; myClass_Data.RefreshData(false, this.myDataTable); this.dataGridView_Data.DataSource = this.myDataView; this.RefreshData(false); Class_DataControlBind.SetDataGridViewSelectedPosition("WelderBelongID", myForm.myClass_WelderBelong.WelderBelongID.ToString(), this.dataGridView_Data); } }