Esempio n. 1
0
        private void btn_new_project_Click(object sender, EventArgs e)
        {
            SqlConnection conn = ConnectionClass.GetConnection_jodan_quote();

            SqlCommand    select_max_project  = new SqlCommand(Statementsclass.select_max_project_id, conn);
            SqlDataReader read_max_project_id = select_max_project.ExecuteReader();


            if (read_max_project_id.Read())
            {
                Valuesclass.project_id = (Convert.ToInt32(read_max_project_id["Project ID"])) + 1;
                read_max_project_id.Close();
            }
            ConnectionClass.Dispose_connection(conn);


            SqlConnection conn2 = ConnectionClass.GetConnection_jodan_quote();
            SqlCommand    select_max_quote_id = new SqlCommand(Statementsclass.select_max_quote_id, conn2);
            SqlDataReader read_max_quote_id   = select_max_quote_id.ExecuteReader();

            if (read_max_quote_id.Read())
            {
                Valuesclass.quote_id = (Convert.ToInt32(read_max_quote_id["Quote ID"])) + 1;
                read_max_quote_id.Close();
            }

            Valuesclass.new_item_identifier = 1;


            SqlCommand insert_new_project = new SqlCommand(Statementsclass.insert_new_project, conn2);

            insert_new_project.Parameters.AddWithValue("@customer_id", Valuesclass.customer_account_ref);
            insert_new_project.Parameters.AddWithValue("@quote_date", DateTime.Now);
            insert_new_project.Parameters.AddWithValue("@created_by", loginclass.Login.globalFullName.ToString());
            insert_new_project.ExecuteNonQuery();
            ConnectionClass.Dispose_connection(conn2);
            this.Hide();
            FrmQuote project = new FrmQuote();

            project.Show();
        }
        private void FrmQuoteReport_FormClosed(object sender, FormClosedEventArgs e)
        {
            FrmQuote quote = new FrmQuote();

            quote.Show();
        }
Esempio n. 3
0
        private void grid_quote_list_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int i = e.RowIndex;

            Valuesclass.new_item_identifier = 0;
            Valuesclass.customer_name       = grid_quote_list.Rows[i].Cells["Customer Name"].Value.ToString();
            Valuesclass.project_id          = Convert.ToInt32(grid_quote_list.Rows[i].Cells["Project ID"].Value);
            try
            {
                if (e.ColumnIndex == grid_quote_list.Columns["btn_open"].Index && e.RowIndex >= 0)
                {
                    FrmQuote quote = new FrmQuote();
                    quote.Show();
                    this.Hide();
                }
                if (e.ColumnIndex == grid_quote_list.Columns["btn_copy"].Index && e.RowIndex >= 0)
                {
                    Valuesclass.new_item_identifier = 1;
                    Valuesclass.project_id          = Convert.ToInt32(grid_quote_list.Rows[i].Cells["Project ID"].Value);
                    DialogResult confirm = MessageBox.Show("Are You Sure You Want To Copy Quotation?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (confirm == DialogResult.Yes)
                    {
                        Valuesclass.customer_name = "";
                        if (Valuesclass.jodan_y_n == 0)
                        {
                            FrmCustomerSelect select = new FrmCustomerSelect();
                            select.ShowDialog();
                        }
                        else
                        {
                            Valuesclass.customer_name        = "JODAN CONTRACTS LTD                                         ";
                            Valuesclass.customer_account_ref = "JODAN CONTRACTS LTD                                         ";
                        }

                        if (string.IsNullOrEmpty(Valuesclass.customer_name) == true)
                        {
                            return;
                        }

                        SqlConnection conn         = ConnectionClass.GetConnection_jodan_quote();
                        SqlCommand    copy_project = new SqlCommand(Statementsclass.copy_project, conn);
                        copy_project.Parameters.AddWithValue("@project_Id", Valuesclass.project_id);
                        SqlDataReader reader = copy_project.ExecuteReader();

                        if (reader.Read())
                        {
                            SqlConnection conn2 = ConnectionClass.GetConnection_jodan_quote();

                            SqlCommand insert_copied_project = new SqlCommand(Statementsclass.insert_copied_project, conn2);

                            insert_copied_project.Parameters.AddWithValue("@convertion_id", Valuesclass.project_id);
                            insert_copied_project.Parameters.AddWithValue("@customer_ref", Valuesclass.customer_account_ref);
                            insert_copied_project.Parameters.AddWithValue("@site_ref", reader["site_ref"].ToString());
                            insert_copied_project.Parameters.AddWithValue("@project_ref", reader["project_ref"].ToString());
                            insert_copied_project.Parameters.AddWithValue("@date_created", DateTime.Now);
                            insert_copied_project.Parameters.AddWithValue("@quote_status", reader["quote_status"].ToString());
                            insert_copied_project.Parameters.AddWithValue("@jodan_y_n", Valuesclass.jodan_y_n);
                            insert_copied_project.ExecuteNonQuery();

                            ConnectionClass.Dispose_connection(conn);
                            ConnectionClass.Dispose_connection(conn2);
                        }

                        Copy_Item();
                        // Copy_converted_hardware();



                        MessageBox.Show("Quotation Successfully Converted", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        FrmQuote quote = new FrmQuote();
                        quote.Show();
                        this.Hide();
                    }
                    else
                    {
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "");
            }
        }