private void cb_Ltable_SelectedIndexChanged(object sender, EventArgs e) { if (!Isloading) { InitDataGrid(); string ls_sql = "select table_position From IF_Table_infor" + " Where Table_Name = '" + cb_Ltable.SelectedValue + "'"; DataTable ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { if (ldt.Rows.Count > 0) { string table_position = ldt.Rows[0]["table_position"].ToString(); ls_sql = "select Table_Name,Table_desc From IF_Table_infor" + " Where Table_Type = 'Z' and table_position = '" + table_position + "'"; if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { if (ldt.Rows.Count > 0) { cb_Ztable.DisplayMember = "Table_desc"; cb_Ztable.ValueMember = "Table_Name"; cb_Ztable.DataSource = ldt; //cb_Ztable.SelectedIndex = -1; //cb_Ztable.SelectedIndex = 0; } } } } } }
private void InsertPublicRows(string as_formtype_id) { //if (_TableName != "") return; string ls_sql = "SELECT Table_Name, Field_Name,Field_Desc, Field_Type, IsPK,CanNull,ShowIndex,IsIdentity " + " FROM IF_field_infor Where Table_Name ='" + as_formtype_id + "' order by ShowIndex"; DataTable ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { DataTable ldt_old = (DataTable)dgv_columns.DataSource; for (int i = ldt_old.Rows.Count - 1; i >= 0; i--) { if (ldt_old.Rows[i].RowState != DataRowState.Deleted) { ldt_old.Rows[i].Delete(); } } foreach (DataRow dr in ldt.Rows) { DataRow ldr = ldt_old.NewRow(); ldr[1] = dr[1]; ldr[2] = dr[2]; ldr[3] = dr[3]; ldr[4] = dr[4]; ldr[5] = dr[5]; ldr[6] = dr[6]; ldr[7] = dr[7]; ldt_old.Rows.Add(ldr); } } }
private void FrmTableTranse_Load(object sender, EventArgs e) { RetrieveData(); LoadInterfaceTrans(); DataGridStyle.GridDisplayStyle(dgv_task, true); Isloading = false; string sql = "select Table_Name from IF_Table_Infor where table_position = '0'"; AccessDBop.SQLSelect(sql, ref dtOurTableName); sql = "select Table_Name from IF_Table_Infor where table_position = '1'"; AccessDBop.SQLSelect(sql, ref dtTheirTableName); }
private void RetrieveUser() { string ls_sql = "SELECT 0 as selected, Table_Name, Table_desc FROM IF_Table_infor " + "Where Table_Name not in " + "(SELECT OurTableName FROM IF_Task " + "Where Task_id = '" + _Task_id + "')"; DataTable ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { dgv_tables.DataSource = ldt; } }
string GetPositionByTable(string TableName) { string sql = "select table_position from IF_Table_infor where Table_Name = '" + TableName + "'"; DataTable dt = new DataTable(); if (AccessDBop.SQLSelect(sql, ref dt)) { if (dt.Rows.Count > 0) { return(dt.Rows[0]["table_position"].ToString()); } } return(""); }
private void RetrieveData() { string ls_sql = ""; DataTable ldt; SetDGVColumn_Direction(); //初始化datagird if (_Task_id != "" && _Task_id != null) { //ls_sql = "SELECT id,Task_id, Task_Name, TheirTableName,TheirSql, OurTableName, OurTable_desc, OurSql,interfaceDesc,SWITCH(direction = '0', '{0}',True,'{1}') AS direction_alias,'删除' as del ,IncrementInsert,DeleteNotDrop,DropTable,GroupSql ,GroupField" + // " FROM IF_Task Where Task_id ='" + _Task_id + "' order by id"; ls_sql = "SELECT id,Task_id, Task_Name, TheirTableName,TheirSql, OurTableName, OurTable_desc, OurSql,interfaceDesc,direction,'删除' as del ,IncrementInsert,DeleteNotDrop,DropTable,GroupSql ,GroupField" + " FROM IF_Task Where Task_id ='" + _Task_id + "' order by id"; //ls_sql = string.Format(ls_sql, "导入" + Project.DB_Alias, "导入" + Project.theirDB_Alias); ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { if (ldt.Rows.Count > 0) { DirectionTrans(ldt); t_task.Text = ldt.Rows[0]["Task_id"].ToString(); t_taskname.Text = ldt.Rows[0]["Task_Name"].ToString(); } dgv_task.DataSource = ldt; if (Isloading) { gd_dt = ldt.Copy(); } } } else { t_task.Text = DateTime.Now.ToString("yyyyMMddHHmmss"); _Task_id = t_task.Text; ls_sql = "SELECT id,Task_id, Task_Name, TheirTableName,TheirSql, OurTableName, OurTable_desc, OurSql,interfaceDesc,direction,'删除' as del ,IncrementInsert ,DeleteNotDrop,DropTable,GroupSql ,GroupField" + " FROM IF_Task Where 1 < 0"; //ls_sql = string.Format(ls_sql, "导入" + Project.DB_Alias, "导入" + Project.theirDB_Alias); ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { dgv_task.DataSource = ldt; if (Isloading) { gd_dt = ldt.Copy(); } } } }
private void RetrieveTask() { string ls_sql = " SELECT distinct Task_id, Task_Name FROM IF_Task "; DataTable ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { DataRow dr = ldt.NewRow(); ldt.Rows.InsertAt(dr, 0); cb_task.DisplayMember = "Task_id"; cb_task.ValueMember = "Task_Name"; cb_task.DataSource = ldt; cb_task.SelectedIndex = -1; cb_task.SelectedIndex = 0; } }
private void InitDataGrid() { string ls_sql = ""; DataTable ldt; ls_sql = "select '' as Field_Name,'' as Field_Desc,Field_Name as ZField_Name,Field_Desc as ZField_Desc,'N' as RelativeFields,'Y' as IsTrans,'' as convertCol From IF_field_infor" + " Where Table_Name = '" + cb_Ztable.SelectedValue + "' order by showindex"; ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { d_replace.DataSource = (r_replace.Checked ? ldt : d_replace.DataSource); d_check.DataSource = (r_check.Checked ? ldt : d_check.DataSource); d_contition.DataSource = (r_contition.Checked ? ldt : d_contition.DataSource); } ls_sql = "select Field_Name,Field_Desc From IF_field_infor" + " Where Table_Name = '" + cb_Ltable.SelectedValue + "' order by showindex"; ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { DataGridView dgv = new DataGridView(); if (r_replace.Checked) { dgv = d_replace; } if (r_check.Checked) { dgv = d_check; } if (r_contition.Checked) { dgv = d_contition; } int count = Math.Min(dgv.Rows.Count, ldt.Rows.Count); for (int i = 0; i < count; i++) { dgv[0, i].Value = ldt.Rows[i]["Field_Name"].ToString(); dgv[1, i].Value = ldt.Rows[i]["Field_Desc"].ToString(); } } }
public void LoadData() { t_TheirTableName.Text = _TheirTableName; t_OurTableName.Text = _OurTableName; string ls_sql = ""; DataTable ldt = new DataTable(); if (_interfaceDesc == "") { ls_sql = "select Field_Name as TField_Name,Field_Name,Field_Desc, Field_Type, CanNull,'Y' as IsTrans,'' as convertCol From IF_field_infor" + " Where Table_Name = '" + _OurTableName + "'"; ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { dgv_Fields.DataSource = ldt; } } else { string[] Rule_contents = _interfaceDesc.Split(new string[] { "{separator}" }, StringSplitOptions.None); string ls_Rule_content = Rule_contents[0]; string[] ls_rows = ls_Rule_content.Split(new string[] { "{|}" }, StringSplitOptions.None); //初始化datagridview for (int i = 0; i < ls_rows.Length; i++) { string[] ls_value = ls_rows[i].Split(new string[] { "{,}" }, StringSplitOptions.None); dgv_Fields.Rows.Add(ls_value); } if (Rule_contents.Length > 1) { t_where.Text = Rule_contents[1]; t_group.Text = Rule_contents[2]; } } }
private void RetrieveData() { string ls_sql = ""; DataTable ldt; //if (_TableType != "Z") //{ //绑定下拉框 ls_sql = "select Table_Name,Table_desc From IF_Table_infor" + " Where Table_Type = 'Z' "; ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { if (ldt.Rows.Count > 0) { cb_Ztable.DisplayMember = "Table_desc"; cb_Ztable.ValueMember = "Table_Name"; cb_Ztable.DataSource = ldt; cb_Ztable.SelectedIndex = -1; cb_Ztable.SelectedIndex = 0; } } if (_TableName == "") { ls_sql = "select Table_Name,Table_desc From IF_Table_infor" + " Where Table_Type = 'L'" + " and Table_Name not in " + " (select TableName from IF_Table_Compare)"; } else { ls_sql = "select Table_Name,Table_desc From IF_Table_infor" + " Where Table_Type = 'L'"; } ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { if (ldt.Rows.Count > 0) { cb_Ltable.DisplayMember = "Table_desc"; cb_Ltable.ValueMember = "Table_Name"; cb_Ltable.DataSource = ldt; cb_Ltable.SelectedIndex = -1; cb_Ltable.SelectedIndex = 0; } } //} //初始化datagird if (_TableName != "" && _TableName != null) { cb_Ltable.Enabled = false; cb_Ztable.Enabled = false; ls_sql = "SELECT TableName, CompareTableName,Rule_id, Rule_content, SQLString " + " FROM IF_Table_Compare Where TableName ='" + _TableName + "'"; ldt = new DataTable(); DataGridView dgv = new DataGridView(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { if (ldt.Rows.Count > 0) { cb_Ltable.SelectedValue = ldt.Rows[0]["TableName"].ToString(); cb_Ztable.SelectedValue = ldt.Rows[0]["CompareTableName"].ToString(); switch (ldt.Rows[0]["Rule_id"].ToString()) { case "0": dgv = d_replace; r_replace.Checked = true; tb_Mode.SelectedIndex = 0; break; case "1": dgv = d_check; r_check.Checked = true; tb_Mode.SelectedIndex = 1; break; case "2": dgv = d_contition; r_contition.Checked = true; tb_Mode.SelectedIndex = 2; break; } } string ls_Rule_content = ldt.Rows[0]["Rule_content"].ToString(); string[] ls_contents = ls_Rule_content.Split(new string[] { "{seprator}" }, StringSplitOptions.None); string[] ls_rows = ls_contents[0].Split(new string[] { "{|}" }, StringSplitOptions.None); //初始化datagridview for (int i = 0; i < ls_rows.Length; i++) { string[] ls_value = ls_rows[i].Split(new string[] { "{,}" }, StringSplitOptions.None); dgv.Rows.Add(ls_value); } //若条件更新初始化增删改字段 string[] ls_conditionfileds = ls_contents[1].Split(new string[] { "," }, StringSplitOptions.None); if (r_contition.Checked) { t_conditionfield.Text = ls_conditionfileds[0]; t_addflag.Text = ls_conditionfileds[1]; t_updateflag.Text = ls_conditionfileds[2]; t_deleteflag.Text = ls_conditionfileds[3]; c_conAdd.Checked = (ls_conditionfileds[4] == "1" ? true : false); c_conUpdate.Checked = (ls_conditionfileds[5] == "1" ? true : false); c_conDel.Checked = (ls_conditionfileds[6] == "1" ? true : false); if ((!c_conAdd.Checked) && (!c_conUpdate.Checked) && (!c_conDel.Checked)) { d_contition.Enabled = false; DataGridStyle.GridDisplayStyle(d_contition, true, false); } else { d_contition.Enabled = true; DataGridStyle.GridDisplayStyle(d_contition, true); } } else if (r_check.Checked) { c_checkAdd.Checked = (ls_conditionfileds[0] == "1" ? true : false); c_checkUpdate.Checked = (ls_conditionfileds[1] == "1" ? true : false); c_checkDel.Checked = (ls_conditionfileds[2] == "1" ? true : false); if ((!c_checkAdd.Checked) && (!c_checkUpdate.Checked) && (!c_checkDel.Checked)) { d_check.Enabled = false; DataGridStyle.GridDisplayStyle(d_check, true, false); } else { d_check.Enabled = true; DataGridStyle.GridDisplayStyle(d_check, true); } } //初始化自定义语句 if (ls_contents[2] == "1") { r_enable.Checked = true; t_sql.Text = ls_contents[3]; } else { r_disable.Checked = true; } } } else { InitDataGrid(); tb_Mode.SelectedIndex = 1; c_checkAdd.Checked = false; c_checkDel.Checked = false; c_checkUpdate.Checked = false; } }
private void RetrieveData() { bool lb_result = false; //写dgv_columns string ls_sql = "SELECT Table_Name, Field_Name,Field_Desc, Field_Type, IsPK,CanNull,ShowIndex,IsIdentity " + " FROM IF_field_infor Where Table_Name ='" + _TableName + "' order by ShowIndex"; DataTable ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { dgv_columns.DataSource = ldt; } //写cb_CompareTable 下拉 if (_TableType != "Z") { ls_sql = "select Table_Name,Table_desc From IF_Table_infor" + " Where Table_Type = 'Z'"; ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { if (ldt.Rows.Count > 0) { cb_CompareTable.DisplayMember = "Table_desc"; cb_CompareTable.ValueMember = "Table_Name"; cb_CompareTable.DataSource = ldt; cb_CompareTable.SelectedIndex = -1; cb_CompareTable.SelectedIndex = 0; } } } if (ucbTablePosition.Text == Project.DB_Alias) { ls_sql = "select Db_type,Db_name,Db_server,Db_User,Db_Password From IF_DBConnectionInfor" + " Where bz = 0"; } else if (ucbTablePosition.Text == Project.theirDB_Alias) { ls_sql = "select Db_type,Db_name,Db_server,Db_User,Db_Password From IF_DBConnectionInfor" + " Where bz = 1"; } else { ls_sql = ""; } ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { if (ldt.Rows.Count > 0) { //constr = ""; ls_type = ldt.Rows[0]["Db_type"].ToString(); if (ls_type == "sql") { //constr = "server = " + ldt.Rows[0]["Db_server"] // + ";database = " + ldt.Rows[0]["Db_name"] //+ ";Uid = " + ldt.Rows[0]["Db_User"] //+ ";pwd = " + ldt.Rows[0]["Db_Password"]; ls_sql = "SELECT Name FROM SysObjects Where XType in('U','V') ORDER BY Name"; ldt = new DataTable(); if (ucbTablePosition.Text == Project.DB_Alias) { lb_result = SQLServerDBop.SQLSelect(Project.DB_Connection, ls_sql, ref ldt, ""); } else { lb_result = SQLServerDBop.SQLSelect(Project.TheirDB_Connection, ls_sql, ref ldt, ""); } if (lb_result) { cb_DatabaseTable.DisplayMember = "Name"; cb_DatabaseTable.ValueMember = "Name"; cb_DatabaseTable.DataSource = ldt; cb_DatabaseTable.SelectedIndex = -1; cb_DatabaseTable.SelectedIndex = 0; } dgv_columns.Columns["ISIDENTITY"].Visible = true; } else if (ls_type == "ora") { //constr = "server = " + ldt.Rows[0]["Db_server"] // + ";Uid = " + ldt.Rows[0]["Db_User"] // + ";pwd = " + ldt.Rows[0]["Db_Password"]; ls_sql = ("SELECT table_name as Name from user_tables where tablespace_name in" + " (" + " select default_tablespace from dba_users" + " where username = '******'" + " ) UNION SELECT VIEW_NAME AS NAME FROM User_Views").ToUpper(); ldt = new DataTable(); if (ucbTablePosition.Text == Project.DB_Alias) { lb_result = OracleDBop.SQLSelect(Project.DB_Connection, ls_sql, ref ldt); } else { lb_result = OracleDBop.SQLSelect(Project.TheirDB_Connection, ls_sql, ref ldt); } if (lb_result) { cb_DatabaseTable.DisplayMember = "Name"; cb_DatabaseTable.ValueMember = "Name"; cb_DatabaseTable.DataSource = ldt; cb_DatabaseTable.SelectedIndex = -1; cb_DatabaseTable.SelectedIndex = 0; } dgv_columns.Columns["ISIDENTITY"].Visible = false; } else if (ls_type == "mysql") { string db_name = ucbTablePosition.Text == Project.DB_Alias ? Project.DbName : Project.theirDbName; ls_sql = "select table_name as name from INFORMATION_SCHEMA.TABLES Where TABLE_TYPE='BASE TABLE' and table_schema = '" + db_name + "'"; ldt = new DataTable(); if (ucbTablePosition.Text == Project.DB_Alias) { lb_result = MySqlDBop.SQLSelect(Project.DB_Connection, ls_sql, ref ldt); } else { lb_result = MySqlDBop.SQLSelect(Project.TheirDB_Connection, ls_sql, ref ldt); } if (lb_result) { cb_DatabaseTable.DisplayMember = "Name"; cb_DatabaseTable.ValueMember = "Name"; cb_DatabaseTable.DataSource = ldt; cb_DatabaseTable.SelectedIndex = -1; cb_DatabaseTable.SelectedIndex = 0; } dgv_columns.Columns["ISIDENTITY"].Visible = true; } else if (ls_type == "access") { //string db_name = ucbTablePosition.Text == Project.DB_Alias ? Project.DbName : Project.theirDbName; //ls_sql = "SELECT name FROM MSYSOBJECTS WHERE TYPE=1 AND NAME NOT LIKE 'Msys*'"; //ldt = new DataTable(); //if (ucbTablePosition.Text == Project.DB_Alias) // lb_result = AccessDBop.SQLSelect(Project, ls_sql, ref ldt); //else // lb_result = AccessDBop.SQLSelect(Project.TheirDB_Connection, ls_sql, ref ldt); //if (lb_result) //{ // cb_DatabaseTable.DisplayMember = "Name"; // cb_DatabaseTable.ValueMember = "Name"; // cb_DatabaseTable.DataSource = ldt; // cb_DatabaseTable.SelectedIndex = -1; // cb_DatabaseTable.SelectedIndex = 0; //} //dgv_columns.Columns["ISIDENTITY"].Visible = true; MessageBox.Show("暂不支持access"); } } } }
private void RetrieveData() { SetLabelShow(); string ls_sql = ""; //初始化datagird ls_sql = "SELECT id,Task_id, Task_Name" + " FROM IF_Task Where Task_id ='10000000000000'"; ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { if (ldt.Rows.Count > 0) { t_taskname.Text = ldt.Rows[0]["Task_Name"].ToString(); } } ls_sql = "SELECT *" + " FROM IF_PHOTO where serial = 1"; ldt = new DataTable(); if (AccessDBop.SQLSelect(ls_sql, ref ldt)) { if (ldt.Rows.Count > 0) { if (ldt.Rows[0]["StoreType"].ToString() == "1") { r_database2file.Checked = true; OurXh.Text = ldt.Rows[0]["OUR_XH"].ToString(); cbZpIsPath.Checked = ldt.Rows[0]["ZPIsPath"].ToString() == "1" ? true : false; if (ldt.Rows[0]["Compress"].ToString() == "0") { r_disable.Checked = true; } else { r_enable.Checked = true; } } else if (ldt.Rows[0]["StoreType"].ToString() == "2") { r_file2file.Checked = true; OurXh2.Text = ldt.Rows[0]["OUR_XH"].ToString(); if (ldt.Rows[0]["Compress"].ToString() == "0") { r_disable1.Checked = true; } else { r_enable1.Checked = true; } } else if (ldt.Rows[0]["StoreType"].ToString() == "3") { r_file2database.Checked = true; tbTableName.Text = ldt.Rows[0]["TableName"].ToString(); tbXH.Text = ldt.Rows[0]["XH"].ToString(); tbZP.Text = ldt.Rows[0]["ZP"].ToString(); tbFilePath.Text = ldt.Rows[0]["BsPath"].ToString(); } if (ldt.Rows[0]["GetType"].ToString() == "1") { r_fromtable.Checked = true; } else { r_fromsql.Checked = true; } //if (ldt.Rows[0]["db_name"].ToString() == "bs") //{ // rbBs.Checked = true; //} //else //{ // rbScm.Checked = true; //} //if (ldt.Rows[0]["db_position"].ToString() == "0") //{ // cbPosition.Checked = true; //} //else //{ // cbPosition.Checked = false; //} if (ldt.Rows[0]["FileToXHType"].ToString() == "0") { r_XH.Checked = true; } else { r_Get_XH.Checked = true; } TableName.Text = ldt.Rows[0]["TableName"].ToString(); XH.Text = ldt.Rows[0]["XH"].ToString(); ZP.Text = ldt.Rows[0]["ZP"].ToString(); XHSQL.Text = ldt.Rows[0]["XHSQL"].ToString(); ZPSQL.Text = ldt.Rows[0]["ZPSQL"].ToString(); FROMSQL.Text = ldt.Rows[0]["FROMSQL"].ToString(); WHERESQL.Text = ldt.Rows[0]["WHERESQL"].ToString(); ZPSQL.Text = ldt.Rows[0]["ZPSQL"].ToString(); CompressRate.Value = Convert.ToDecimal(ldt.Rows[0]["CompressRate"].ToString()); CompressRate1.Value = Convert.ToDecimal(ldt.Rows[0]["CompressRate"].ToString()); string sValue = ldt.Rows[0]["width"].ToString().Trim(); sValue = sValue == "" ? "140" : sValue; nudWidth.Value = Convert.ToDecimal(sValue); sValue = ldt.Rows[0]["height"].ToString().Trim(); sValue = sValue == "" ? "194" : sValue; nudHeight.Value = Convert.ToDecimal(sValue); PhotoNumbers.Text = ldt.Rows[0]["PhotoNumbers"].ToString(); BsPath.Text = ldt.Rows[0]["BsPath"].ToString(); BsPath1.Text = ldt.Rows[0]["BsPath"].ToString(); TheirPhotoPath.Text = ldt.Rows[0]["TheirPhotoPath"].ToString(); StartPos.Text = ldt.Rows[0]["StartPos"].ToString(); EndPos.Text = ldt.Rows[0]["EndPos"].ToString(); } } }