private void b_ok_Click(object sender, EventArgs e) { ldt.Rows[0]["StoreType"] = (r_database2file.Checked ? "1" : (r_file2file.Checked ? "2" : "3")); ldt.Rows[0]["GetType"] = (r_fromtable.Checked ? "1" : "2"); ldt.Rows[0]["TableName"] = TableName.Text; ldt.Rows[0]["XH"] = XH.Text; ldt.Rows[0]["ZP"] = ZP.Text; ldt.Rows[0]["XHSQL"] = XHSQL.Text; ldt.Rows[0]["ZPSQL"] = ZPSQL.Text; ldt.Rows[0]["FROMSQL"] = FROMSQL.Text; ldt.Rows[0]["WHERESQL"] = WHERESQL.Text; //ldt.Rows[0]["db_name"] = (rbBs.Checked ? "bs" : "scm"); //ldt.Rows[0]["db_position"] = (cbPosition.Checked ? "0" : "1"); if (r_database2file.Checked) { ldt.Rows[0]["Compress"] = r_enable.Checked ? "1" : "0"; ldt.Rows[0]["CompressRate"] = CompressRate.Value; ldt.Rows[0]["BsPath"] = BsPath.Text; ldt.Rows[0]["OUR_XH"] = OurXh.Text; ldt.Rows[0]["ZPIsPath"] = cbZpIsPath.Checked ? "1" : "0"; } else if (r_file2file.Checked) { ldt.Rows[0]["Compress"] = r_enable1.Checked ? "1" : "0"; ldt.Rows[0]["CompressRate"] = CompressRate1.Value; ldt.Rows[0]["BsPath"] = BsPath1.Text; ldt.Rows[0]["OUR_XH"] = OurXh2.Text; } else if (r_file2database.Checked) { ldt.Rows[0]["TableName"] = tbTableName.Text; ldt.Rows[0]["XH"] = tbXH.Text; ldt.Rows[0]["ZP"] = tbZP.Text; ldt.Rows[0]["BsPath"] = tbFilePath.Text; } ldt.Rows[0]["width"] = nudWidth.Value; ldt.Rows[0]["height"] = nudHeight.Value; ldt.Rows[0]["FileToXHType"] = r_XH.Checked ? "0" : "1"; ldt.Rows[0]["PhotoNumbers"] = PhotoNumbers.Text; ldt.Rows[0]["TheirPhotoPath"] = TheirPhotoPath.Text; ldt.Rows[0]["StartPos"] = StartPos.Text; ldt.Rows[0]["EndPos"] = EndPos.Text; string ls_sql = "SELECT *" + " FROM IF_PHOTO where serial = 1"; AccessDBop.SQLExecute("delete from IF_Task where Task_id = '10000000000000'"); AccessDBop.SQLExecute("insert into IF_Task(Task_id,Task_Name,direction,IncrementInsert) values('10000000000000','" + t_taskname.Text + "','0','N')"); if (AccessDBop.SQLUpdate(ls_sql, ref ldt)) { MessageBox.Show("保存成功"); DialogResult = DialogResult.OK; } else { MessageBox.Show("保存失败"); } }
private void b_ok_Click(object sender, EventArgs e) { foreach (DataGridViewRow dgvr in dgv_tables.Rows) { string ls_OurTableName = dgvr.Cells[1].Value.ToString(); string ls_OurTableDesc = dgvr.Cells[2].Value.ToString(); string ls_selected = dgvr.Cells[0].Value.ToString(); if (ls_selected == "1") { string ls_sql = "Insert into IF_Task(Task_id,Task_Name,TheirTableName,TheirSql,OurTableName,OurTable_desc,OurSql,interfaceDesc,DeleteNotDrop,DropTable,direction,IncrementInsert) values ('" + _Task_id + "','','" + ls_OurTableName + "','', '" + ls_OurTableName + "', '" + ls_OurTableDesc + "','','','N','Y','0','N')"; AccessDBop.SQLExecute(ls_sql); } } DialogResult = DialogResult.OK; }
public bool Save() { string ls_sql = ""; DataTable ldt; if (_TableName != "" && _TableName != null) { ls_sql = "update IF_Table_Compare" + " set Rule_id = '" + (r_replace.Checked ? "0" : (r_check.Checked ? "1" : "2")) + "'," + " Rule_content = '" + GetRulecontent() + "'," + " SQLString = '" + GetRuleSQL() + "'" + " where TableName= '" + _TableName + "'"; ldt = new DataTable(); if (AccessDBop.SQLExecute(ls_sql)) { return(true); } else { return(false); } } else { string Ztable = cb_Ztable.SelectedValue == null ? "z_table" : cb_Ztable.SelectedValue.ToString(); string Ltable = cb_Ltable.SelectedValue.ToString(); ls_sql = "INSERT INTO IF_Table_Compare(TableName,CompareTableName, Rule_id, Rule_content,SQLString) " + "VALUES ('" + Ltable + "','" + Ztable + "','" + (r_replace.Checked ? "0" : (r_check.Checked ? "1" : "2")) + "','" + GetRulecontent() + "','" + GetRuleSQL() + "')"; ldt = new DataTable(); if (AccessDBop.SQLExecute(ls_sql)) { return(true); } else { return(false); } } //return true; }
private void b_close_Click(object sender, EventArgs e) { string ls_sql = "SELECT id,Task_id, Task_Name, TheirTableName,TheirSql, OurTableName, OurTable_desc, OurSql,interfaceDesc,direction,IncrementInsert ,DeleteNotDrop,DropTable,GroupSql ,GroupField " + " FROM IF_Task Where Task_id ='" + t_task.Text + "'"; foreach (DataRow dr in gd_dt.Rows) { dr.SetAdded(); } string ls_sql1 = "delete FROM IF_Task Where Task_id ='" + t_task.Text + "'"; if (AccessDBop.SQLExecute(ls_sql1)) { if (!AccessDBop.SQLUpdate(ls_sql, ref gd_dt)) { MessageBox.Show("取消更新时出错!"); return; } } DialogResult = DialogResult.Cancel; }
private void dgv_task_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 10) { if (MessageBox.Show("确定要删除此关系吗?", "删除提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { //获取连接信息 string ls_sql = "delete from IF_Task where Task_id = '" + t_task.Text + "' and OurTableName = '" + dgv_task["OurTableName", e.RowIndex].Value.ToString() + "'"; AccessDBop.SQLExecute(ls_sql); RetrieveData(); } } else if (e.ColumnIndex == 11) { if ((bool)dgv_task[e.ColumnIndex, e.RowIndex].EditedFormattedValue == false) { dgv_task["DeleteNotDrop", e.RowIndex].Value = "N"; dgv_task["DropTable", e.RowIndex].Value = "N"; } } else if (e.ColumnIndex == 12) { if ((bool)dgv_task[e.ColumnIndex, e.RowIndex].EditedFormattedValue == false) { dgv_task["IncrementInsert", e.RowIndex].Value = "N"; dgv_task["DropTable", e.RowIndex].Value = "N"; } } else if (e.ColumnIndex == 13) { if ((bool)dgv_task[e.ColumnIndex, e.RowIndex].EditedFormattedValue == false) { dgv_task["DeleteNotDrop", e.RowIndex].Value = "N"; dgv_task["IncrementInsert", e.RowIndex].Value = "N"; } } }
private void b_ok_Click(object sender, EventArgs e) { if (tb_TableName.Text == "") { MessageBox.Show("请输入表名!"); return; } if (ucbTablePosition.Text == "") { MessageBox.Show("请选择表位置!"); return; } string ls_sql = ""; string ls_CompareTableName = (_TableType == "Z" ? "" : (cb_CompareTable.SelectedValue == null ? "" : cb_CompareTable.SelectedValue.ToString())); if (_TableName == "") { ls_sql = "INSERT INTO IF_Table_infor(Table_Name,Table_desc, Table_Type, CompareTableName,table_position) " + "VALUES ('{0}','{1}','" + _TableType + "','" + ls_CompareTableName + "','{2}')"; } else { ls_sql = "UPDATE IF_Table_infor Set Table_Name='{0}', Table_desc = '{1}', CompareTableName = '" + ls_CompareTableName + "',table_position='{2}' " + "Where Table_Name='" + _TableName + "' and Table_Type = '" + _TableType + "'"; } string sPosition = ucbTablePosition.Text == Project.DB_Alias ? "0" : "1"; ls_sql = String.Format(ls_sql, new object[] { tb_TableName.Text, tb_TableDesc.Text, sPosition }); _TableName = tb_TableName.Text; if (AccessDBop.SQLExecute(ls_sql)) { ls_sql = "SELECT Table_Name, Field_Name, Field_Desc, " + "Field_Type, IsPK, CanNull,ShowIndex,IsIdentity " + " FROM IF_field_infor " + " Where Table_Name ='" + _TableName + "'"; DataTable ldt1 = (DataTable)dgv_columns.DataSource; int k = 0; foreach (DataRow ldr in ldt1.Rows) { if (ldr.RowState != DataRowState.Deleted) { if (ldr["Field_Name"] == null || ldr["Field_Name"].ToString() == "") { MessageBox.Show("请输入列名!"); return; } if (ldr["Field_Type"] == null || ldr["Field_Type"].ToString() == "") { MessageBox.Show("请输入列类型!"); return; } ldr[0] = tb_TableName.Text; if (ldr["IsPK"] == null || ldr["IsPK"].ToString().Trim() == "") { ldr["IsPK"] = "N"; } if (ldr["CanNull"] == null || ldr["CanNull"].ToString().Trim() == "") { ldr["CanNull"] = "N"; } if (ldr["IsIdentity"] == null || ldr["IsIdentity"].ToString().Trim() == "") { ldr["IsIdentity"] = "N"; } ldr["ShowIndex"] = k++; } } bool updateFlag = !AccessDBop.SQLUpdate(ls_sql, ref ldt1); string db_type = ucbTablePosition.Text == Project.DB_Alias ? Project.DB_Type : Project.TheirDB_Type; string CreaateTableSQL = DataBaseManager.GetCreateTableSQL(_TableName, db_type); if (updateFlag || (CreaateTableSQL.Equals("") || CreaateTableSQL.Equals("error") ? false : !AccessDBop.SQLExecute("update IF_Table_infor set CreateTable='" + CreaateTableSQL.Replace("'", "''") + "' Where Table_Name='" + _TableName + "'"))) { MessageBox.Show("更新列时出错!"); return; } else { MessageBox.Show("更新列成功!"); } } else { MessageBox.Show("更新表时出错!"); return; } DialogResult = DialogResult.OK; }