Пример #1
0
        private void btnQuote_Click(object sender, EventArgs e)
        {
            //frmNewQuote frm = new frmNewQuote();
            //frm.ShowDialog();
            //loadDGV();
            DialogResult result = MessageBox.Show("Are you sure you want to add a new quote?", "New Quote", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                string sql = "INSERT INTO dbo.slimline_install_quote  (custAccRef) VALUES(' ')";
                using (SqlConnection conn = new SqlConnection(CONNECT.ConnectionString))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand(sql, conn))
                    {
                        cmd.ExecuteNonQuery();
                        loadDGV();
                        //here we emulate clicking the new quote
                        int quoteNumber = 0;
                        quoteNumber = Convert.ToInt32(dgvMain.Rows[0].Cells[0].Value.ToString());
                        frmManageQuote frm = new frmManageQuote(quoteNumber, -1);
                        this.Hide();
                        frm.ShowDialog();
                        this.Show();
                        loadDGV();
                    }
                    conn.Close();
                }
            }
        }
Пример #2
0
        private void dgvMain_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            frmManageQuote frm = new frmManageQuote(Convert.ToInt32(dgvMain.Rows[e.RowIndex].Cells[0].Value), 0);

            this.Hide();
            frm.ShowDialog();
            loadDGV();
            this.Show();
        }
Пример #3
0
        private void insertData(DataTable dt)
        {
            //first up we need to insert a new quote
            int    quote_id = 0;
            string sql      = "INSERT INTO dbo.slimline_install_quote  (custAccRef) VALUES(' ')";

            using (SqlConnection conn = new SqlConnection(CONNECT.ConnectionString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand(sql, conn))
                {
                    cmd.ExecuteNonQuery();
                }
                //grab max id rq
                sql = "SELECT MAX(ID) from dbo.slimline_install_quote";
                using (SqlCommand cmd = new SqlCommand(sql, conn))
                    quote_id = Convert.ToInt32(cmd.ExecuteScalar());

                //now we go through the datatable and insert the items it has
                foreach (DataRow row in dt.Rows)  //    doorReference  - width - height - mastic
                {
                    int mastic = 0;
                    if (row["mastic"].ToString() == "yes")
                    {
                        mastic = -1;
                    }
                    else
                    {
                        mastic = 0;
                    }
                    sql = "INSERT INTO dbo.slimline_install_door (door_reference,structural_opening_width,structural_opening_height,mastic_required,quote_id) VALUES(" +
                          "'" + row["doorReference"].ToString() + "'," + row["width"].ToString() + "," + row["height"].ToString() + "," + mastic.ToString() + "," + quote_id.ToString() + " ) ";;
                    using (SqlCommand cmd = new SqlCommand(sql, conn))
                        cmd.ExecuteNonQuery();
                }
                conn.Close();
                frmManageQuote frm = new frmManageQuote(quote_id, -2);
                this.Hide();
                frm.ShowDialog();
                this.Show();
                loadDGV();
            }
        }