예제 #1
0
        public void sua(string mahd, int nhanvien, int phieuthuexe, int xe, int tongtien, DateTime ngaytra)
        {
            DataProvider context = new DataProvider();
            HOADON       hdDH    = context.HOADONs.FirstOrDefault(p => p.MAHD.ToString() == mahd);

            if (hdDH != null)
            {
                hdDH.MAHD          = int.Parse(mahd);
                hdDH.MANV          = nhanvien;
                hdDH.SOPHIEUTHUEXE = phieuthuexe;
                hdDH.MAXE          = xe;
                hdDH.TONGTIENTHUE  = tongtien;
                hdDH.NGAYTRAXETT   = ngaytra;
                context.SaveChanges();
                MessageBox.Show("Cập nhật thành công.");
            }
        }
예제 #2
0
        public void xoa(string mahd)
        {
            DataProvider context = new DataProvider();
            HOADON       hdDB    = context.HOADONs.FirstOrDefault(p => p.MAHD.ToString() == mahd);

            if (hdDB == null)
            {
                throw new Exception("Không tìm tìm thấy hoá đơn.");
            }
            DialogResult dig = MessageBox.Show("Bạn có chắc chắn muốn xoá hoá đơn này", "Cảnh báo", MessageBoxButtons.YesNo);

            if (dig == DialogResult.Yes)
            {
                context.HOADONs.Remove(hdDB);
                context.SaveChanges();
            }
        }
예제 #3
0
        public void them(int nhanvien, int phieuthuexe, int xe, int tongtien, DateTime ngaytra)
        {
            HOADON hd = new HOADON();


            hd.MANV          = nhanvien;
            hd.SOPHIEUTHUEXE = phieuthuexe;

            int s1 = nhanvien;

            hd.MATK = int.Parse(timmatk(s1));

            hd.MAXE = xe;

            int s = phieuthuexe;

            //xe = hd.tim(s);
            //hd.MAXE = int.Parse(xe);

            hd.TONGTIENTHUE = tinhtongmoi(s.ToString(), ngaytra);
            string ngaytr = string.Format("{0:MM/dd/yyyy}", ngaytra);
            //  hd.NGAYTRAXETT = ngaytra;
            string ngay = String.Format("{0:MM/dd/yyyy}", DateTime.Now);
            //  hd.NGAYLAP = DateTime.Now;

            DataProvider context = new DataProvider();
            HOADON       hdDH    = context.HOADONs.FirstOrDefault(p => p.MAHD.ToString() == hd.MAHD.ToString());

            if (hdDH == null)
            {
                try
                {
                    context.Database.ExecuteSqlCommand("Insert into HOADON(NGAYLAPHD,NGAYTRAXETT,TONGTIENTHUE,SOPHIEUTHUEXE,MAXE,MANV,MATK) Values('" + ngay + "','" + ngaytr + "','" + hd.TONGTIENTHUE + "','" + hd.SOPHIEUTHUEXE + "','" + hd.MAXE + "','" + hd.MANV + "'," + hd.MATK + ")");
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Số phiếu này không phù hợp với mã xe bạn đã nhập" +
                                    "\n Hãy tạo phiếu trước khi lập hoá đơn");
                }
            }
        }