Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(link))
                {
                    string idPhieuNhap = "";
                    conn.Open();
                    SqlCommand comm = new SqlCommand();
                    comm.CommandText = "sp_ThemPhieuNhap1";
                    comm.CommandType = CommandType.StoredProcedure;
                    comm.Connection  = conn;
                    comm.Parameters.AddWithValue("@idPhieuNhap", int.Parse(txtMaPN.Text));
                    comm.Parameters.AddWithValue("@sNgayNhap", txtNgayLap.Text);
                    comm.Parameters.AddWithValue("@idNhanVien", int.Parse(txtMaNv.Text));
                    comm.Parameters.AddWithValue("@sTenNv", txtTenNv.Text);
                    SqlDataReader dr = comm.ExecuteReader();

                    int ire = comm.ExecuteNonQuery();
                    if (ire < 1)
                    {
                        MessageBox.Show("Thêm mới thất bại");
                        reset();
                        checkA = false;
                    }
                    else
                    {
                        MessageBox.Show("Thêm mới thành công");
                        reset();
                        checkA = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            FormCTPhieuNhap formCTPhieuNhap = new FormCTPhieuNhap(idNv, nameNv, idPhieuNhap);

            formCTPhieuNhap.Show();
        }
        private void chiTiếtPhiếuNhậpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormCTPhieuNhap formCTPhieuNhap = new FormCTPhieuNhap(idNv, nameNv, idPhieuNhap);

            formCTPhieuNhap.Show();
        }