示例#1
0
        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();
            }
        }
示例#2
0
        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();
        }
示例#3
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            ssh.Connect();

            DBModifyOutput output = ssh.ModifyDML(UpdateList);

            ssh.Disconnect();
            txtResult.Text = output.Response;

            QuerySelect();
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
        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();
        }