示例#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
                {
                }
            }
        }