private void btn_sqlconn_Click(object sender, EventArgs e) { try { if (cmb_pt.SelectedItem == null) { return; } string sqlgetdata = string.Format("select * from PT_Up_DataBase_Setting where pt_id = '{0}'", ((DataRowView)cmb_pt.SelectedItem).Row["PT_ID"].ToString()); DataTable connstr = DALUse.Query(sqlgetdata).Tables[0]; if (connstr.Rows.Count == 1) { string sqlupdate = string.Format("update PT_Up_DataBase_Setting set joins = '{0}',PT_DataBase ='{2}' where pt_id = '{1}'", txt_connstr.Text, cmb_pt.SelectedValue.ToString(), txt_database.Text); if (DALUse.ExecuteSql(sqlupdate) == 1) { MessageBox.Show("修改成功!"); } } else if (connstr.Rows.Count == 0) { string sqlinsert = string.Format("insert into PT_Up_DataBase_Setting (pt_id,Joins,PT_DataBase) values('{0}','{1}','{2}')", cmb_pt.SelectedValue.ToString(), txt_connstr.Text, txt_database.Text); if (DALUse.ExecuteSql(sqlinsert) == 1) { MessageBox.Show("添加成功!"); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btn_save_Click(object sender, EventArgs e) { try { cf.WaitingThreadStart(); foreach (DataRow dr in dtcompare.Rows) { if (dr["NEWROWFLAG"].ToString() == "1")//当时才插入为新插入行 { string sqlupdate = string.Format("update PT_COMPARISON_DETAIL_DICT set compare_name='{0}',compare_code='{1}'where id = '{2}'", dr["COMPARE_NAME"].ToString().Replace("'", "''"), dr["COMPARE_CODE"].ToString().Replace("'", "''"), dr["ID"].ToString()); sqllist.Add(sqlupdate); } } bool result = DALUse.ExecuteSqlTran(sqllist.ToArray()); cf.WaitingThreadStop(); InitData(); if (result) { MessageBox.Show("数据保存成功!"); } } catch (Exception ex) { string serror = ""; foreach (string s in sqllist) { serror += s + "\n"; } MessageBox.Show(serror + ex.ToString()); } }
private void btn_delnode_Click(object sender, EventArgs e) { //if (tl_node.FocusedNode.HasChildren) //{ // MessageBox.Show("请先清除子节点!"); //} //else //{ //DALUse.ExecuteSql(string.Format("delete pt_xml_config where id = {0}", ((DataRowView)tl_node.GetDataRecordByNode(tl_node.FocusedNode)).Row["ID"].ToString())); //} if (tl_node.FocusedNode == null) { return; } TreeListNode tln = tl_node.FocusedNode; RecursiveDel(tln); DALUse.ExecuteSql(string.Format("delete pt_xml_config where id = '{0}'", ((DataRowView)tl_node.GetDataRecordByNode(tln)).Row["ID"].ToString())); foreach (TreeListNode deln in tlist) { DALUse.ExecuteSql(string.Format("delete pt_xml_config where id = '{0}'", ((DataRowView)tl_node.GetDataRecordByNode(deln)).Row["ID"].ToString())); } Initgc_nodeData(); InitTreeListData(); tl_node.ExpandAll(); }
/// <summary> /// 获取平台配置的sql /// </summary> /// <returns>返回sql列表</returns> public void GetConfigSQL() { string strSQL = string.Format("select * from pt_sql a,pt_tables_dict b where a.table_id = b.id and b.exportflag ='TRUE' "); m_dsSQL = DALUse.Query(strSQL); RemoteMessage.SendMessage("===加载配置语句\nSQL:" + strSQL); }
private void btn_cancel_Click(object sender, EventArgs e) { if (MessageBox.Show(null, "确定删除所选项", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } try { foreach (DataRow dr in source.Rows) { if (dr["CHK"].ToString() == "1") { string sql = "delete from pt_comparison where compare_id = '" + dr["compare_id"] + "'"; DALUse.ExecuteSql(sql); } } MessageBox.Show("取消绑定成功!"); source = InitData(); gc_comparison.DataSource = source.DefaultView; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void InsertIntoTable(DataSet ds) { #region 将生成的dataset存入数据库 List <string> sqllist = new List <string>(); foreach (DataRow dr in ds.Tables[0].Rows) { string sql = ""; string insertValueString = ""; string insertColumnString = ""; foreach (DataColumn dc in ds.Tables[0].Columns) { ///读取信息 然后导入到数据库 insertValueString += string.Format("'{0}',", dr[dc].ToString()); insertColumnString += string.Format("{0},", dc.ToString()); } insertColumnString = insertColumnString.Trim(','); insertValueString = insertValueString.Trim(','); sql = string.Format(@"insert into {0}({1}) values({2})", txt_dict_name.Text, insertColumnString, insertValueString); sqllist.Add(sql); } try { DALUse.ExecuteSqlTran(sqllist.ToArray()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } #endregion }
/// <summary> /// 通过pt_id获取需要转换的字典 /// </summary> /// <param name="pt_id">平台id</param> /// <returns>字典集信息</returns> public static void GetPtCompareDictDetail() { PublicVar.CompareDict.Tables.Clear(); DataSet _dsType = GetPtCompareDict(PublicVar.Pt_Id); try { foreach (DataRow _dr in _dsType.Tables[0].Rows) { DataTable _dt = new DataTable(_dr["type_name"].ToString()); string strSQL = string.Format("select * from pt_comparison_detail_dict t where pt_id ='{0}' and type_name = '{1}'", PublicVar.Pt_Id, _dr["type_name"].ToString()); DataSet _ds = DALUse.Query(strSQL); if (_ds.Tables.Count > 0) { _dt = _ds.Tables[0].Copy(); _dt.TableName = _dr["type_name"].ToString(); } PublicVar.CompareDict.Tables.Add(_dt); } } catch (Exception exp1) { CommonFunction.WriteError(exp1.ToString()); } }
private void btn_add_Click(object sender, EventArgs e) { try { string sql = ""; //if (publicProperty.DATABASETYPE=="ORACLE") //{ //Guid g = new Guid(); sql = string.Format("insert into pt_xml_config(layout_name,ID,FIELD_NAME,pt_id) values('{0}','{2}','根节点','{1}')", txt_layout_name.Text, pt_id, Guid.NewGuid()); //} //else if (publicProperty.DATABASETYPE=="SQLSERVER") //{ // sql = string.Format("insert into pt_xml_config(layout_name,FIELD_NAME,pt_id) values('{0}','根节点',{1})", txt_layout_name.Text, int.Parse(pt_id)); //} if (DALUse.ExecuteSql(sql) == 1) { this.FindForm().Close(); uctlMessageBox.frmDisappearShow("添加成功!"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btn_dellocaldict_Click(object sender, EventArgs e) { try { string sql = string.Format("delete PT_LOCAL_DICT where type_name = '{0}'", cmb_local.SelectedValue.ToString()); string sql1 = string.Format("update PT_COMPARISON_DETAIL_DICT set COMPARE_CODE = null ,COMPARE_NAME = null where type_name = '{0}'", cmb_local.SelectedValue.ToString()); if (MessageBox.Show(null, "确定删除所选字典?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { int r1 = DALUse.ExecuteSql(sql); } catch (Exception exp) { CommonFunction.WriteErrorLog(exp.ToString()); } try { int r2 = DALUse.ExecuteSql(sql1); } catch (Exception exp) { CommonFunction.WriteErrorLog(exp.ToString()); } InitDictData(); } } catch (Exception exp) { CommonFunction.WriteErrorLog(exp.ToString()); } }
/// <summary> /// 每当修改,删除,保存操作后进行刷新操作,跟新实时数据。 /// </summary> public void RefreshContent() { string sql = string.Format("select * from pt_target_field where table_name ='{0}' and pt_id ='{1}'", gridView1.GetDataRow(gridView1.FocusedRowHandle)["TABLE_NAME"].ToString(), ((DataRowView)cmb_ptname.SelectedItem).Row["pt_id"].ToString()); dttemp = DALUse.Query(sql).Tables[0]; gc_pt_target.DataSource = dttemp; }
public void FindCompare() { sb.Length = 0; sb.Append('%'); string sql = ""; if (rb_field.Checked && rb_mohu.Checked) { foreach (char c in gridView3.GetDataRow(gridView3.FocusedRowHandle)["field"].ToString().ToCharArray()) { sb.Append(c); sb.Append('%'); } sql = string.Format("select * from PT_LOCAL_DICT where pt_id = '{0}' and type_name = '{1}'and field like'{2}'", cmb_pt_name.SelectedValue.ToString(), cmb_local.SelectedValue.ToString(), sb.ToString()); } else if (rb_field.Checked && rb_yange.Checked) { sql = string.Format("select * from PT_LOCAL_DICT where pt_id = '{0}' and type_name = '{1}'and field ='{2}'", cmb_pt_name.SelectedValue.ToString(), cmb_local.SelectedValue.ToString(), gridView3.GetDataRow(gridView3.FocusedRowHandle)["field"].ToString()); } else if (rb_code.Checked && rb_mohu.Checked) { foreach (char c in gridView3.GetDataRow(gridView3.FocusedRowHandle)["field_code"].ToString().ToCharArray()) { sb.Append(c); sb.Append('%'); } sql = string.Format("select * from PT_LOCAL_DICT where pt_id = '{0}' and type_name = '{1}'and field_code like'{2}'", cmb_pt_name.SelectedValue.ToString(), cmb_local.SelectedValue.ToString(), sb.ToString()); } else if (rb_code.Checked && rb_yange.Checked) { sql = string.Format("select * from PT_LOCAL_DICT where pt_id = '{0}' and type_name = '{1}'and field_code = '{2}'", cmb_pt_name.SelectedValue.ToString(), cmb_local.SelectedValue.ToString(), gridView3.GetDataRow(gridView3.FocusedRowHandle)["field_code"].ToString()); } gc_local.DataSource = DALUse.Query(sql).Tables[0]; }
private void gridView1_Click(object sender, EventArgs e) { try { needfix = false; if (dttabledetail.Rows.Count != 0) { DataSet dsconnstr = DALUse.Query(string.Format("select * from PT_Setting where pt_id ='{0}'", cmb_ptname.SelectedValue.ToString())); if (dsconnstr.Tables.Count > 0 && dsconnstr.Tables[0].Rows.Count > 0) { connstr = dsconnstr.Tables[0].Rows[0]["connstr"].ToString(); } string sqltemp = string.Format("select * from pt_target_field where table_name ='{0}' and pt_id = '{1}'", gridView1.GetDataRow(gridView1.FocusedRowHandle)["TABLE_NAME"].ToString(), ((DataRowView)cmb_ptname.SelectedItem).Row["pt_id"].ToString()); string sqltarget = string.Format("select * from {0} where 1=0 ", gridView1.GetDataRow(gridView1.FocusedRowHandle)["TABLE_NAME"].ToString()); DataSet dstarget = DALUseSpecial.Query(sqltarget, connstr); if (dstarget.Tables.Count > 0) { dttarget = dstarget.Tables[0]; } DataSet dstemp = DALUse.Query(sqltemp); if (dstemp.Tables.Count > 0) { dttemp = dstemp.Tables[0]; } CheckTargetDict(dttemp, dttarget); gc_pt_target.DataSource = dttemp; } } catch (Exception ex) { //MessageBox.Show(ex.ToString()); } }
private void btn_ok_Click(object sender, EventArgs e) { string sqlupdatetable = string.Format("update pt_tables_dict set table_name = '{0}' where id ='{1}'", txt_tablename.Text, table_id); string sqlupdatetable2 = string.Format("update PT_TARGET_FIELD set table_name = '{0}' where pt_id = '{1}' and table_name = '{2}'", txt_tablename.Text, pt_id, oldtablename); string sqlinserttable = ""; //if (publicProperty.DATABASETYPE=="ORACLE") //{ //Guid g= new Guid(); sqlinserttable = string.Format("insert into pt_tables_dict(id,pt_id,table_name,exportflag) values('{2}','{0}','{1}','TRUE')", pt_id, txt_tablename.Text, Guid.NewGuid()); //} //else if (publicProperty.DATABASETYPE=="SQLSERVER") //{ // sqlinserttable = string.Format("insert into pt_tables_dict(pt_id,table_name) values({0},'{1}')", pt_id, txt_tablename.Text); //} if (kind == "update" && txt_tablename.Text != "") { DALUse.ExecuteSql(sqlupdatetable); DALUse.ExecuteSql(sqlupdatetable2); } else if (kind == "add" && txt_tablename.Text != "") { DALUse.ExecuteSql(sqlinserttable); } else { MessageBox.Show("表名不能为空!"); } this.FindForm().Close(); }
private void btn_save_Click(object sender, EventArgs e) { try { bool ischecked = rb_hong.Checked | rb_element.Checked | rb_cengci.Checked; if (!ischecked) { MessageBox.Show("ÇëÑ¡Ôñ±£´æÀàÐÍ£¡"); return; } string sqlinsert = ""; string sourcetype = ""; //if (publicProperty.DATABASETYPE=="ORACLE") //{ //Guid g = new Guid(); if (rb_cengci.Checked)//²ã´ÎºÅ { sourcetype = "0"; sqlinsert = string.Format("insert into pt_temp_field(id,pt_name,class_name,item_name,item_code,cengci_code,field_name,pt_id,sourcetype) values('{8}','{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", pt_name, class_name, item_name, item_code, txt_cengci_code.Text.ToString(), txt_field.Text.ToString(), pt_id, sourcetype, Guid.NewGuid()); } else if (rb_hong.Checked)//ºê { sourcetype = "1"; sqlinsert = string.Format("insert into pt_temp_field(id,pt_name,class_name,item_name,item_code,field_name,cengci_code,pt_id,sourcetype) values('{8}','{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", pt_name, class_name, item_name, item_code, txt_field.Text.ToString(), "**", pt_id, sourcetype, Guid.NewGuid()); } else if (rb_element.Checked)//ÔªËØ { sourcetype = "2"; sqlinsert = string.Format("insert into pt_temp_field(id,pt_name,class_name,item_name,item_code,field_name,cengci_code,pt_id,sourcetype) values('{8}','{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", pt_name, class_name, item_name, item_code, txt_field.Text.ToString(), "**", pt_id, sourcetype, Guid.NewGuid()); } //} //else if (publicProperty.DATABASETYPE =="mssqlserver") //{ // if (rb_cengci.Checked)//²ã´ÎºÅ // { // sourcetype = "0"; // sqlinsert = string.Format("insert into pt_temp_field(pt_name,class_name,item_name,item_code,cengci_code,field_name,pt_id,sourcetype) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", pt_name, class_name, item_name, item_code, txt_cengci_code.Text.ToString(), txt_field.Text.ToString(), pt_id, sourcetype); // } // else if (rb_hong.Checked)//ºê // { // sourcetype = "1"; // sqlinsert = string.Format("insert into pt_temp_field(pt_name,class_name,item_name,item_code,field_name,cengci_code,pt_id,sourcetype) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", pt_name, class_name, item_name, item_code, txt_field.Text.ToString(), "**", pt_id, sourcetype); // } // else if (rb_element.Checked)//ÔªËØ // { // sourcetype = "2"; // sqlinsert = string.Format("insert into pt_temp_field(pt_name,class_name,item_name,item_code,field_name,cengci_code,pt_id,sourcetype) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", pt_name, class_name, item_name, item_code, txt_field.Text.ToString(), "**", pt_id, sourcetype); // } //} DALUse.ExecuteSql(sqlinsert); MessageBox.Show("±£´æ³É¹¦£¡"); this.FindForm().Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void GetPats() { m_dsPtas = new DataSet(); string sql = string.Format("select m.PATIENT_ID,m.VISIT_ID ,n.NAME from pat_visit m ,pat_master_index n where {0} >'{1}' and {0}< '{2}' and m.patient_id = n.patient_id", "DISCHARGE_DATE_TIME", DateTime.Today.AddDays(-1), DateTime.Today); m_dsPtas = DALUse.Query(sql); ExportDB.m_strTimeRange = "[时间]:" + DateTime.Today.AddDays(-1).ToString() + "至" + DateTime.Today; RemoteMessage.SendMessage("===加载病人列表\nSQL:" + sql + "\n===共" + m_dsPtas.Tables[0].Rows.Count.ToString() + "人"); }
/// <summary> /// 递归删除选定节点下的所有节点 /// </summary> /// <param name="tln">焦点节点</param> private void RecursiveDel(TreeListNode tln) { //if (tln.HasChildren) //{ // foreach (TreeListNode tlnchild in tln.Nodes) // { // RecursiveDel((TreeListNode)tlnchild); // } //} //else //{ // DALUse.ExecuteSql(string.Format("delete pt_xml_config where id = {0}", ((DataRowView)tl_node.GetDataRecordByNode(tln)).Row["ID"].ToString())); // //RecursiveDel(tln); //} //----------- //if (tln.Nodes.Count >= 0) //{ // if (tln.Nodes.Count == 0) // { // DALUse.ExecuteSql(string.Format("delete pt_xml_config where id = {0}", ((DataRowView)tl_node.GetDataRecordByNode(tln)).Row["ID"].ToString())); // } // else // { // foreach (TreeListNode node in tln.Nodes) // { // DALUse.ExecuteSql(string.Format("delete pt_xml_config where id = {0}", ((DataRowView)tl_node.GetDataRecordByNode(tln)).Row["ID"].ToString())); // if (node.Nodes.Count > 0) // { // RecursiveDel(node); // } // } // } //} //else //{ // DALUse.ExecuteSql(string.Format("delete pt_xml_config where id = {0}", ((DataRowView)tl_node.GetDataRecordByNode(tln)).Row["ID"].ToString())); //} //----------- if (tl_node.FocusedNode == null) { return; } if (tln.Nodes.Count > 0) { foreach (TreeListNode node in tln.Nodes) { //tlist.Add(node); DALUse.ExecuteSql(string.Format("delete pt_xml_config where id = '{0}'", ((DataRowView)tl_node.GetDataRecordByNode(node)).Row["ID"].ToString())); if (node.Nodes.Count > 0) { RecursiveDel(node); } } } }
private void gridView2_Click(object sender, EventArgs e) { if (gridView2.FocusedRowHandle < 0) { return; } string sql = string.Format("select * from pt_sql where id = {0}", gridView2.GetDataRow(gridView2.FocusedRowHandle)["ID"].ToString()); rtb_sql.Text = DALUse.Query(sql).Tables[0].Rows[0]["SQL"].ToString(); }
public void GetField() { if (gridView1.FocusedRowHandle < 0 || cmb_pt.SelectedItem == null) { return; } string sql = string.Format("select CENGCI_CODE,FIELD_NAME from pt_temp_field where pt_name = '{0}' and item_name='{1}'", ((DataRowView)cmb_pt.SelectedItem).Row["pt_name"].ToString(), gridView1.GetDataRow(gridView1.FocusedRowHandle)["item_name"].ToString()); gc_field.DataSource = DALUse.Query(sql).Tables[0]; }
/// <summary> /// 取出对比字段 /// </summary> /// <param name="pt_id">平台名</param> /// <param name="table_name">表名</param> /// <param name="compare_name">字段名</param> /// <returns></returns> public static string getFieldName(string pt_id, string table_name, string compare_name) { string result = ""; DataSet ds = DALUse.Query(string.Format("select * from PT_COMPARISON where pt_id = '{0}' and table_name = '{1}' and compare_name = '{2}'", pt_id, table_name, compare_name)); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { result = ds.Tables[0].Rows[0]["field"].ToString(); } return(result); }
public void getLayoutData() { try { gc_layout.DataSource = DALUse.Query(string.Format("select distinct LAYOUT_NAME from pt_xml_config where pt_id = '{0}'", cmb_pt.SelectedValue)).Tables[0]; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void getData() { try { string sqlgetdata = string.Format("select * from PT_Up_DataBase_Table where pt_id = '{0}'", ((DataRowView)cmb_pt.SelectedItem).Row["pt_id"].ToString()); gc_upload.DataSource = DALUse.Query(sqlgetdata).Tables[0]; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btn_save_Click(object sender, EventArgs e) { try { if (txt_node_name.Text != "") { string multiple = ""; if (rb_no.Checked) { multiple = "NO"; } else if (rb_yes.Checked) { multiple = "YES"; } string sqlinsert = ""; //if (publicProperty.DATABASETYPE == "ORACLE") //{ //Guid g = new Guid(); string field = ""; if (ckb_banding.Checked) { field = gridView1.FocusedRowHandle >= 0 ? gridView1.GetDataRow(gridView1.FocusedRowHandle)["COMPARE_NAME"].ToString() : ""; } sqlinsert = string.Format("insert into pt_xml_config(id,parient_id,field_name,field,pt_id,multiple,layout_name) values('{5}','{0}','{1}','{2}','{3}','{4}','{6}')", lab_parientid.Text.ToString() == "" ? "-1" : lab_parientid.Text.ToString(), txt_node_name.Text, field, pt_id, multiple, Guid.NewGuid(), layout_name ); //} //else if (publicProperty.DATABASETYPE=="SQLSERVER") //{ // string.Format("insert into pt_xml_config(parient_id,field_name,field,pt_id,multipel) values({0},'{1}','{2}',{3},'{4}')", // lab_parientid.Text.ToString() == "" ? "-1" : lab_parientid.Text.ToString(), // txt_node_name.Text, // gridView1.FocusedRowHandle >= 0 ? gridView1.GetDataRow(gridView1.FocusedRowHandle)["COMPARE_NAME"].ToString() : "", // pt_id, // multiple); //} DALUse.ExecuteSql(sqlinsert); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } this.FindForm().Close(); }
private void btn_ok_Click(object sender, EventArgs e) { try { string sql = string.Format("update pt_xml_config set layout_name = '{0}' where layout_name = '{1}'", txt_layoutname.Text, layout_name); DALUse.ExecuteSql(sql); this.FindForm().Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void InitComboxDatasource() { try { cmb_pt.DataSource = DALUse.Query(PublicProperty.SqlGetPT).Tables[0]; cmb_pt.ValueMember = "pt_id"; cmb_pt.DisplayMember = "pt_name"; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void SaveAndUpdate() { try { DALUse.ExecuteSqlTran(sqllist.ToArray()); } catch (Exception) { throw; } MessageBox.Show("保存操作完成!"); InitData(); }
private void cmb_target_SelectedIndexChanged(object sender, EventArgs e) { try { string sqltarget = string.Format("select distinct 0 NEWROWFLAG, T.* from PT_COMPARISON_DETAIL_DICT T WHERE pt_id='{0}' and type_name='{1}'", ((DataRowView)cmb_pt_name.SelectedItem).Row["pt_id"].ToString(), ((DataRowView)cmb_target.SelectedItem).Row["type_name"].ToString()); dtcompare = DALUse.Query(sqltarget).Tables[0]; gc_comparison.DataSource = dtcompare; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void cmb_local_SelectedIndexChanged(object sender, EventArgs e) { try { string sqllocal = string.Format("select * from PT_LOCAL_DICT WHERE type_name='{0}'", ((DataRowView)cmb_local.SelectedItem).Row["type_name"].ToString()); dtlocal = DALUse.Query(sqllocal).Tables[0]; gc_local.DataSource = dtlocal; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void txt_itemname_TextChanged(object sender, EventArgs e) { sb.Length = 0; sb.Append('%'); foreach (char c in txt_itemname.Text.ToCharArray()) { sb.Append(c); sb.Append('%'); } string sql = string.Format("select * from PT_LOCAL_DICT where field like'{0}'", sb.ToString()); gc_local.DataSource = DALUse.Query(sql).Tables[0]; }
private void btn_export_Click(object sender, EventArgs e) { try { if (sfd_save.ShowDialog(this) == DialogResult.OK) { cf.WaitingThreadStart(); if (rb_excel.Checked)//excel导出 { gridView1.ExportToXls(sfd_save.FileName + ".xls"); } else if (rb_pdf.Checked)//pdf导出 { MessageBox.Show("未完成"); } else if (rb_xml.Checked)//xml导出 { XmlDocument doc = new XmlDocument(); string sqlgetlayout = string.Format("select * from pt_xml_config where layout_name = '{0}'", cmb_xml.Text); DataTable dtlayout = DALUse.Query(sqlgetlayout).Tables[0]; DataRow[] drroot = dtlayout.Select("parient_id is null"); XmlNode root = doc.CreateElement(drroot[0]["field_name"].ToString()); root.InnerText = ""; doc.AppendChild(root); DataRow[] drsecondes = dtlayout.Select(string.Format("parient_id ='{0}'", drroot[0]["id"].ToString())); foreach (DataRow drdata in source.Rows) { XmlElement xn = doc.CreateElement(drsecondes[0]["field_name"].ToString()); root.AppendChild(xn); foreach (DataRow drfield in dtlayout.Rows) { if (source.Columns.Contains(drfield["field"].ToString())) { XmlNode xnleaf = doc.CreateElement(drfield["field_name"].ToString()); xnleaf.InnerText = drdata[drfield["field"].ToString()].ToString(); xn.AppendChild(xnleaf); } } } CommonFunction.ConverDataSetToXMLFile(doc.InnerXml, sfd_save.FileName + ".xml"); } cf.WaitingThreadStop(); uctlMessageBox.frmDisappearShow("数据导出成功!"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btn_del_Click(object sender, EventArgs e) { try { string sql = string.Format("delete from pt_sql where id = {0}", gridView2.GetDataRow(gridView2.FocusedRowHandle)["ID"].ToString()); DALUse.ExecuteSql(sql); MessageBox.Show("删除成功!"); } catch (Exception EX) { MessageBox.Show(EX.ToString()); } FreshSQL(); }