Example #1
0
        private void buttonchitiethd_Click(object sender, EventArgs e)
        {
            chitiethoadon f = new chitiethoadon();

            f.mahd = textBoxmahd.Text;
            f.Show();
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DateTime idate;

            idate = dateTimePicker3.Value;
            SqlConnection cnn = new SqlConnection(constr);

            cnn.Open();
            string     select = "SELECT * FROM Hoadon WHERE MAHOADON = @mhd ";
            SqlCommand cm     = new SqlCommand(select, cnn);

            cm.Parameters.AddWithValue("@mhd", textBoxmahd.Text);
            cm.ExecuteNonQuery();
            SqlDataReader dta = cm.ExecuteReader();

            if (dta.Read() == false)
            {
                cnn.Close();
                cnn.Open();
                string     insert = "INSERT INTO dbo.Hoadon VALUES (@mhd,@tenkh,@nl,0)";
                SqlCommand cmd    = new SqlCommand(insert, cnn);
                cmd.Parameters.AddWithValue("@mhd", textBoxmahd.Text);
                cmd.Parameters.AddWithValue("@tenkh", textBoxtenkhach.Text);
                cmd.Parameters.AddWithValue("@nl", idate.ToShortDateString());
                cmd.ExecuteNonQuery();
                chitiethoadon f = new chitiethoadon();
                f.mahd = textBoxmahd.Text;
                f.Show();
            }
            else
            {
                MessageBox.Show("Chức Năng Chỉ Dành Cho Thêm Mới. Mời Bấm 'Chi Tiết' Để Xem Chi Tiết Hóa Đơn ");
                textmasach.Focus();
            }
        }