Exemple #1
0
 protected virtual void PrepareHopDongKhachHang(HopDongModel model)
 {
     model.KhachHang = new HopDongModel.KhachHangModel();
     if (model.KhachHangID > 0)
     {
         var custommer = _customerService.GetCustomerById(model.KhachHangID);
         model.KhachHang.Id       = custommer.Id;
         model.KhachHang.Email    = custommer.Email;
         model.KhachHang.Fullname = custommer.GetFullName();
     }
 }
Exemple #2
0
        public ActionResult TaoHopDong()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.QLHopDong))
            {
                return(AccessDeniedView());
            }
            var model = new HopDongModel();

            //default values
            PrepareListLoaiHopDong(model);
            PrepareListNhaXe(model);
            PrepareHopDongKhachHang(model);
            return(View(model));
        }
Exemple #3
0
        protected virtual void PrepareListNhaXe(HopDongModel model)
        {
            var nhaxes = _nhaxeService.GetAllNhaXe("", 0, 100, false, _workContext.CurrentCustomer.Id);

            if (nhaxes.Count > 0)
            {
                foreach (var s in nhaxes)
                {
                    model.ListNhaXe.Add(new SelectListItem {
                        Text = string.Format("{0} - {1}", s.MaNhaXe, s.TenNhaXe), Value = s.Id.ToString(), Selected = (s.Id == model.NhaXeID)
                    });
                }
            }
        }
        private void loadComboBoxHopDong()
        {
            //Variable
            HopDongModel hopDong      = new HopDongModel();
            DataTable    td           = new DataTable();
            ComboboxItem comboboxItem = new ComboboxItem();

            td = hopDong.getAllTable();
            foreach (DataRow row in td.Rows)
            {
                comboboxItem       = new ComboboxItem();
                comboboxItem.Text  = row[1].ToString(); //Gan ten chuc vu
                comboboxItem.Value = row[0].ToString(); //Gan ma chuc vu

                cbLoaiHopDong.Items.Add(comboboxItem);  //Add item moi vao trong comboBox
            }
        }
Exemple #5
0
        public ActionResult SuaHopDong(HopDongModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.QLHopDong))
            {
                return(AccessDeniedView());
            }

            var hopdong = _chonveService.GetHopDongById(model.Id);

            if (hopdong == null || hopdong.TrangThai != Core.Domain.Chonves.ENTrangThaiHopDong.Moi || hopdong.NguoiTaoID != _workContext.CurrentCustomer.Id)
            {
                //No manufacturer found with the specified id
                return(RedirectToAction("ListHopDong"));
            }

            if (ModelState.IsValid)
            {
                hopdong = model.ToEntity(hopdong);

                //var customer = _customerService.GetCustomerByEmail(model.KhachHang.Email);
                //if (customer != null && !customer.Deleted)
                //{
                //    hopdong.KhachHangID = customer.Id;
                //}

                hopdong.NgayCapNhat = DateTime.UtcNow;
                _chonveService.UpdateHopDong(hopdong);


                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabIndex();

                    return(RedirectToAction("SuaHopDong", hopdong.Id));
                }
                return(RedirectToAction("ListHopDong"));
            }
            return(View(model));
        }
Exemple #6
0
        public ActionResult TaoHopDong(HopDongModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.QLHopDong))
            {
                return(AccessDeniedView());
            }
            if (ModelState.IsValid)
            {
                var hopdong = new HopDong();
                hopdong              = model.ToEntity(hopdong);
                hopdong.NguoiTaoID   = _workContext.CurrentCustomer.Id;
                hopdong.NgayTao      = DateTime.UtcNow;
                hopdong.NgayCapNhat  = null;
                hopdong.NgayHetHan   = null;
                hopdong.NgayKichHoat = null;
                hopdong.TrangThai    = Core.Domain.Chonves.ENTrangThaiHopDong.Moi;
                _chonveService.InsertHopDong(hopdong);
                return(continueEditing ? RedirectToAction("SuaHopDong", new { id = hopdong.Id }) : RedirectToAction("ListHopDong"));
            }

            return(View(model));
        }
Exemple #7
0
 protected virtual void PrepareListLoaiHopDong(HopDongModel model)
 {
     model.ListLoaiHopDong = GetEnumSelectList <ENLoaiHopDong>(model.LoaiHopDongID);
 }
 public static HopDong ToEntity(this HopDongModel model, HopDong destination)
 {
     return(model.MapTo(destination));
 }
 public static HopDong ToEntity(this HopDongModel model)
 {
     return(model.MapTo <HopDongModel, HopDong>());
 }