public List <DTO.Chitiethoadonxuat> Laysanpham(int masp) { List <DTO.Chitiethoadonxuat> list = new List <DTO.Chitiethoadonxuat>(); string sql = "SELECT MASP,TENSP,DONGIA,GIAMGIA FROM SANPHAM WHERE MASP = " + masp; SqlConnection con = dc.getConnect(); cmd = new SqlCommand(sql, con); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { DTO.Chitiethoadonxuat cthd = new DTO.Chitiethoadonxuat(); cthd.MASP1 = Int32.Parse(dr["MASP"].ToString()); cthd.TENSP1 = dr["TENSP"].ToString(); cthd.GIATIEN1 = Int32.Parse(dr["DONGIA"].ToString()); cthd.GIAMGIA1 = Int32.Parse(dr["GIAMGIA"].ToString()); list.Add(cthd); } return(list); }
public bool Themchitiethoadonxuat(DTO.Chitiethoadonxuat cthdx) { string sql = "INSERT INTO CHITIETHOADONXUAT(MAHDX,MASP,TENSP,SOLUONG,GIATIEN,GIAMGIA)VALUES(@MAHDX, @MASP, @TENSP, @SOLUONG, @GIATIEN, @GIAMGIA)"; SqlConnection con = dc.getConnect(); try { con.Open(); cmd = new SqlCommand(sql, con); cmd.Parameters.Add("@MAHDX", SqlDbType.Int).Value = cthdx.MAHDX1; cmd.Parameters.Add("@MASP", SqlDbType.Int).Value = cthdx.MASP1; cmd.Parameters.Add("@TENSP", SqlDbType.NVarChar).Value = cthdx.TENSP1; cmd.Parameters.Add("@SOLUONG", SqlDbType.Int).Value = cthdx.SOLUONG1; cmd.Parameters.Add("@GIATIEN", SqlDbType.Int).Value = cthdx.GIATIEN1; cmd.Parameters.Add("@GIAMGIA", SqlDbType.Int).Value = cthdx.GIAMGIA1; cmd.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(false); } return(true); }
public bool Themchitiethoadonxuat(DTO.Chitiethoadonxuat cthdx) { return(hdxd.Themchitiethoadonxuat(cthdx)); }