public DienNuoc GetId(int maDN) { DienNuoc dn = new DienNuoc(); using (SqlConnection connection = con()) { dn = (DienNuoc)connection.Query <DienNuoc>("SELECT MaDN,DichVu.MaDV,SoCu,SoMoi,ngayChot,PHONGTRO.MaPhongTro,TenDV,TenPhongTro From DienNuoc,DichVu,PHONGTRO where DienNuoc.MaDV=DichVu.MaDV and PHONGTRO.MaPhongTro = DienNuoc.MaPhongTro and maDN=" + maDN).FirstOrDefault(); return(dn); } }
public int Update(DienNuoc dn) { int count = 0; using (SqlConnection connection = con()) { count = connection.Execute("UPDATE DienNuoc SET MaDV= @MaDV, SoCu= @SoCu, SoMoi=@SoMoi,ngayChot=@ngayChot,MaPhongTro=@MaPhongTro WHERE MaDN=@MaDN", dn); } return(count); }
public IActionResult Post(DienNuoc dn) { if (unitOfWork.DienNuoc.Add(dn) == 0) { return(StatusCode(StatusCodes.Status500InternalServerError, new Reponse { Status = "error", Massage = "error" })); } return(Ok(new Reponse { Status = "succes", Massage = "succes" })); }
public void SuaDienNuoc(string maptdn, string maphong, string sdtruoc, string sntruoc, string sdien, string snuoc, string dgdien, string dgnuoc, string tdien, string tnuoc, string thangthu, string masv, string manv, string ghichu) { int SDT = int.Parse(sdtruoc); int SNT = int.Parse(sntruoc); int SD = int.Parse(sdien); int SN = int.Parse(snuoc); double DGD = double.Parse(dgdien); double DGN = double.Parse(dgnuoc); double TD = double.Parse(tdien); TD = (SD - SDT) * DGD; double TN = double.Parse(tnuoc); TN = (SN - SNT) * DGN; DN = new DienNuoc(maptdn, maphong, SDT, SNT, SD, SN, DGD, DGN, TD, TN, thangthu, masv, manv, ghichu); DNDAL.Suadiennuoc(DN); }
public int Add(DienNuoc dn) { int x; using (SqlConnection connection = con()) { connection.Open(); x = connection.Query <DienNuoc>($"SELECT MaDN From DienNuoc Where MaDV=@MaDV and MaPhongTro=@MaPhongTro", dn, commandType: CommandType.Text).Count(); if (x <= 0) { connection.Execute("insert DienNuoc values(@MaDV,@SoCu,@SoMoi,@ngayChot,@MaPhongTro)", dn); return(1); } return(0); } }
public DienNuoc Laydiennuoctheoma(string MaPTDN) { DataTable dt = DNDAL.LayDNTheoMa(MaPTDN); DienNuoc dn = new DienNuoc(); dn.Maptdn = dt.Rows[0][0].ToString(); dn.Maphong = dt.Rows[0][1].ToString(); dn.Sodientruoc = int.Parse(dt.Rows[0][2].ToString()); dn.Sonuoctruoc = int.Parse(dt.Rows[0][3].ToString()); dn.Sodien = int.Parse(dt.Rows[0][4].ToString()); dn.Sonuoc = int.Parse(dt.Rows[0][5].ToString()); dn.Dongiadien = double.Parse(dt.Rows[0][6].ToString()); dn.Dongianuoc = double.Parse(dt.Rows[0][7].ToString()); dn.Tiendien = double.Parse(dt.Rows[0][8].ToString()); dn.Tiennuoc = double.Parse(dt.Rows[0][9].ToString()); dn.Thangthu = dt.Rows[0][10].ToString(); dn.Masinhvien = dt.Rows[0][11].ToString(); dn.Manhanvien = dt.Rows[0][12].ToString(); dn.Ghichu = dt.Rows[0][13].ToString(); return(dn); }
public IActionResult Put(DienNuoc dn) { unitOfWork.DienNuoc.Update(dn); return(Ok()); }
public void XoaDienNuoc(string MaPTDN) { DN = new DienNuoc(MaPTDN, "", '0', '0', '0', '0', '0', '0', '0', '0', "", "", "", ""); DNDAL.Xoadiennuoc(DN); }
public void Xoadiennuoc(DienNuoc dn) { strSQL = "Delete DienNuoc where MaPTDN='" + dn.Maptdn + "'"; helper.ThucThiKN(strSQL); }
public void Suadiennuoc(DienNuoc dn) { strSQL = "Update DienNuoc set MaPhong='" + dn.Maphong + "',SoDienTruoc='" + dn.Sodientruoc + "',SoNuocTruoc='" + dn.Sonuoctruoc + "',SoDien='" + dn.Sodien + "',SoNuoc='" + dn.Sonuoc + "',DonGiaDien='" + dn.Dongiadien + "',DonGiaNuoc='" + dn.Dongianuoc + "',ThanhTienDien='" + dn.Tiendien + "',ThanhTienNuoc='" + dn.Tiennuoc + "',ThangThu='" + dn.Thangthu + "',MaSV='" + dn.Masinhvien + "',MaNV='" + dn.Manhanvien + "',GhiChu=N'" + dn.Ghichu + "' where MaPTDN='" + dn.Maptdn + "'"; helper.ThucThiKN(strSQL); }
public void Themdiennuoc(DienNuoc dn) { strSQL = "Insert into DienNuoc values('" + dn.Maptdn + "','" + dn.Maphong + "','" + dn.Sodientruoc + "','" + dn.Sonuoctruoc + "','" + dn.Sodien + "','" + dn.Sonuoc + "','" + dn.Dongiadien + "','" + dn.Dongianuoc + "','" + dn.Tiendien + "','" + dn.Tiennuoc + "','" + dn.Thangthu + "','" + dn.Masinhvien + "','" + dn.Manhanvien + "',N'" + dn.Ghichu + "' )"; helper.ThucThiKN(strSQL); }