public void GetUnit(int?userId)
        {
            qtUnitService _service = new qtUnitService();

            IEnumerable <qtUnit> list = _service.FindList().AsQueryable().Where(r => r.Status == true && r.ParentId != 0);
            string html = string.Empty;

            html += "<table class='grid' style='width: 100%;'>" +
                    "<thead>" +
                    "<tr>" +
                    "<th><input type='checkbox' name='cbxList' id='cbxList'></th>" +
                    "<th> Tên đơn vị </th>" +

                    "</thead>";
            foreach (qtUnit unit in list)
            {
                string check = checkUnit(userId, unit.UnitId);
                html += "<tr>" +
                        "<td style='text-align: center;'><input type='checkbox' value=" + unit.UnitId + " name='cbxUnit' id='cbxUnit' " + check + " ></td>" +
                        "<td>" + unit.UnitName + "</td>" +
                        "</tr>";
            }
            html            += "</table>";
            ViewBag.UnitList = html;
        }
        private string TreeUnit(int?DepId)
        {
            string html = string.Empty;

            qtUnitService        _unit = new qtUnitService();
            IEnumerable <qtUnit> list  = _unit.FindList().Where(m => m.Status == true).OrderBy(m => m.SortOrder);

            if (list != null && list.Count() > 0)
            {
                html += "<div id='tree'>";
                foreach (qtUnit unit in list)
                {
                    qtDepartmentService        _dep = new qtDepartmentService();
                    IEnumerable <qtDepartment> dep  = _dep.FindList()
                                                      .Where(m => m.UnitId == unit.UnitId && m.Status == true).OrderBy(m => m.SortOrder);
                    html += "<ul><li>" + unit.UnitName + "</a>";

                    if (dep != null && dep.Count() > 0)
                    {
                        html += "<ul>";
                        foreach (qtDepartment item in dep)
                        {
                            html += "<li><a  href='/QuanTri/Substitute/Index?DepartmentId=" + item.DepartmentId + "'>" + item.DepartmentName +
                                    //"(" + item.Substitutes.Count() + ")" +
                                    "</a></li>";
                        }
                        html += "</ul>";
                    }
                    html += "</li></ul>";
                }
                html += "</div>";
            }
            return(html);
        }
        private string TreeUnit(int?unitId)
        {
            string html = string.Empty;

            qtUnitService        _unit    = new qtUnitService();
            qtUnitManagerService _manager = new qtUnitManagerService();

            IEnumerable <qtUnit> list = _unit.FindList().Where(m => m.Status == true).OrderBy(m => m.SortOrder);

            if (list != null && list.Count() > 0)
            {
                html += "<div class='treeview'>";
                foreach (qtUnit unit in list)
                {
                    string css = "";
                    //int soluong = _manager.SoluongNguoiDung(unit.UnitId);
                    int soluong = _manager.SoluongNguoiDung(unit.UnitId);
                    if (unitId.HasValue)
                    {
                        if (unitId == unit.UnitId)
                        {
                            css = " expanded";
                        }
                    }
                    html += "<ul class='ul-tree '><li class='" + css + "'><img class='toggler " + css + "'  /><a  href='/QuanTri/UnitManager/Index?UnitId=" + unit.UnitId + "'>" + unit.UnitName + "(" + soluong + ")</a>";

                    html += "</li></ul>";
                }
                html += "</div>";
            }
            return(html);
        }
Exemple #4
0
        private string TreeUnit(int?unitId)
        {
            string html = string.Empty;

            qtUnitService        _unit = new qtUnitService();
            IEnumerable <qtUnit> list  = _unit.FindList().Where(m => m.Status == true).OrderBy(m => m.SortOrder);

            if (list != null && list.Count() > 0)
            {
                html += "<div id='tree' class=''>";
                foreach (qtUnit unit in list)
                {
                    qtUserConfigService        _userconfig = new qtUserConfigService();
                    IEnumerable <qtUserConfig> userconfig  = _userconfig.FindList().Where(m => m.UnitId == unit.UnitId && m.IsActive == true);
                    html += "<ul><li><a  href='/QuanTri/UserConfig/Index?UnitId=" + unit.UnitId + "'>" + unit.UnitName + "(" + userconfig.Count() + ")</a>";
                    if (userconfig != null && userconfig.Count() > 0)
                    {
                        html += "<ul>";
                        foreach (qtUserConfig config in userconfig)
                        {
                            html += "<li>" + config.AppName + "</li>";
                        }
                        html += "</ul>";
                    }
                    html += "</li></ul>";
                }
                html += "</div>";
            }
            return(html);
        }
Exemple #5
0
        private void DropDownList(int?unitId)
        {
            qtUnitService        _unit    = new qtUnitService();
            IEnumerable <qtUnit> listUnit = _unit.FindList().Where(m => m.Status == true).OrderBy(m => m.SortOrder);

            ViewBag.UnitId = new SelectList(listUnit, "UnitId", "UnitName", unitId);
        }
        private void DropDownListView(int?depId, int?posId, int?unitId)
        {
            string dep  = "";
            string pos  = "";
            string unit = "";

            if (depId.HasValue)
            {
                dep = depId.ToString();
            }
            if (posId.HasValue)
            {
                pos = posId.ToString();
            }
            if (unitId.HasValue)
            {
                unit = unitId.ToString();
            }


            qtPositionService        _position = new qtPositionService();
            IEnumerable <qtPosition> listPos   = _position.FindList().Where(m => m.Status == true);

            ViewBag.PositionID = new SelectList(listPos, "PositionID", "PositionName", pos);

            qtUnitService        _unit    = new qtUnitService();
            IEnumerable <qtUnit> listUnit = _unit.FindList().Where(m => m.Status == true).OrderBy(m => m.SortOrder);

            ViewBag.UnitId = new SelectList(listUnit, "UnitId", "UnitName", unit);
        }
Exemple #7
0
        public void ThongTin(qtUser user)
        {
            qtDepartmentService _department = new qtDepartmentService();
            qtUnitService       _unit       = new qtUnitService();
            qtPositionService   _position   = new qtPositionService();

            ViewBag.TenPhong = _department.FindByKey(user.DepartmentId).DepartmentName;
            ViewBag.TenDonVi = _unit.FindByKey(user.UnitId).UnitName;
            ViewBag.ChucVu   = _position.FindByKey(user.PositionId).PositionName;
        }
Exemple #8
0
        public PartialViewResult Units(int?UnitId)
        {
            qtUnitService _unit = new qtUnitService();

            IEnumerable <qtUnit> danhSachDonVi = _unit.FindList();

            SelectList select = new SelectList(danhSachDonVi, "UnitId", "UnitName", UnitId);

            return(PartialView("Units", select));
        }
        public void DropNhapDuLieu(int?_LoaiPhieu, int?MaKho, int?TrangThai, int PhieuXuatNhap)
        {
            LoaiPhieuNhapService        _loai     = new LoaiPhieuNhapService();
            IEnumerable <LoaiPhieuNhap> LoaiPhieu = _loai.DanhSachPhieuNhap(PhieuXuatNhap);

            ViewBag.LoaiPhieu = new SelectList(LoaiPhieu, "LoaiPhieuNhapId", "TenLoaiPhieuNhap", _LoaiPhieu);

            qtUnitService        _unit  = new qtUnitService();
            IEnumerable <qtUnit> dsUnit = _unit.FindList().Where(x => x.ParentId != null && x.ParentId != 0);

            ViewBag.Kho = new SelectList(dsUnit, "UnitId", "UnitName", MaKho);

            ViewBag.SizeGuid = new SelectList(new List <shSetSize>(), "Value", "Text");

            ViewBag.TrangThai = new SelectList(GoodReceiptIsuueHelper.DanhSachTrangThaiNhapXuatKho(null), "Value", "Text", TrangThai);
        }
Exemple #10
0
        public PartialViewResult ListUnits(int?page)
        {
            int pageCurrent = 1;

            if (page.HasValue)
            {
                pageCurrent = page.Value;
            }

            qtUnitService _unit = new qtUnitService();

            IPagedList <qtUnit> dsUnit = _unit.DanhSachUnit_PhanTrang(pageCurrent, Config.PAGE_SIZE_10);

            ViewBag.ListUnits = dsUnit;

            return(PartialView("ListUnits", dsUnit));
        }
        private void DropDownListView(int?unitId, int?departmentId)
        {
            qtUnitService        _unit    = new qtUnitService();
            IEnumerable <qtUnit> listUnit = _unit.FindList().Where(m => m.Status == true).OrderBy(m => m.SortOrder);

            ViewBag.UnitId = new SelectList(listUnit, "UnitId", "UnitName", unitId);

            qtDepartmentService        _dep    = new qtDepartmentService();
            IEnumerable <qtDepartment> listDep = _dep.FindList().Where(m => m.Status == true && m.UnitId == unitId)
                                                 .OrderBy(m => m.SortOrder);

            ViewBag.DepartmentId = new SelectList(listDep, "DepartmentId", "DepartmentName", departmentId);

            //List<Unit> list = _unit.FindList().Where(m => m.IsActive == true).OrderBy(m => m.SortOrder).ToList();
            //AutoComplete program = new AutoComplete();
            //SelectList select = new SelectList(list, "UnitId", "UnitName", unitId);
            //program.languanges = select;
            //ViewBag.UnitId = program.languanges;
        }
Exemple #12
0
        public ActionResult Create(int?DonViId, string UnitCode, string UnitName, int?UnitId, int?SortOrder, string LevelCode, string Email, string PhoneNumber, bool?Status)
        {
            if (!DonViId.HasValue)
            {
                DonViId = 0;
            }
            qtUnitService _unit = new qtUnitService();

            qtUnit unit = _unit.ThemMoi_HieuChinhUnit(
                DonViId.Value,
                UnitName,
                UnitCode,
                UnitId,
                LevelCode,
                SortOrder,
                Email,
                PhoneNumber,
                Status,
                DateTime.Now);

            return(RedirectToAction("Index"));
        }
Exemple #13
0
        public ActionResult Create(int?id, int?UnitId)
        {
            qtUnitService _unit = new qtUnitService();
            qtUnit        unit  = new qtUnit();

            if (id.HasValue)
            {
                unit = _unit.FindByKey(id);
                if (unit != null)
                {
                    ViewBag.DonViId = unit.UnitId;
                    return(View(unit));
                }
                else
                {
                    ModelState.AddModelError("", "Dữ liệu không tồn tại trong hệ thống. Vui lòng kiểm tra lại");
                    return(View(new qtUnit()));
                }
            }

            return(View(unit));
        }
Exemple #14
0
        public ActionResult Order(int?p, int?pay_type, string City, string Town, string order_name, string order_address, string order_phone, string order_email, string base_remark)
        {
            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        #region Get Infor login
                        string MemberGuid   = string.Empty;
                        bool   isCoTaiKhoan = false;

                        if (string.IsNullOrEmpty(User.Identity.GetMemberLogin().MemberGuid) ||
                            string.IsNullOrWhiteSpace(User.Identity.GetMemberLogin().MemberGuid))
                        {
                            //return Redirect("/dang-nhap?urlPrefix=/gio-hang");
                            isCoTaiKhoan = false;
                        }
                        else
                        {
                            isCoTaiKhoan = true;
                            MemberGuid   = User.Identity.GetMemberLogin().MemberGuid;
                        }

                        var cart = Session[CartSession];
                        if (cart == null)
                        {
                            TempData["Cart"] = "Giỏ hàng trống. Vui lòng thao tác lại.";
                            return(Redirect("/gio-hang"));
                        }

                        cart = cart as List <CartItem>;
                        shSizeService _size = new shSizeService();
                        decimal       price = _size.ListProductPrice_Quantity(cart as List <CartItem>, 0, 0, 0);

                        decimal Feeship = Config.FeeShip;
                        if (price > Config.FeeTotal)
                        {
                            Feeship = 0;
                        }

                        int _Status = OrderStatus.DangXuLy.GetHashCode();

                        shOrderService _order = new shOrderService();
                        #endregion

                        #region Tìm nhân viên random được chọn xử lý đơn hàng
                        // ds nhân viên được phân xử lý đơn hàng
                        qtUser        UserId             = new qtUser();
                        List <qtUser> dsUser_XuLyDonhang = CommonHelper.GetUserTheoMaCauHinhHeThong_GetTheoUser(Config.TAI_KHOAN_NHAN_DON_HANG, Units.ChiNhanhShowRoom.GetHashCode()).ToList();

                        int userid_dagiaoviec         = 0;
                        IEnumerable <shOrder> dsOrder = _order.DanhSachOrder()
                                                        .Where(x => x.UserId != null && x.UserId != 0)
                                                        .OrderByDescending(x => x.OrderId);

                        foreach (var item in dsOrder)
                        {
                            if (item.UserId != null && item.UserId != 0)
                            {
                                userid_dagiaoviec = item.UserId.Value;
                                break;
                            }
                        }

                        for (int i = 0; i < dsUser_XuLyDonhang.Count(); i++)
                        {
                            qtUser user = dsUser_XuLyDonhang[i];

                            if (user.UserId == userid_dagiaoviec)
                            {
                                if (i == (dsUser_XuLyDonhang.Count() - 1))
                                {
                                    UserId = dsUser_XuLyDonhang[0];
                                }
                                else if (i < (dsUser_XuLyDonhang.Count() - 1))
                                {
                                    UserId = dsUser_XuLyDonhang[i + 1];
                                }
                            }
                        }
                        #endregion

                        #region shOrder
                        shOrder order = _order.Insert_Update(
                            null,
                            null,
                            null,
                            MemberGuid,
                            order_name,
                            order_email,
                            order_phone,
                            order_address,
                            price,
                            _Status,
                            null,
                            TypeHelper.ToInt32(Town),
                            TypeHelper.ToInt32(City),
                            Feeship,
                            true,
                            DateTime.Now,
                            pay_type,
                            DateTime.Now,
                            UserId.UserId
                            );
                        #endregion

                        #region shOrderHistory
                        shOrderHistoryService _orderHistory = new shOrderHistoryService();
                        shOrderHistory        orderHistory  = _orderHistory.Insert_Update(
                            null,
                            order.OrderGuid,
                            _Status,
                            User.Identity.GetMemberLogin().MemberGuid,
                            "Đặt hàng",
                            null,
                            true,
                            DateTime.Now);

                        #endregion

                        #region shOrderDetail
                        shOrderDetailService _orderDetail = new shOrderDetailService();
                        price = 0;
                        decimal total = 0;
                        foreach (var item in cart as List <CartItem> )
                        {
                            price = _size.ProductPrice(item.SizeGuid);
                            total = price * item.Quantity;

                            _orderDetail.Insert_Update(
                                null,
                                null,
                                null,
                                order.OrderGuid,
                                MemberGuid,
                                item.Product.ProductGuid,
                                item.Product.ProductName,
                                item.SectionGuid,
                                item.SizeGuid,
                                item.Quantity,
                                price,
                                total,
                                true,
                                DateTime.Now,
                                DateTime.Now
                                );
                        }
                        #endregion

                        #region SEND EMAIL, MESSAGE
                        // 1. Gửi Email tới Quản trị viên xác nhận đơn hàng

                        /// ds User cấu hình nhận Email trong hệ thống
                        IEnumerable <qtUser> dsUser = CommonHelper.GetUserTheoMaCauHinhHeThong_GetTheoUser(Config.TAI_KHOAN_EMAIL_THONG_BAO_TIEP_NHAN_DON_HANG, Units.ChiNhanhShowRoom.GetHashCode());
                        string noidungdonhang       = EmailHelper.NoiDungDonHang(order, cart as List <CartItem>);
                        string noidungEmail         = string.Empty;
                        foreach (var user in dsUser)
                        {
                            noidungEmail = string.Empty;
                            qtUnitService _unit = new qtUnitService();
                            noidungEmail = EmailHelper.NoiDungMailThongBaoQuanTri(_unit.UnitName(Units.ChiNhanhShowRoom.GetHashCode()), 1, noidungdonhang);
                            EmailHelper.ThongBaoEmailDonHangMoi(user.Email, noidungEmail);
                        }

                        if (UserId.UserId > 0)
                        {
                            noidungEmail = string.Empty;
                            qtUnitService _unit = new qtUnitService();
                            noidungEmail = EmailHelper.NoiDungMailThongBaoQuanTri(_unit.UnitName(Units.ChiNhanhShowRoom.GetHashCode()), 1, noidungdonhang);
                            EmailHelper.ThongBaoEmailDonHangMoi(UserId.Email, noidungEmail);
                        }

                        // 2. Gửi Email xác nhận đơn hàng tới khách hàng
                        noidungEmail = "";
                        if (isCoTaiKhoan)
                        {
                            noidungEmail = EmailHelper.NoiDungMailThongBaoNguoiDatHang(noidungdonhang);
                            EmailHelper.ThongBaoEmailDonHangMoiToiNguoiDatHang(User.Identity.GetMemberLogin().Email, noidungEmail);
                        }
                        // 3. Gửi thông báo tới Quản trị viên nhận thông báo
                        ThongBaoService _thongbao = new ThongBaoService();
                        foreach (var user in dsUser)
                        {
                            int?Memberid = null;
                            if (isCoTaiKhoan)
                            {
                                Memberid = User.Identity.GetMemberLogin().MemberId;
                            }

                            _thongbao.InsertOrUpdate(
                                null,
                                "Thông báo đơn hàng mới. Người đặt hàng: " + order_name + ", giá trị: " + Format.FormatDecimalToString(price),
                                "Bạn có đơn hàng mới cần xử lý từ khách hàng: " + order_name +
                                " với đơn hàng tổng giá trị: " + Format.FormatDecimalToString(price) +
                                " lúc: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm") +
                                ". Vui lòng truy cập hệ thống để xử lý",
                                "/DanhMuc/Order/Index/s=" + order.OrderGuid,
                                Memberid,
                                user.UserId,
                                DateTime.Now,
                                false,
                                Config.THONG_BAO_DON_HANG_MOI,
                                null
                                );
                        }

                        if (UserId.UserId > 0)
                        {
                            int?Memberid = null;
                            if (isCoTaiKhoan)
                            {
                                Memberid = User.Identity.GetMemberLogin().MemberId;
                            }

                            _thongbao.InsertOrUpdate(
                                null,
                                "Thông báo đơn hàng mới. Người đặt hàng: " + order_name + ", giá trị: " + Format.FormatDecimalToString(price),
                                "Bạn có đơn hàng mới cần xử lý từ khách hàng: " + order_name +
                                " với đơn hàng tổng giá trị: " + Format.FormatDecimalToString(price) +
                                " lúc: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm") +
                                ". Vui lòng truy cập hệ thống để xử lý",
                                "/DanhMuc/Order/Index/s=" + order.OrderGuid,
                                Memberid,
                                UserId.UserId,
                                DateTime.Now,
                                false,
                                Config.THONG_BAO_DON_HANG_MOI,
                                null
                                );
                        }

                        #endregion

                        #region Clear data cookies after order
                        Session[CartSession] = null;
                        #endregion

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }

            return(Redirect("/thong-tin-ca-nhan"));
        }
        public List <TreeView> GetUnitTreeView(bool isShowDepartment)
        {
            qtUnitService _unit = new qtUnitService();

            IEnumerable <qtUnit> dsUnit = _unit.FindList()
                                          .Where(x => x.ParentId == null || x.ParentId == 0);

            List <TreeView> dsTreeView = new List <TreeView>();
            TreeView        zTree      = null;
            TreeView        childZtree = null;

            foreach (var item in dsUnit)
            {
                zTree          = new TreeView();
                zTree.name     = item.UnitName;
                zTree.isParent = true;
                zTree.id       = item.UnitId.ToString();
                zTree.pId      = (item.ParentId == null || item.ParentId == 0) ? "" : item.ParentId.ToString();

                IEnumerable <qtUnit> dsChildUnit = _unit.GetUnitsByParentId(item.UnitId);

                List <TreeView> dsChildTreeview = null;

                if (dsChildUnit.Count() > 0)
                {
                    dsChildTreeview = new List <TreeView>();

                    foreach (var childUnit in dsChildUnit)
                    {
                        childZtree      = new TreeView();
                        childZtree.id   = childUnit.UnitId.ToString();
                        childZtree.pId  = (childUnit.ParentId == null || childUnit.ParentId == 0) ? "" : childUnit.ParentId.ToString();
                        childZtree.name = childUnit.UnitName;

                        if (isShowDepartment)
                        {
                            childZtree.isParent = isShowDepartment;                             // TRUE Áp dụng cho hiển thị đơn vị có phòng ban  đi kèm
                            childZtree.children = DepartmentByUnit(childUnit.UnitId);
                            if (childZtree.children != null && childZtree.children.Count() > 0) // Kiểm tra nếu đơn vi CÓ phòng ban đi kèm thì hiển thị phòng ban
                            {
                                childZtree.open = true;
                            }
                            else // Kiểm tra nếu đơn vi KHÔNG phòng ban đi kèm thì KHÔNG hiển thị
                            {
                                childZtree.open = false;
                            }
                        }
                        else
                        {
                            childZtree.isParent = isShowDepartment;  // FALSE Áp dụng cho hiển thị đơn vị không phòng ban kèm theo
                            childZtree.children = null;
                            childZtree.open     = false;
                        }

                        childZtree.click = "unitchange(" + childUnit.UnitId + ")";


                        dsChildTreeview.Add(childZtree);
                    }

                    zTree.children = dsChildTreeview;
                    zTree.open     = true;
                    zTree.click    = "unitchange(" + item.UnitId + ")";
                }
                else
                {
                    zTree.click = "unitchange(" + item.UnitId + ")";
                    zTree.open  = false;
                }
                dsTreeView.Add(zTree);
            }
            return(dsTreeView);
        }
Exemple #16
0
        public static MvcHtmlString UnitName(this HtmlHelper helper, int?UnitId)
        {
            qtUnitService _unit = new qtUnitService();

            return(new MvcHtmlString(_unit.UnitName(UnitId)));
        }