Пример #1
0
        private void NewPartToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewPart np = new NewPart(this);

            np.FormClosed += new FormClosedEventHandler(VendorSetupClosed);
            np.Show();
        }
Пример #2
0
        private void Part_combo_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (part_combo.SelectedIndex == 1)
            {
                NewPart np = new NewPart(ms);
                np.FormClosed += new FormClosedEventHandler(PartSetupClosed);
                np.Show();
            }
            else
            {
                try
                {
                    using (SqlConnection conn = new SqlConnection(conn_string))
                    {
                        q = "SELECT PartID, PartDescription, UnitPrice " +
                            "FROM Parts " +
                            "WHERE PartNumber = '" + part_combo.Text + "'";

                        SqlCommand cmd = new SqlCommand();
                        cmd.Connection  = conn;
                        cmd.CommandType = CommandType.Text;
                        cmd.CommandText = q;

                        DataTable      td = new DataTable();
                        SqlDataAdapter da = new SqlDataAdapter(q, conn);
                        conn.Open();
                        da.Fill(td);
                        conn.Close();
                        desc_txb.Text  = td.Rows[0].ItemArray[1].ToString();
                        price_txb.Text = td.Rows[0].ItemArray[2].ToString();
                    }
                    int     qty   = Convert.ToInt16(qty_txb.Text);
                    decimal price = Convert.ToDecimal(price_txb.Text);
                    decimal total = qty * price;
                    total_txb.Text = total.ToString();
                }
                catch
                {
                }
            }
        }
Пример #3
0
        private void AddToOrder_btn_Click(object sender, EventArgs e)
        {
            Get_PartID(part_combo.Text);

            switch (partID)
            {
            case 0:
                if (MessageBox.Show("Part does not exist! \nDo you want to Add " + part_combo.Text +
                                    " to the Parts table?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string  partnumber      = part_combo.Text;
                    string  partdescription = desc_txb.Text;
                    decimal unitprice       = Convert.ToDecimal(price_txb.Text);

                    NewPart np = new NewPart(ms);

                    using (SqlConnection conn = new SqlConnection(conn_string))
                    {
                        q = "SELECT PartID, PartDescription, UnitPrice " +
                            "FROM Parts " +
                            "WHERE PartID = '" + np.Save_Part_With_Return(partnumber, partdescription, unitprice) + "'";

                        SqlCommand cmd = new SqlCommand();
                        cmd.Connection  = conn;
                        cmd.CommandType = CommandType.Text;
                        cmd.CommandText = q;

                        DataTable      td = new DataTable();
                        SqlDataAdapter da = new SqlDataAdapter(q, conn);
                        conn.Open();
                        da.Fill(td);
                        conn.Close();
                        desc_txb.Text  = td.Rows[0].ItemArray[1].ToString();
                        price_txb.Text = td.Rows[0].ItemArray[2].ToString();
                    }
                    int     qty   = Convert.ToInt16(qty_txb.Text);
                    decimal price = Convert.ToDecimal(price_txb.Text);
                    decimal total = qty * price;
                    total_txb.Text = total.ToString();

                    Fill_Part_ComboBox();
                }
                break;

            default:
                newOrderDetails_dataGridView.Rows.Add(new String[]
                                                      { qty_txb.Text,
                                                        unit_combo.Text,
                                                        part_combo.SelectedValue.ToString(),
                                                        part_combo.Text,
                                                        desc_txb.Text,
                                                        price_txb.Text,
                                                        per_combo.Text,
                                                        DBNull.Value.ToString(),
                                                        "False",
                                                        total_txb.Text, });

                newOrderDetails_dataGridView.Sort(part, ListSortDirection.Ascending);
                qty_txb.Clear();
                unit_combo.SelectedIndex = 0;
                part_combo.SelectedIndex = 0;
                desc_txb.Clear();
                price_txb.Clear();
                per_combo.SelectedIndex = 0;
                total_txb.Clear();
                partID = 0;
                break;
            }
        }
Пример #4
0
        private void AddToOrder_btn_Click(object sender, EventArgs e)
        {
            Get_PartID(part_comboBox.Text);

            switch (partid)
            {
            case 0:
                if (MessageBox.Show("Part does not exist! \nDo you want to Add " + part_comboBox.Text +
                                    " to the Parts table?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string  partnumber      = part_comboBox.Text;
                    string  partdescription = partDesc_textbox.Text;
                    decimal unitprice       = 0;

                    NewPart np = new NewPart(ms);

                    using (SqlConnection conn = new SqlConnection(conn_string))
                    {
                        string q = "SELECT PartID, PartDescription, UnitPrice " +
                                   "FROM Parts " +
                                   "WHERE PartID = '" + np.Save_Part_With_Return(partnumber, partdescription, unitprice) + "'";

                        SqlCommand cmd = new SqlCommand();
                        cmd.Connection  = conn;
                        cmd.CommandType = CommandType.Text;
                        cmd.CommandText = q;

                        DataTable      td = new DataTable();
                        SqlDataAdapter da = new SqlDataAdapter(q, conn);
                        conn.Open();
                        da.Fill(td);
                        conn.Close();
                        partDesc_textbox.Text = td.Rows[0].ItemArray[1].ToString();
                    }
                    int     qty   = Convert.ToInt16(qty_textBox.Text);
                    decimal price = Convert.ToDecimal(0);

                    Part_comboBox_Fill();
                }
                else
                {
                    dataGridView1.Rows.Add(new String[]
                                           { DBNull.Value.ToString(),
                                             DBNull.Value.ToString(),
                                             DBNull.Value.ToString(),
                                             DBNull.Value.ToString(),
                                             textBox2.Text, });
                }
                break;

            default:
                if (stock_radioButton.Checked == true)
                {
                    stock = true;
                }
                else if (ordered_radioButton.Checked == true)
                {
                    stock = false;
                }
                dataGridView1.Rows.Add(new String[]
                                       { part_comboBox.SelectedValue.ToString(),
                                         qty_textBox.Text,
                                         partDesc_textbox.Text,
                                         stock.ToString(),
                                         textBox2.Text, });

                dataGridView1.Sort(part, ListSortDirection.Ascending);
                qty_textBox.Clear();
                partDesc_textbox.Clear();
                textBox2.Clear();

                break;
            }
        }