//确定 private void btnOK_Click(object sender, EventArgs e) { try { string tname = this.txtTemplateName.Text.Trim(); if (tname != "") { string sql = "update t_tempplate set tname='" + tname + "' where tid='" + current_id + "'"; int num = App.ExecuteSQL(sql); if (num > 0) { App.Msg("更新成功!"); //对模板界面设置 if (templateManage.GetType().ToString().Contains("ucTemplateManagement_Small")) { ucTemplateManagement_Small temp = (ucTemplateManagement_Small)templateManage; temp.treeView1.SelectedNode.Text = tname; } else { ucTemplateManagement temp = (ucTemplateManagement)templateManage; temp.treeView1.SelectedNode.Text = tname; } } else { App.Msg("更新失败!"); } this.Close(); } else { App.Msg("模板名称不能为空!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnOK_Click(object sender, EventArgs e) { TreeNode parentNode; if (templateManage.GetType().ToString().Contains("ucTemplateManagement_Small")) { ucTemplateManagement_Small temp = (ucTemplateManagement_Small)templateManage; parentNode = temp.treeView1.SelectedNode; } else { ucTemplateManagement temp = (ucTemplateManagement)templateManage; parentNode = temp.treeView1.SelectedNode; } ArrayList Sqls = new ArrayList(); Sqls.Add("delete from t_tempplate_section where TEMPLATE_ID=" + current_id + ""); Sqls.Add("update t_tempplate set TEMPPLATE_LEVEL='S' where TID=" + current_id + ""); for (int i = 0; i < dataGridViewX1.Rows.Count; i++) { DataGridViewCheckBoxCell sc = dataGridViewX1["科室", i] as DataGridViewCheckBoxCell; if (sc.Value != null) { if (sc.Value.ToString() == "true") { DataGridViewCheckBoxCell sc2 = dataGridViewX1["默认科室", i] as DataGridViewCheckBoxCell; if (sc2.Value != null) { if (sc2.Value.ToString() == "true") { ucTemplateManagement.isSecDefault = "true"; Sqls.Add("insert into t_tempplate_section(TEMPLATE_ID,SECTION_ID,ISDEFAULT)values(" + current_id + "," + dataGridViewX1["科室主键", i].Value.ToString() + ",'Y')"); } else { Sqls.Add("insert into t_tempplate_section(TEMPLATE_ID,SECTION_ID,ISDEFAULT)values(" + current_id + "," + dataGridViewX1["科室主键", i].Value.ToString() + ",'N')"); } } else { Sqls.Add("insert into t_tempplate_section(TEMPLATE_ID,SECTION_ID,ISDEFAULT)values(" + current_id + "," + dataGridViewX1["科室主键", i].Value.ToString() + ",'N')"); } } } } Sqls.Add("delete from T_TEMPPLATE_GROUP where TEMPLATE_ID=" + current_id + ""); string[] strSqls = new string[Sqls.Count]; for (int i = 0; i < Sqls.Count; i++) { strSqls[i] = Sqls[i].ToString(); } if (App.ExecuteBatch(strSqls) > 0) { ucTemplateManagement.Temp_Sections = App.GetDataSet("select * from T_TEMPPLATE_SECTION"); ucTemplateManagement.Temp_Groups = App.GetDataSet("select * from T_TEMPPLATE_GROUP"); App.Msg("设置成功!"); } this.Close(); }