Пример #1
0
        public void sua(string maptx, int makh, int manv)
        {
            PHIEUTHUEXE ptx = new PHIEUTHUEXE();

            ptx.SOPHIEUTHUEXE = int.Parse(maptx);
            ptx.MAKH          = makh;
            ptx.MANV          = manv;
            ptx.NGAYLAP       = DateTime.Now;
            int s = manv;

            ptx.MATK = int.Parse(timmatk(s));

            DataProvider conext = new DataProvider();
            PHIEUTHUEXE  ptxDB  = conext.PHIEUTHUEXEs.FirstOrDefault(p => p.SOPHIEUTHUEXE.ToString() == ptx.SOPHIEUTHUEXE.ToString());

            if (ptxDB != null)
            {
                ptxDB.SOPHIEUTHUEXE = ptx.SOPHIEUTHUEXE;
                ptxDB.MAKH          = ptx.MAKH;
                ptxDB.MANV          = ptx.MANV;
                ptxDB.NGAYLAP       = ptx.NGAYLAP;
                ptxDB.MATK          = ptx.MATK;
                conext.SaveChanges();
                MessageBox.Show("Sửa thành công.");
            }
        }
Пример #2
0
        public void them(int makh, int manv)
        {
            DataProvider context = new DataProvider();
            PHIEUTHUEXE  ptx     = new PHIEUTHUEXE();

            // ptx.SOPHIEUTHUEXE = int.Parse(txtsophieu.Text);
            ptx.MAKH = makh;
            ptx.MANV = manv;

            int s = manv;

            ptx.MATK = int.Parse(timmatk(s));

            //   ptx.NGAYLAP = DateTime.Now;
            string ngay = String.Format("{0:MM/dd/yyyy}", DateTime.Now);

            DataProvider conext = new DataProvider();
            PHIEUTHUEXE  ptxDB  = conext.PHIEUTHUEXEs.FirstOrDefault(p => p.SOPHIEUTHUEXE.ToString() == ptx.SOPHIEUTHUEXE.ToString());

            if (ptxDB == null)
            {
                context.Database.ExecuteSqlCommand("Insert into PHIEUTHUEXE( NGAYLAP, MAKH,MANV,MATK) Values('" + ngay + "'," + ptx.MAKH + "," + ptx.MANV + "," + ptx.MATK + ")");
                conext.SaveChanges();
            }
        }
Пример #3
0
        public int tinhtongnho(string a, DateTime ngaytra2, int maxe, int solong)
        {
            DataProvider connext = new DataProvider();
            PHIEUTHUEXE  ctptx   = connext.PHIEUTHUEXEs.FirstOrDefault(p => p.SOPHIEUTHUEXE.ToString() == a.ToString());
            XETHUE       xt      = connext.XETHUEs.FirstOrDefault(p => p.MAXE == maxe);

            if (ctptx != null)
            {
                DateTime ngaymuon = ctptx.NGAYLAP.Value.Date;
                DateTime ngaytra  = ngaytra2;//ctptx.NGAYTRAXEDK.Value.Date;
                TimeSpan time     = ngaytra - ngaymuon;
                int      c        = (time.Days * xt.GIAXE.Value) * solong;
                return(c);
            }
            return(0);
        }
Пример #4
0
        public void xoa(string maptx)
        {
            DataProvider context = new DataProvider();
            PHIEUTHUEXE  ptxDB   = context.PHIEUTHUEXEs.FirstOrDefault(p => p.SOPHIEUTHUEXE.ToString() == maptx);

            if (ptxDB == null)
            {
                throw new Exception("khong tim thay");
            }
            DialogResult dig = System.Windows.Forms.MessageBox.Show("Bạn có muốn xóa", "Canh bao", MessageBoxButtons.YesNo);

            if (dig == DialogResult.Yes)
            {
                context.PHIEUTHUEXEs.Remove(ptxDB);
                context.SaveChanges();
            }
        }