/// <summary> /// 删除数据类型信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDeleteTable_Click(object sender, EventArgs e) { DataTable dataTable = this.grdDataList.DataSource as DataTable; if (dataTable != null && dataTable.Rows.Count > 0) { DataRow[] selectedRows = dataTable.Select(string.Format("{0} = True", COMMON_FIELDS.FIELD_COMMON_CHECKED)); if (selectedRows.Length > 0) { this.SelectedData = selectedRows; } else { MessageService.ShowMessage("请选择数据!"); } if (SelectedData != null && SelectedData.Length > 0) { DataRow selectedRow = SelectedData[0]; #region insert new group name to table and add node to treeview if (MessageBox.Show(StringParser.Parse("${res:FanHai.Hemera.Addins.BasicData.BasicDataSettingTree.MsgDeleteTableTypeText}"), StringParser.Parse("${res:FanHai.Hemera.Addins.BasicData.BasicDataSettingTree.MsgDeleteTableTypeCaption}"), MessageBoxButtons.OKCancel) == DialogResult.OK) { try { //set value to entity baseAttributeCategoryEntity.CategoryKey = selectedRow[BASE_ATTRIBUTE_CATEGORY_FIELDS.FIELDS_CATEGORY_KEY].ToString().Trim(); //save data baseAttributeCategoryEntity.DeleteBaseCategory(); //check result if (baseAttributeCategoryEntity.ErrorMsg == "") { //重新加载数据 LoadData(); MessageBox.Show(StringParser.Parse("${res:FanHai.Hemera.Addins.BasicData.BasicDataSettingTree.MsgDeleteTableTypeSuccessfully}")); } else { MessageBox.Show(StringParser.Parse(baseAttributeCategoryEntity.ErrorMsg)); } } catch (Exception ee) { MessageBox.Show(ee.Message); } } #endregion } } }
/// <summary> /// DeleteDataType /// </summary> private void DeleteDataType(object sender, EventArgs e) { DataSet dataDsCategoryKey = new DataSet(); #region insert new group name to table and add node to treeview if (MessageBox.Show(StringParser.Parse("${res:FanHai.Hemera.Addins.BasicData.BasicDataSettingTree.MsgDeleteTableTypeText}"), StringParser.Parse("${res:FanHai.Hemera.Addins.BasicData.BasicDataSettingTree.MsgDeleteTableTypeCaption}"), MessageBoxButtons.OKCancel) == DialogResult.OK) { try { //set value to entity baseAttributeCategoryEntity.CategoryKey = tvBasicSettings.SelectedNode.Tag.ToString(); //save data baseAttributeCategoryEntity.DeleteBaseCategory(); //check result if (baseAttributeCategoryEntity.ErrorMsg == "") { //remove node //add by yanrong liu 2010-08-27 foreach (IViewContent viewContent in WorkbenchSingleton.Workbench.ViewContentCollection) { if (viewContent.TitleName == tvBasicSettings.SelectedNode.Text + StringParser.Parse("${res:FanHai.Hemera.Addins.BasicData.BasicSettingsViewContent.ViewContentPartTitle}")) { viewContent.WorkbenchWindow.CloseWindow(true); continue; } if (viewContent.TitleName == tvBasicSettings.SelectedNode.Text + StringParser.Parse("${res:FanHai.Hemera.Addins.BasicData.BasicSettingsDatViewContent.ViewContentPartTitle}")) { viewContent.WorkbenchWindow.CloseWindow(true); continue; } } //end tvBasicSettings.Nodes.Remove(tvBasicSettings.SelectedNode); MessageBox.Show(StringParser.Parse("${res:FanHai.Hemera.Addins.BasicData.BasicDataSettingTree.MsgDeleteTableTypeSuccessfully}")); } else { MessageBox.Show(StringParser.Parse(baseAttributeCategoryEntity.ErrorMsg)); } } catch (Exception ee) { MessageBox.Show(ee.Message); } } #endregion }