示例#1
0
 public phieumuontra_ett(tbl_phieumuon_tra phieu)
 {
     sophieumuon = phieu.sophieumuon;
     madg = (int)phieu.madg;
     manv = (int)phieu.manv;
     ngaymuon = phieu.ngaymuon;
     ngaytra = phieu.ngaytra;
     xacnhantra = (bool)phieu.xacnhantra;
     ghichu = phieu.ghichu;
 }
示例#2
0
 public phieumuontra_ett(tbl_phieumuon_tra phieu)
 {
     sophieumuon = phieu.sophieumuon;
     madg        = (int)phieu.madg;
     manv        = (int)phieu.manv;
     ngaymuon    = phieu.ngaymuon;
     ngaytra     = phieu.ngaytra;
     xacnhantra  = (bool)phieu.xacnhantra;
     ghichu      = phieu.ghichu;
 }
示例#3
0
        public Result <phieumuontra_ett> insert_phieumuontra(phieumuontra_ett phieumuontra, List <string> list_masach)
        {
            Result <phieumuontra_ett> rs = new Result <phieumuontra_ett>();

            try
            {
                // create new tbl_phieumuontra to insert to database_context
                tbl_phieumuon_tra temp = new tbl_phieumuon_tra();
                temp.manv       = phieumuontra.manv;
                temp.madg       = phieumuontra.madg;
                temp.ngaytra    = phieumuontra.ngaytra;
                temp.ngaymuon   = phieumuontra.ngaymuon;
                temp.xacnhantra = phieumuontra.xacnhantra;
                temp.ghichu     = phieumuontra.ghichu;

                db.tbl_phieumuon_tras.InsertOnSubmit(temp);

                if (list_masach.Count() > 0)
                {
                    foreach (string item in list_masach)
                    {
                        var dt = db.tbl_saches.Where(o => o.masach == int.Parse(item)).SingleOrDefault();
                        dt.soluong--;
                    }
                }

                db.SubmitChanges();

                var last_record = db.tbl_phieumuon_tras.OrderByDescending(o => o.sophieumuon).Take(1);
                if (last_record.Count() > 0)
                {
                    foreach (var item in last_record)
                    {
                        phieumuontra_ett temp1 = new phieumuontra_ett(item);
                        rs.data = temp1;
                    }
                }
                rs.errcode = ErrorCode.sucess;
                return(rs);
            }
            catch (Exception e)
            {
                rs.data     = null;
                rs.errcode  = ErrorCode.fail;
                rs.errInfor = e.ToString();
                return(rs);
            }
        }
示例#4
0
        public Result<phieumuontra_ett> insert_phieumuontra(phieumuontra_ett phieumuontra, List<string> list_masach)
        {
            Result<phieumuontra_ett> rs = new Result<phieumuontra_ett>();

            try
            {
                // create new tbl_phieumuontra to insert to database_context
                tbl_phieumuon_tra temp = new tbl_phieumuon_tra();
                temp.manv = phieumuontra.manv;
                temp.madg = phieumuontra.madg;
                temp.ngaytra = phieumuontra.ngaytra;
                temp.ngaymuon = phieumuontra.ngaymuon;
                temp.xacnhantra = phieumuontra.xacnhantra;
                temp.ghichu = phieumuontra.ghichu;

                db.tbl_phieumuon_tras.InsertOnSubmit(temp);

                if (list_masach.Count() > 0)
                {
                    foreach (string item in list_masach)
                    {
                        var dt = db.tbl_saches.Where(o => o.masach == int.Parse(item)).SingleOrDefault();
                        dt.soluong--;
                    }
                }

                db.SubmitChanges();

                var last_record = db.tbl_phieumuon_tras.OrderByDescending(o => o.sophieumuon).Take(1);
                if (last_record.Count() > 0)
                {
                    foreach (var item in last_record)
                    {
                        phieumuontra_ett temp1 = new phieumuontra_ett(item);
                        rs.data = temp1;
                    }
                }
                rs.errcode = ErrorCode.sucess;
                return rs;
            }
            catch (Exception e)
            {
                rs.data = null;
                rs.errcode = ErrorCode.fail;
                rs.errInfor = e.ToString();
                return rs;
            }
        }