private void button4_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                errorProvider1.Clear();
                errorProvider1.SetError(textBox1, "Please Enter Serial Number");
            }
            else
            {
                errorProvider1.Clear();
                conn();

                string s = "Select * from Service where Serial=@sn";

                cmd.CommandText = s;

                cmd.Parameters.AddWithValue("@sn", textBox1.Text);

                SqlDataReader dr = cmd.ExecuteReader();

                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        textBox1.Text     = dr[5].ToString();
                        textBox2.Text     = dr[3].ToString();
                        textBox3.Text     = dr[4].ToString();
                        textBox4.Text     = dr[6].ToString();
                        textBox5.Text     = dr[7].ToString();
                        textBox6.Text     = dr[9].ToString();
                        richTextBox2.Text = dr[10].ToString();
                    }


                    scon.Close();
                    SearchDone sd = new SearchDone();
                    sd.Show();
                }
                else
                {
                    RecordDone rd = new RecordDone();
                    rd.Show();
                }
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                errorProvider1.SetError(textBox1, "Please Enter Serial Number");
            }
            else
            {
                errorProvider1.Clear();

                conn();
                string s = "Select * from Car where Serial=@sn";

                cmd.CommandText = s;

                cmd.Parameters.AddWithValue("@sn", textBox1.Text);

                SqlDataReader rd = cmd.ExecuteReader();

                if (rd.HasRows)
                {
                    int count = 0;
                    while (rd.Read())
                    {
                        textBox1.Text  = rd[2].ToString();
                        comboBox1.Text = rd[3].ToString();
                        comboBox2.Text = rd[4].ToString();
                        comboBox3.Text = rd[5].ToString();
                        comboBox4.Text = rd[6].ToString();
                        textBox2.Text  = rd[7].ToString();
                        count++;
                    }


                    scon.Close();
                    SearchDone sd = new SearchDone();
                    sd.Show();
                }
                else
                {
                    RecordDone rdd = new RecordDone();
                    rdd.Show();
                }
            }
        }
Пример #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" && comboBox5.Text == "")
            {
                errorProvider1.SetError(textBox1, "Please Enter Customer Name OR Serial Number");
                errorProvider1.SetError(comboBox5, "Please Enter Customer Name OR Serial Number");
            }
            else
            {
                errorProvider1.Clear();


                if (textBox1.Text != "")
                {
                    conn();
                    string s_name = "Select c.Name,c.Street,c.City,c.Prov,c.Pcode,c.Phone,cr.Serial,cr.Model,cr.Trim,cr.Color,cr.Year,cr.Price,cr.Purchinv,cr.Purchdate from Customer c,Car cr WHERE c.ID=cr.Cid AND c.Name=@cname";
                    cmd1.CommandText = s_name;
                    cmd1.Parameters.AddWithValue("@cname", textBox1.Text);

                    SqlDataReader dr = cmd1.ExecuteReader();
                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            textBox1.Text  = dr[0].ToString();
                            textBox2.Text  = dr[1].ToString();
                            textBox3.Text  = dr[2].ToString();
                            textBox4.Text  = dr[3].ToString();
                            textBox5.Text  = dr[4].ToString();
                            textBox6.Text  = dr[5].ToString();
                            comboBox5.Text = dr[6].ToString();
                            comboBox1.Text = dr[7].ToString();
                            comboBox2.Text = dr[8].ToString();
                            comboBox3.Text = dr[9].ToString();
                            comboBox4.Text = dr[10].ToString();
                            textBox8.Text  = dr[11].ToString();
                            textBox9.Text  = dr[13].ToString();
                            textBox10.Text = dr[12].ToString();
                        }
                        SearchDone sd = new SearchDone();
                        sd.Show();
                    }
                    else
                    {
                        RecordDone rdd = new RecordDone();
                        rdd.Show();
                    }
                }
                else if (comboBox5.Text != "")
                {
                    conn();
                    string s_cid = "Select DISTINCT c.Name,c.Street,c.City,c.Prov,c.Pcode,c.Phone,cr.Serial,cr.Model,cr.Trim,cr.Color,cr.Year,cr.Price,cr.Purchinv,cr.Purchdate from Customer c,Car cr where c.ID=cr.Cid AND cr.Serial=@serial";

                    cmd2.CommandText = s_cid;
                    cmd2.Parameters.AddWithValue("@serial", comboBox5.Text);
                    SqlDataReader dr = cmd2.ExecuteReader();
                    if (dr.HasRows)
                    {
                        int count = 0;
                        while (dr.Read())
                        {
                            textBox1.Text  = dr[0].ToString();
                            textBox2.Text  = dr[1].ToString();
                            textBox3.Text  = dr[2].ToString();
                            textBox4.Text  = dr[3].ToString();
                            textBox5.Text  = dr[4].ToString();
                            textBox6.Text  = dr[5].ToString();
                            comboBox5.Text = dr[6].ToString();
                            comboBox1.Text = dr[7].ToString();
                            comboBox2.Text = dr[8].ToString();
                            comboBox3.Text = dr[9].ToString();
                            comboBox4.Text = dr[10].ToString();
                            textBox8.Text  = dr[11].ToString();
                            textBox9.Text  = dr[13].ToString();
                            textBox10.Text = dr[12].ToString();
                            count++;
                        }
                        SearchDone sd = new SearchDone();
                        sd.Show();
                    }
                    else
                    {
                        RecordDone rdd = new RecordDone();
                        rdd.Show();
                    }
                }

                scon.Close();
            }
        }