private void btnInsert_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count > InitialRowsCount) { for (int i = InitialRowsCount - 1; i < (dataGridView1.Rows.Count - 1); i++) { InsertInfo modInfo = new InsertInfo(Table); for (int c = 0; c < dataGridView1.Columns.Count; c++) { if (PrimaryKeyData != null && PrimaryKeyData.PrimaryKeyIndex == c) //skip primary key in insert { continue; } modInfo.Add(dataGridView1.Columns[c].Name, dataGridView1.Rows[i].Cells[c].Value); dataGridView1.Rows[i].Cells[c].Style.BackColor = Color.Green; } InsertList.Add(modInfo); } ssh.Connect(); DBModifyOutput output = ssh.ModifyDML(InsertList); ssh.Disconnect(); txtResult.Text = output.Response; QuerySelect(); } }
private void btnExecute_Click(object sender, EventArgs e) { ssh.Connect(); DBModifyOutput output = ssh.ExecuteScript(txtScript.Text); txtOuput.ForeColor = output.Status == 0 ? Color.Green : Color.Red; txtOuput.Text = output.Response; ssh.Disconnect(); }
private void btnEdit_Click(object sender, EventArgs e) { ssh.Connect(); DBModifyOutput output = ssh.ModifyDML(UpdateList); ssh.Disconnect(); txtResult.Text = output.Response; QuerySelect(); }
public DBModifyOutput ExecuteScript(String scriptContent) { DBModifyOutput output = new DBModifyOutput(); sshClient.RunCommand(String.Format("rm {0}", SqlFile)); foreach (String splitLine in scriptContent.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)) { sshClient.RunCommand(String.Format("echo \"{0}\" >> {1}", splitLine, SqlFile)); } var response = sshClient.RunCommand(PsqlScriptExec()); output.Response = response.ExitStatus == 0 ? response.Result : response.Error; output.Status = response.ExitStatus; return(output); }
public DBModifyOutput ModifyDML(List <ModifyInfo> updateList) { DBModifyOutput output = new DBModifyOutput(); if (updateList != null) { sshClient.RunCommand(String.Format("rm {0}", SqlFile)); foreach (ModifyInfo update in updateList) { sshClient.RunCommand(String.Format("echo \"{0}\" >> {1}", update.GetQuery(), SqlFile)); } var response = sshClient.RunCommand(PsqlScriptExec()); output.Response = response.ExitStatus == 0 ? response.Result : response.Error; output.Status = response.ExitStatus; } return(output); }
private void btnDelete_Click(object sender, EventArgs e) { List <ModifyInfo> deleteList = new List <ModifyInfo>(); foreach (DataGridViewRow row in dataGridView1.SelectedRows) { DeleteInfo newDel = new DeleteInfo(PrimaryKeyData.PrimaryKeyName, Int32.Parse(row.Cells[PrimaryKeyData.PrimaryKeyIndex].Value.ToString()), Table); deleteList.Add(newDel); } ssh.Connect(); DBModifyOutput output = ssh.ModifyDML(deleteList); ssh.Disconnect(); txtResult.Text = output.Response; QuerySelect(); }