public string Them(NiemYetGiaInGiaCongThanhPhamBDO entityBDO) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(tenDB))) { var p = new DynamicParameters(); //Của dapper p.Add("@Ten", entityBDO.Ten); p.Add("@DienGiai", entityBDO.DienGiai); p.Add("@IdBangGia", entityBDO.IdBangGia); p.Add("@IdHangKhachHang", entityBDO.IdHangKhachHang); p.Add("@ThuTu", entityBDO.ThuTu); p.Add("@KhongSuDung", entityBDO.KhongSuDung); p.Add("@LoaiThanhPham", entityBDO.LoaiThanhPham); p.Add("@id", dbType: DbType.Int32, direction: ParameterDirection.Output); //Excecute connection.Execute("dbo.spNiemYetGiaInGiaCongThanhPham_Them", p, commandType: CommandType.StoredProcedure); //xử lý id out entityBDO.Id = p.Get<int>("@id"); ///nếu cần có thể ///đặt return ở đay cũng được } return "Đã thêm"; }
public NiemYetGiaInGiaCongThanhPhamBDO DocTheoId(int iD) { NiemYetGiaInGiaCongThanhPhamBDO output = null; using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(tenDB))) { var p = new DynamicParameters(); p.Add("@id", iD); output = connection.QueryFirstOrDefault<NiemYetGiaInGiaCongThanhPhamBDO>("dbo.spNiemYetGiaInGiaCongThanhPham_DocTheoId", p, commandType: CommandType.StoredProcedure);//Thử return output; } }
public string Sua(NiemYetGiaInGiaCongThanhPhamBDO entityBDO) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(tenDB))) { var p = new DynamicParameters(); //Của dapper p.Add("@id", entityBDO.Id); p.Add("@Ten", entityBDO.Ten); p.Add("@DienGiai", entityBDO.DienGiai); p.Add("@IdBangGia", entityBDO.IdBangGia); p.Add("@IdHangKhachHang", entityBDO.IdHangKhachHang); p.Add("@ThuTu", entityBDO.ThuTu); p.Add("@KhongSuDung", entityBDO.KhongSuDung); p.Add("@LoaiThanhPham", entityBDO.LoaiThanhPham); connection.Execute("dbo.spNiemYetGiaInGiaCongThanhPham_SuaTheoId", p, commandType: CommandType.StoredProcedure); } return $"Đã sửa {entityBDO.Id}"; }
public string Sua(NiemYetGiaInGiaCongThanhPhamBDO entityBDO) { return(dAO.Sua(entityBDO)); }