Exemplo n.º 1
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(), "");
            }
        }
Exemplo n.º 2
0
        private void btn_convert_Click(object sender, EventArgs e)
        {
            try
            {
                Valuesclass.new_item_identifier = 1;
                DialogResult confirm = MessageBox.Show("Are You Sure You Want To Copy Quotation?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (confirm == DialogResult.Yes)
                {
                    Valuesclass.customer_name = "";
                    FrmCustomerSelect select = new FrmCustomerSelect();
                    select.ShowDialog();
                }
                Select_max_project_id();


                if (string.IsNullOrEmpty(Valuesclass.customer_name) == true)
                {
                    return;
                }
                SqlConnection conn2        = ConnectionClass.GetConnection_jodan_quote();
                SqlCommand    copy_project = new SqlCommand(Statementsclass.copy_project, conn2);
                copy_project.Parameters.AddWithValue("@project_Id", dT_Quote.DT_Quote_Items.Rows[0]["Project ID"]);
                SqlDataReader reader = copy_project.ExecuteReader();

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

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

                    insert_copied_project.Parameters.AddWithValue("@convertion_id", dT_Quote.DT_Quote_Items.Rows[0]["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", 0);

                    insert_copied_project.ExecuteNonQuery();

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


                Copy_Item();

                dT_customer.Clear();
                dT_Quote.Clear();
                this.dT_customer.SALES_LEDGER.Clear();
                this.dT_Quote.DT_Quote_Items.Clear();
                dT_customer.EnforceConstraints = false;

                this.ada_quote_items.Fill(dT_Quote.DT_Quote_Items, Valuesclass.project_id);
                this.sALES_LEDGERTableAdapter.Fill(dT_customer.SALES_LEDGER, Valuesclass.customer_account_ref);
                txt_customer.Text     = Valuesclass.customer_name;
                Valuesclass.jodan_y_n = 0;
                Format();
                MessageBox.Show("Quotation Successfully Converted", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "");
            }
        }