// GET: Admin/PhieuPhatHanhs/Create
        public ActionResult Create(int loaiVeSoId, System.DateTime ngayPhat)
        {
            ViewBag.LoaiVeSo     = db.LoaiVeSoes.Where(m => m.LoaiVeSoId == loaiVeSoId).Select(m => m.TenTinh).SingleOrDefault();
            ViewBag.NgayPhatHanh = ngayPhat;

            DotPhatHanh dotPhatHanh = new DotPhatHanh();

            dotPhatHanh.NgayPhat   = ngayPhat;
            dotPhatHanh.LoaiVeSoId = loaiVeSoId;
            List <PhieuPhatHanhVM> listPhieuPhatHanh = new List <PhieuPhatHanhVM>();
            var listDaiLyId = db.DaiLies.Select(m => m.DaiLyId).ToList();

            foreach (var item in listDaiLyId)
            {
                PhieuPhatHanhVM phieuPhatHanhVM = new PhieuPhatHanhVM();
                phieuPhatHanhVM.DaiLyId = item;
                DaiLyDao daiLyDao = new DaiLyDao();
                phieuPhatHanhVM.SLPhat   = daiLyDao.TinhToanSLPhatTheoDaiLy(loaiVeSoId, item, ngayPhat);
                phieuPhatHanhVM.TenDaiLy = db.DaiLies.Where(m => m.DaiLyId == item).Select(m => m.TenDaiLy).SingleOrDefault();
                listPhieuPhatHanh.Add(phieuPhatHanhVM);
            }
            dotPhatHanh.ListPhieuPhatHanh = listPhieuPhatHanh;

            return(View(dotPhatHanh));
        }
示例#2
0
        public ActionResult DeleteConfirmed(string id)
        {
            DotPhatHanh dotPhatHanh = db.DotPhatHanhs.Find(id);

            db.DotPhatHanhs.Remove(dotPhatHanh);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#3
0
 public ActionResult Edit([Bind(Include = "MaDaiLy,MaLoaiVeSo,NgayNhan,SoLuong,SLBanDuoc,TienThanhToan,Flag")] DotPhatHanh dotPhatHanh)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dotPhatHanh).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MaDaiLy    = new SelectList(db.DaiLies, "MaDaiLy", "TenDaiLy", dotPhatHanh.MaDaiLy);
     ViewBag.MaLoaiVeSo = new SelectList(db.LoaiVesoes, "MaLoaiVeSo", "Tinh", dotPhatHanh.MaLoaiVeSo);
     return(View(dotPhatHanh));
 }
示例#4
0
        // GET: DotPhatHanh/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DotPhatHanh dotPhatHanh = db.DotPhatHanhs.Find(id);

            if (dotPhatHanh == null)
            {
                return(HttpNotFound());
            }
            return(View(dotPhatHanh));
        }
示例#5
0
        // GET: DotPhatHanh/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DotPhatHanh dotPhatHanh = db.DotPhatHanhs.Find(id);

            if (dotPhatHanh == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MaDaiLy    = new SelectList(db.DaiLies, "MaDaiLy", "TenDaiLy", dotPhatHanh.MaDaiLy);
            ViewBag.MaLoaiVeSo = new SelectList(db.LoaiVesoes, "MaLoaiVeSo", "Tinh", dotPhatHanh.MaLoaiVeSo);
            return(View(dotPhatHanh));
        }
示例#6
0
        /// <summary>
        /// Khởi tạo để cập nhật đợt phát hành
        /// </summary>
        public FormEditDotPhatHanh(string maDotPhatHanh)
        {
            InitializeComponent();

            this.dotPhatHanhBUS = new DotPhatHanhBUS();

            try
            {
                this.dotPhatHanh = this.dotPhatHanhBUS.GetByMaDotPhatHanh(maDotPhatHanh);
            }
            catch (Exception ex)
            {
                this.DialogResult = DialogResult.Abort;

                XtraMessageBox.Show(ex.Message, @"Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public ActionResult Create(DotPhatHanh dotPhatHanh, System.DateTime ngayPhat, int loaiVeSoId)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in dotPhatHanh.ListPhieuPhatHanh)
                {
                    PhieuPhatHanh phieuPhatHanh = new PhieuPhatHanh();
                    phieuPhatHanh.LoaiVeSoId = loaiVeSoId;
                    phieuPhatHanh.NgayPhat   = ngayPhat;
                    phieuPhatHanh.DaiLyId    = db.DaiLies.Where(m => m.TenDaiLy == item.TenDaiLy).Select(m => m.DaiLyId).FirstOrDefault();
                    phieuPhatHanh.SLPhat     = item.SLPhat;
                    db.PhieuPhatHanhs.Add(phieuPhatHanh);
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dotPhatHanh));
        }
        public ActionResult Create(DotPhatHanh dotPhatHanh)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in dotPhatHanh.PhieuPhatHanhs)
                {
                    PhieuPhatHanh phieuPhatHanh = new PhieuPhatHanh();
                    phieuPhatHanh.LoaiVeSoId = dotPhatHanh.LoaiVeSoId;
                    phieuPhatHanh.NgayPhat   = dotPhatHanh.NgayPhat;
                    phieuPhatHanh.DaiLyId    = item.DaiLyId;
                    phieuPhatHanh.SLPhat     = item.SLPhat;
                    db.PhieuPhatHanhs.Add(phieuPhatHanh);
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dotPhatHanh));
        }
示例#9
0
        /// <summary>
        /// Cập nhật loại vé
        /// </summary>
        public void UpdateDotPhatHanh()
        {
            try
            {
                this.dotPhatHanh = new DotPhatHanh(
                    this.dotPhatHanh.MaDotPhatHanh,
                    this.dotPhatHanh.TenDotPhatHanh,
                    this.dotPhatHanh.NgayLap);

                this.dotPhatHanhBUS.Update(this.dotPhatHanh);

                this.DialogResult = DialogResult.OK;

                XtraMessageBox.Show("Cập Nhật Thành Công", @"Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, @"Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#10
0
        /// <summary>
        /// Thêm đợt phát hành
        /// </summary>
        public void InsertDotPhatHanh()
        {
            try
            {
                this.dotPhatHanh = new DotPhatHanh(
                    string.Empty,
                    this.textEdit_TenDotPhatHanh.Text,
                    this.dateEdit_NgayLap.Text);

                this.dotPhatHanhBUS.Insert(this.dotPhatHanh);

                this.DialogResult = DialogResult.OK;

                XtraMessageBox.Show("Thêm Thành Công", @"Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                this.dotPhatHanh = null;

                XtraMessageBox.Show(ex.Message, @"Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }