Ejemplo n.º 1
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure to Delete all records?", "Delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                SQLWorker sq = new SQLWorker();

                sq.Execute_Query("delete from " + curr_node.Text,
                                 Convert.ToInt32(curr_node.Tag));
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string com_str = "insert into " + tbl_name + " values (";
            string tmp_str = "";
            string cols    = "";

            int tmp = tbl.Columns.Count;

            SQLiteParameter[] prm = new SQLiteParameter[tmp];

            for (int i = 0; i < tmp; i++)
            {
                prm[i] = new SQLiteParameter("@p" + (i + 1).ToString(), tbl.Columns[i].DataType);
                try
                {
                    switch (tbl.Columns[i].DataType.ToString().ToUpper())
                    {
                    case "SYSTEM.STRING":
                        prm[i].Value = txt[i].Text;
                        break;

                    case "SYSTEM.DATETIME":
                    case "SYSTEM.DATE":
                        prm[i].Value = DateTime.Parse(txt[i].Text).ToString("s");
                        break;

                    case "SYSTEM.DOUBLE":
                    case "SYSTEM.DECIMAL":
                        prm[i].Value = double.Parse(txt[i].Text);
                        break;

                    default:
                        prm[i].Value = int.Parse(txt[i].Text);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: " + ex.Message);
                    return;
                }

                cols    += lbl[i].Text + ",";
                tmp_str += "@p" + (i + 1).ToString() + ",";
            }

            cols    = cols.Substring(0, cols.Length - 1);
            tmp_str = tmp_str.Substring(0, tmp_str.Length - 1);

            com_str = "insert into " + tbl_name + "(" + cols + ") values (" + tmp_str + ")";

            //MessageBox.Show(com_str);

            SQLWorker sq = new SQLWorker();

            sq.Execute_Query(com_str, connId, prm);

            if (sq.WorkerResult.Result == true)
            {
                MessageBox.Show("Record added");
            }
            else
            {
                MessageBox.Show(sq.WorkerResult.Message);
            }
        }
Ejemplo n.º 3
0
 public frmMain()
 {
     InitializeComponent();
     obj_sql           = new SQLWorker();
     connectionManager = ConnectionManagerV2.GetConnectionManager();
 }
Ejemplo n.º 4
0
 public frmNewTable()
 {
     InitializeComponent();
     obj_sql = new SQLWorker();
 }