//删除 private void simpleButton3_Click(object sender, EventArgs e) { if (gridView1.DataRowCount > 0) { string id = gridView1.GetFocusedRowCellValue("ID").ToString(); if (MessageBox.Show("确定要删除此条数据吗?", "删除提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { bool DeleteFlag = true; if (Program.DB_SIGN == 0) { DeleteFlag = SqliteOptions.CreateInstance().SqliteDelete("delete from t_DiagnosisTemplate where ID='" + id + "'"); } else { DeleteFlag = SqliteOptions_sql.CreateInstance().SqliteDelete("delete from t_DiagnosisTemplate where ID='" + id + "'"); } if (DeleteFlag) { MessageBox.Show("删除成功!"); ZhenDuanTemplet_Form_Load(null, null); } } } }
//修改 private void simpleButton2_Click(object sender, EventArgs e) { if (gridView1.DataRowCount > 0) { if (string.IsNullOrEmpty(textBox1.Text.Trim()) || string.IsNullOrEmpty(textBox2.Text.Trim())) { MessageBox.Show("模板名称或模板内容不能为空!"); return; } //if (GetTheSameTemplate(textBox1.Text.Trim())) //{ // MessageBox.Show("已存在相同的模板名称,请修改"); // return; //} string id = gridView1.GetFocusedRowCellValue("ID").ToString(); bool UpdateFlag = true; if (Program.DB_SIGN == 0) { UpdateFlag = SqliteOptions.CreateInstance().SqliteUpdate("update t_DiagnosisTemplate set ChildTypeName='" + textBox1.Text.Trim() + "',DiagnosisContent='" + textBox2.Text.Trim() + "',JP='" + textBox3.Text.Trim() + "' where ID='" + id + "'"); } else { UpdateFlag = SqliteOptions_sql.CreateInstance().SqliteUpdate("update t_DiagnosisTemplate set ChildTypeName='" + textBox1.Text.Trim() + "',DiagnosisContent='" + textBox2.Text.Trim() + "',JP='" + textBox3.Text.Trim() + "' where ID='" + id + "'"); } if (UpdateFlag) { MessageBox.Show("修改成功!"); ZhenDuanTemplet_Form_Load(null, null); } } }
private void DiagnosisShow_Form_Load(object sender, EventArgs e) { DataTable dt1 = new DataTable(); if (Program.DB_SIGN == 0) { dt1 = SqliteOptions.CreateInstance().ExcuteSqlite("select * from t_DiagnosisTemplate order by DiagIndex DESC"); } else { dt1 = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select * from t_DiagnosisTemplate order by DiagIndex DESC"); } gridControl1.DataSource = dt1; }
//文本框改变事件 private void textBox1_TextChanged(object sender, EventArgs e) { DataTable dt1 = new DataTable(); if (Program.DB_SIGN == 0) { dt1 = SqliteOptions.CreateInstance().ExcuteSqlite("select * from t_DiagnosisTemplate where JP like '%" + textBox1.Text.Trim() + "%' order by DiagIndex DESC"); } else { dt1 = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select * from t_DiagnosisTemplate where JP like '%" + textBox1.Text.Trim() + "%' order by DiagIndex DESC"); } gridControl1.DataSource = dt1; }
//添加 private void simpleButton1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox1.Text.Trim()) || string.IsNullOrEmpty(textBox2.Text.Trim())) { MessageBox.Show("模板名称或模板内容不能为空!"); return; } if (GetTheSameTemplate(textBox1.Text.Trim())) { MessageBox.Show("已存在相同的模板名称,请修改"); return; } DataTable dt_2 = null; if (Program.DB_SIGN == 0) { dt_2 = SqliteOptions.CreateInstance().ExcuteSqlite("select * from t_DiagnosisTemplate where ChildTypeName='" + textBox1.Text.Trim() + "'"); } else { dt_2 = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select * from t_DiagnosisTemplate where ChildTypeName='" + textBox1.Text.Trim() + "'"); } if (dt_2.Rows.Count > 0) { MessageBox.Show("已存在相同模板名称的数据行,请重新命名模板名称!"); return; } if (MessageBox.Show("确定要添加此条数据吗?", "添加提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { bool AddFlag = true; if (Program.DB_SIGN == 0) { AddFlag = SqliteOptions.CreateInstance().SqliteAdd("INSERT INTO t_DiagnosisTemplate (ID,ChildTypeName,DiagnosisContent,JP,DiagIndex) VALUES ('" + Guid.NewGuid().ToString() + "','" + textBox1.Text.Trim() + "','" + textBox2.Text.Trim() + "','" + textBox3.Text.Trim() + "','0')"); } else { AddFlag = SqliteOptions_sql.CreateInstance().SqliteAdd("INSERT INTO t_DiagnosisTemplate (ID,ChildTypeName,DiagnosisContent,JP,DiagIndex) VALUES ('" + Guid.NewGuid().ToString() + "','" + textBox1.Text.Trim() + "','" + textBox2.Text.Trim() + "','" + textBox3.Text.Trim() + "','0')"); } if (AddFlag) { MessageBox.Show("添加成功!"); ZhenDuanTemplet_Form_Load(null, null); } } }
private void ZhenDuanTemplet_Form_Load(object sender, EventArgs e) { DataTable dt1 = null; string sql = "select * from t_DiagnosisTemplate order by DiagIndex DESC"; if (Program.DB_SIGN == 0) { dt1 = SqliteOptions.CreateInstance().ExcuteSqlite(sql); } else { dt1 = SqliteOptions_sql.CreateInstance().ExcuteSqlite(sql); } gridControl1.DataSource = dt1; gridControl1_Click(null, null); }
//判断模板名称是否已存在 bool GetTheSameTemplate(string templateName) { bool SameFlag = false; DataTable dt2 = null; if (Program.DB_SIGN == 0) { dt2 = SqliteOptions.CreateInstance().ExcuteSqlite("select ChildTypeName from t_DiagnosisTemplate where ChildTypeName='" + templateName + "'"); } else { dt2 = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select ChildTypeName from t_DiagnosisTemplate where ChildTypeName='" + templateName + "'"); } if (dt2.Rows.Count > 0) { SameFlag = true; return(SameFlag); } return(SameFlag); }
//数据行点击 private void gridControl1_Click(object sender, EventArgs e) { if (gridView1.DataRowCount > 0) { string dcon = gridView1.GetFocusedRowCellValue("DiagnosisContent").ToString(); //模板内容 string ChildTypeName = gridView1.GetFocusedRowCellValue("ChildTypeName").ToString(); //模板名称 string XuHao = gridView1.GetFocusedRowCellValue("DiagIndex").ToString(); //模板排序下标 string ID = gridView1.GetFocusedRowCellValue("ID").ToString(); //模板ID int ReIndex = int.Parse(XuHao) + 1; if (Program.DB_SIGN == 0) { SqliteOptions.CreateInstance().SqliteUpdate("update t_DiagnosisTemplate set DiagIndex='" + ReIndex + "' where ID='" + ID + "'"); } else { SqliteOptions_sql.CreateInstance().SqliteUpdate("update t_DiagnosisTemplate set DiagIndex='" + ReIndex + "' where ID='" + ID + "'"); } DiagnosisShow_Form_Load(null, null); TemplateEvent(dcon, null); } }