Exemple #1
0
        // 3. bang chi tiet thiet bi
        public string InsertCTThietBi(CTthietBi ttCTThietBi)
        {
            string        Message;
            SqlConnection con = new SqlConnection(strQuery);

            con.Open();
            SqlCommand cmd = new SqlCommand("insert into CTThietBi(MaTB,MaPH,DonGia,SoLuong) values(@maTB,@idPH,@donGia,@soLuong)", con);

            cmd.Parameters.AddWithValue("@maTB", ttCTThietBi.maTB);
            cmd.Parameters.AddWithValue("@maPH", ttCTThietBi.maPH);
            cmd.Parameters.AddWithValue("@tenTB", ttCTThietBi.maPH);
            cmd.Parameters.AddWithValue("@donGia", ttCTThietBi.donGia);
            cmd.Parameters.AddWithValue("@soluong", ttCTThietBi.soLuong);
            int result = cmd.ExecuteNonQuery();

            if (result == 1)
            {
                Message = "thiet bi co ma" + ttCTThietBi.maTB + "them thanh cong";
            }
            else
            {
                Message = "thiet bi co ma" + ttCTThietBi.maTB + "them khong thanh cong";
            }
            con.Close();
            return(Message);
        }
Exemple #2
0
        public bool DeleteCTThietBi(CTthietBi ttCTThietBi)
        {
            SqlConnection con = new SqlConnection(strQuery);
            SqlCommand    cmd = new SqlCommand("delete from CTThietBi where MaTB=@idTB", con);

            cmd.Parameters.AddWithValue("@idTB", ttCTThietBi.maTB);
            cmd.ExecuteNonQuery();
            con.Close();
            return(true);
        }
Exemple #3
0
        public void UpdateCTThietBi(CTthietBi ttCTThietBi)
        {
            SqlConnection con = new SqlConnection(strQuery);

            con.Open();
            SqlCommand cmd = new SqlCommand("update CTThietBi set MaPH=@MaPH, DonGia=@donGia, SoLuong=@soLuong where MaTB=@idTB", con);

            cmd.Parameters.AddWithValue("@iTB", ttCTThietBi.maTB);
            cmd.Parameters.AddWithValue("@tenTB", ttCTThietBi.maPH);
            cmd.Parameters.AddWithValue("@donGia", ttCTThietBi.donGia);
            cmd.Parameters.AddWithValue("@soluong", ttCTThietBi.soLuong);
            cmd.ExecuteNonQuery();
            con.Close();
        }