public string tim(int a) { DataProvider connext = new DataProvider(); //PHIEUDENBU pdbDB = connext.PHIEUDENBUs.FirstOrDefault(p => p.SOPDB == a); CTPTHUEXE cttx = connext.CTPTHUEXEs.FirstOrDefault(p => p.SOPHIEUTHUEXE == a); if (cttx != null) { return(cttx.MAXE.ToString()); } return(null); }
public int tinhtongmoi(string a, DateTime ngaytratt) { int i = Convert.ToInt32(a); DataProvider connext = new DataProvider(); CTPTHUEXE ctptx = connext.CTPTHUEXEs.FirstOrDefault(p => p.SOPHIEUTHUEXE == i); if (ctptx != null) { DateTime ngaymuon = ctptx.PHIEUTHUEXE.NGAYLAP.Value.Date; DateTime ngaytra = ngaytratt.Date; TimeSpan time = ngaytra - ngaymuon; int c = (time.Days * ctptx.XETHUE.GIAXE.Value) * ctptx.soluong.Value; return(c); } return(0); }
// thue ham tu bang vao nen ko sua dc public void xoa(int sophieu, int maxe) { DataProvider context = new DataProvider(); CTPTHUEXE ctPtxDB = context.CTPTHUEXEs.FirstOrDefault(p => p.SOPHIEUTHUEXE == sophieu); if (ctPtxDB == null) { throw new Exception("khong tim thay"); } DialogResult dig = MessageBox.Show("Bạn có muốn xóa", "Canh bao", MessageBoxButtons.YesNo); if (dig == DialogResult.Yes) { context.CTPTHUEXEs.Remove(ctPtxDB); context.SaveChanges(); } }
public void sua(int sophieuthue, int maxe, DateTime ngay, int tong, int soluong) { CTPTHUEXE cttx = new CTPTHUEXE(); DataProvider context = new DataProvider(); CTPTHUEXE ptxDB = context.CTPTHUEXEs.FirstOrDefault(p => p.SOPHIEUTHUEXE.ToString() == sophieuthue.ToString()); if (ptxDB != null) { ptxDB.SOPHIEUTHUEXE = sophieuthue; ptxDB.MAXE = maxe; ptxDB.NGAYTRAXEDK = ngay; ptxDB.TONGTIENTHUEXE = tong; ptxDB.soluong = soluong; context.SaveChanges(); } }
public void them(int sophieuthue, int maxe, string ngay, int tongtien, int soluong) { CTPTHUEXE cttx = new CTPTHUEXE(); DataProvider context = new DataProvider(); cttx.SOPHIEUTHUEXE = sophieuthue; cttx.MAXE = maxe; cttx.TONGTIENTHUEXE = tongtien; cttx.soluong = soluong; CTPTHUEXE ptxDB = context.CTPTHUEXEs.FirstOrDefault(p => p.SOPHIEUTHUEXE.ToString() == cttx.SOPHIEUTHUEXE.ToString() && p.MAXE.ToString() == cttx.MAXE.ToString()); if (ptxDB == null) { //context.CTPTHUEXEs.Add(cttx); context.Database.ExecuteSqlCommand("Insert into CTPTHUEXE(SOPHIEUTHUEXE,MAXE,NGAYTRAXEDK,soluong,TONGTIENTHUEXE) Values(" + cttx.SOPHIEUTHUEXE + ", " + cttx.MAXE + ", '" + ngay + "', '" + cttx.soluong + "','" + cttx.TONGTIENTHUEXE + "')"); context.SaveChanges(); } else { MessageBox.Show("Phiếu này đã có"); } }