Esempio n. 1
0
        private void btn_new_item_Click(object sender, EventArgs e)
        {
            Valuesclass.new_item_identifier = 1;
            DialogResult confirm = MessageBox.Show("Add New Item To This Quotation?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (confirm == DialogResult.Yes)
            {
                Save();
                Valuesclass.revision_number = 1;
                select_max_item();
                Select_quote_id();
                this.ada_setting.Fill(dT_Settings.DT_Setting);
                SqlConnection conn = ConnectionClass.GetConnection_jodan_quote();
                SqlCommand    insert_new_project_quote = new SqlCommand(Statementsclass.insert_new_project_quote, conn);
                insert_new_project_quote.Parameters.AddWithValue("@project_id", Valuesclass.project_id);
                insert_new_project_quote.Parameters.AddWithValue("@item_id", Valuesclass.max_item_id);
                insert_new_project_quote.Parameters.AddWithValue("@item_date", DateTime.Now);
                insert_new_project_quote.Parameters.AddWithValue("@created_by", loginclass.Login.globalFullName);
                insert_new_project_quote.Parameters.AddWithValue("@markup_material", dT_Settings.DT_Setting.Rows[0]["markup_material"].ToString());
                insert_new_project_quote.Parameters.AddWithValue("@markup_hardware", dT_Settings.DT_Setting.Rows[0]["markup_hardware"].ToString());
                insert_new_project_quote.Parameters.AddWithValue("@labour_rate", dT_Settings.DT_Setting.Rows[0]["labour_rate"].ToString());
                insert_new_project_quote.ExecuteNonQuery();
                ConnectionClass.Dispose_connection(conn);
                Fill_data();
                this.Hide();
                FrmItem item = new FrmItem();
                item.Show();
                insert_blank_hardware();
            }

            else
            {
                return;
            }
        }
 private void barButtonItem_ItemClick(object sender, ItemClickEventArgs e)
 {
     if (_fItem == null || _fItem.IsDisposed)
     {
         _fItem           = new FrmItem();
         _fItem.MdiParent = this;
         _fItem.Show();
     }
     else
     {
         _fItem.Activate();
     }
 }
Esempio n. 3
0
        private void grid_items_on_quote_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == grid_items_on_quote.Columns["btn_view"].Index && e.RowIndex >= 0)
                {
                    int i = e.RowIndex;
                    Valuesclass.quote_id        = Convert.ToInt32(dT_Quote.DT_Quote_Items.Rows[i]["Item Identity"].ToString());
                    Valuesclass.item_id         = Convert.ToInt32(dT_Quote.DT_Quote_Items.Rows[i]["Item_Id"].ToString());
                    Valuesclass.revision_number = Convert.ToInt32(dT_Quote.DT_Quote_Items.Rows[i]["revision_id"].ToString());
                    //select_max_revison();
                    Valuesclass.new_item_identifier = 0;
                    Valuesclass.locked_identifiter  = 0;
                    FrmItem item = new FrmItem();
                    item.Show();
                    this.Hide();
                }

                if (e.ColumnIndex == grid_items_on_quote.Columns["btn_delete_item"].Index && e.RowIndex >= 0)
                {
                    int          i      = e.RowIndex;
                    DialogResult delete = MessageBox.Show("Delete Item From Project?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                    if (delete == DialogResult.Yes)
                    {
                        int           ID    = Convert.ToInt32(grid_items_on_quote.Rows[i].Cells["Item_Identity"].Value);
                        SqlConnection conn2 = ConnectionClass.GetConnection_jodan_quote();
                        SqlCommand    delete_multiple_item_hardware = new SqlCommand(Statementsclass.delete_multiple_item_hardware, conn2);
                        delete_multiple_item_hardware.Parameters.AddWithValue("@id", ID);
                        delete_multiple_item_hardware.ExecuteNonQuery();
                        ConnectionClass.Dispose_connection(conn2);

                        int           item              = Convert.ToInt32(dT_Quote.DT_Quote_Items.Rows[i]["Item_Id"].ToString());
                        int           project_id        = Convert.ToInt32(dT_Quote.DT_Quote_Items.Rows[i]["Project ID"].ToString());
                        SqlConnection conn              = ConnectionClass.GetConnection_jodan_quote();
                        SqlCommand    delete_quote_item = new SqlCommand(Statementsclass.delete_quote_item, conn);
                        delete_quote_item.Parameters.AddWithValue("@item_id", item);
                        delete_quote_item.Parameters.AddWithValue("@project_id", project_id);
                        delete_quote_item.ExecuteNonQuery();
                        Fill_data();
                    }
                }

                if (e.ColumnIndex == grid_items_on_quote.Columns["btn_copy"].Index && e.RowIndex >= 0)
                {
                    int i = e.RowIndex;
                    select_max_item();

                    Valuesclass.item_id = Convert.ToInt32(dT_Quote.DT_Quote_Items.Rows[i]["Item_Id"].ToString());
                    SqlConnection conn      = ConnectionClass.GetConnection_jodan_quote();
                    SqlCommand    copy_item = new SqlCommand(Statementsclass.copy_item, conn);
                    copy_item.Parameters.AddWithValue("@id", grid_items_on_quote.Rows[i].Cells["Item_Identity"].Value);
                    SqlDataReader reader = copy_item.ExecuteReader();

                    if (reader.Read())
                    {
                        int?          order_id             = (reader["order_id"] as int?) ?? 0;
                        int?          material_id          = (reader["material_id"] as int?) ?? 0;
                        int?          finish_id            = (reader["finish_id"] as int?) ?? 0;
                        int?          fire_rating_id       = (reader["fire_rating_id"] as int?) ?? 0;
                        int?          security_rating_id   = (reader["security_rating_id"] as int?) ?? 0;
                        int?          infill_id            = (reader["infill_id"] as int?) ?? 0;
                        int?          jamb_style_id        = (reader["jamb_style_id"] as int?) ?? 0;
                        double?       material_thickness   = (reader["material_thickness"] as double?) ?? 0;
                        double?       total_cost           = (reader["total_cost"] as double?) ?? 0;
                        double?       converted_cost       = Convert.ToDouble((reader["converted_cost"] as double?) ?? 0);
                        double?       addon_cost           = Convert.ToDouble((reader["addon_cost"] as double?) ?? 0);
                        double?       fire_rating_cost     = Convert.ToDouble((reader["fire_rating_cost"] as double?) ?? 0);
                        double?       security_rating_cost = Convert.ToDouble((reader["security_rating_cost"] as double?) ?? 0);
                        double?       paint_cost           = Convert.ToDouble((reader["paint_cost"] as double?) ?? 0);
                        double?       additional_cost      = Convert.ToDouble((reader["additional_cost"] as double?) ?? 0);
                        double?       discount_percentage  = Convert.ToDouble((reader["discount_percentage"] as double?) ?? 0);
                        SqlConnection conn2 = ConnectionClass.GetConnection_jodan_quote();


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

                        insert_copied_item.Parameters.AddWithValue("@project_id", Valuesclass.project_id);
                        insert_copied_item.Parameters.AddWithValue("@item_id", Valuesclass.max_item_id);
                        insert_copied_item.Parameters.AddWithValue("@order_id", order_id);
                        insert_copied_item.Parameters.AddWithValue("@material_id", material_id);
                        insert_copied_item.Parameters.AddWithValue("@finish_id", finish_id);
                        insert_copied_item.Parameters.AddWithValue("@fire_rating_id", fire_rating_id);
                        insert_copied_item.Parameters.AddWithValue("@security_rating_id", security_rating_id);
                        insert_copied_item.Parameters.AddWithValue("@infill_id", infill_id);
                        insert_copied_item.Parameters.AddWithValue("@jamb_style_id", jamb_style_id);
                        insert_copied_item.Parameters.AddWithValue("@item_notes", reader["item_notes"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@item_date", DateTime.Now);
                        insert_copied_item.Parameters.AddWithValue("@door_ref", reader["door_ref"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@door_type", reader["door_type_id"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@door_style", reader["door_style"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@structual_op_height", reader["structual_op_height"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@structual_op_width", reader["structual_op_width"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@frame_width", reader["frame_width"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@frame_height", reader["frame_height"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@jamb_width", reader["jamb_width"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@jamb_height", reader["jamb_height"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@finish_description", reader["finish_description"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@finish_colour", reader["finish_colour"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@material_thickness", material_thickness);
                        insert_copied_item.Parameters.AddWithValue("@created_by", loginclass.Login.globalFullName);
                        insert_copied_item.Parameters.AddWithValue("@markup_material", reader["markup_material"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@material_cost", reader["material_cost"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@markup_hardware", reader["markup_hardware"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@hardware_cost", reader["hardware_cost"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@labour_rate", reader["labour_rate"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@labour_cost", reader["labour_cost"].ToString());
                        insert_copied_item.Parameters.AddWithValue("@fire_rating_cost", fire_rating_cost);
                        insert_copied_item.Parameters.AddWithValue("@security_rating_cost", security_rating_cost);
                        insert_copied_item.Parameters.AddWithValue("@paint_cost", paint_cost);
                        insert_copied_item.Parameters.AddWithValue("@addon_cost", addon_cost);
                        insert_copied_item.Parameters.AddWithValue("@converted_cost", converted_cost);
                        insert_copied_item.Parameters.AddWithValue("@total_cost", total_cost);
                        insert_copied_item.Parameters.AddWithValue("@additional_cost", additional_cost);
                        insert_copied_item.Parameters.AddWithValue("@discount_percentage", discount_percentage);
                        ConnectionClass.Dispose_connection(conn);



                        insert_copied_item.ExecuteNonQuery();
                        ConnectionClass.Dispose_connection(conn2);
                    }


                    Valuesclass.id = Convert.ToInt32(grid_items_on_quote.Rows[i].Cells["Item_Identity"].Value);
                    Select_quote_id();
                    Copy_hardware();
                    Copy_addon();
                    Fill_data();
                    MessageBox.Show("Item Copy Successful", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch
            {
                // MessageBox.Show(ex.ToString(), "");
            }
        }