Пример #1
0
        /// <summary>
        /// Lấy các thông tin bình luận
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private string BinhLuan(ModProduct_InfoEntity item)
        {
            string sData = "<div class='div-no-comment'>Chưa có bình luận nào cho sản phẩm</div>";

            if (item == null)
            {
                return(sData);
            }

            // LẤy các comment đã được duyệt
            var lstDataComment = ModProduct_CommentsService.Instance.CreateQuery().Where(o => o.ProductInfoId == item.ID && o.Approved == true)
                                 .OrderByDesc(o => o.CreateDate).ToList();

            if (lstDataComment == null || lstDataComment.Count <= 0)
            {
                return(sData);
            }

            sData = string.Empty;

            foreach (var itemComment in lstDataComment)
            {
                sData += "<div class='div-comment-group'>";
                sData += "<div class='div-comment-group-info-user'><span class='div-comment-group-info'>" + itemComment.Name + "</span><span class='div-comment-group-info-email'>" + (string.IsNullOrEmpty(itemComment.Email) ? string.Empty : " - ") + itemComment.Email + "</span>";
                sData += "<span class='div-comment-group-info-address'>" + (string.IsNullOrEmpty(itemComment.Address) ? string.Empty : " - ") + itemComment.Address + "</span><span class='div-comment-group-info-date'>(" + itemComment.CreateDate.ToString("dd/MM/yyyy HH:mm") + ")</span></div>";

                // nội dung comment
                sData += "<div class='div-comment-content'>";
                sData += itemComment.Content;
                sData += "</div>";
                sData += "</div>";
            }

            return(sData);
        }
Пример #2
0
        /// <summary>
        /// Lấy danh sách đại lý
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private string DaiLy(ModProduct_InfoEntity item)
        {
            string sData = string.Empty;
            List <ModProduct_Info_AgentEntity> lstInfo_Agent_In = ModProduct_Info_AgentService.Instance.CreateQuery()
                                                                  .Where(p => p.ProductInfoId == item.ID).ToList();

            if (lstInfo_Agent_In == null || lstInfo_Agent_In.Count <= 0)
            {
                return(sData);
            }

            // Lấy danh sách ID
            string ListId = VSW.Lib.Global.ConvertTool.ConvertListStringToString(lstInfo_Agent_In.Select(p => p.ProductAgeId).ToList());

            List <ModProduct_AgentEntity> lstInfo_Agent = ModProduct_AgentService.Instance.CreateQuery()
                                                          .WhereIn(p => p.ID, ListId)
                                                          .OrderByAsc(o => o.Name).ToList();

            if (lstInfo_Agent == null || lstInfo_Agent.Count <= 0)
            {
                return(sData);
            }

            sData += "<div class='div-agent'>";
            sData += "<div class='div-group-info-detail'>";
            sData += "<div class='group-info-detail'>";
            sData += "Đại lý bán sản phẩm:";
            sData += "</div>";

            foreach (var itemAgent in lstInfo_Agent)
            {
                sData += "<div class='list-info-detail'>";
                sData += itemAgent.Name + " - " + itemAgent.Address;
                sData += "</div>";
            }

            sData += "</div>";
            sData += "</div>";
            return(sData);
        }
Пример #3
0
        public void ActionAdd(ModProduct_CommentsModel model)
        {
            var ProductCurrent = new ModProduct_InfoEntity();

            if (model.RecordID > 0)
            {
                item = ModProduct_CommentsService.Instance.GetByID(model.RecordID);

                // khoi tao gia tri mac dinh khi update
                ProductCurrent = ModProduct_InfoService.Instance.GetByID(item.ProductInfoId);
            }
            else
            {
                item = new ModProduct_CommentsEntity();

                // khoi tao gia tri mac dinh khi insert
                item.Activity   = CPViewPage.UserPermissions.Approve;
                item.CreateDate = DateTime.Now;
            }

            ViewBag.Data           = item;
            ViewBag.Model          = model;
            ViewBag.ProductCurrent = ProductCurrent;
        }
Пример #4
0
        /// <summary>
        /// Danh sách các thuộc tính của sản phẩm
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private string ThuocTinh(ModProduct_InfoEntity item)
        {
            string sData = string.Empty;

            // Lấy thông tin chủng loại
            WebMenuEntity objWebMenuService = WebMenuService.Instance.GetByID(item.MenuID);

            List <ModProduct_Area_PropretyGroupEntity> lstArea_PropretyGroup_All = ModProduct_Area_PropretyGroupService.Instance
                                                                                   .CreateQuery().Where(p => p.ProductAreaId == objWebMenuService.ProductAreaId).ToList();

            #region Lấy tất cả các dữ liệu nhóm theo lĩnh vực
            // Lấy danh sách các nhóm thuộc tính
            if (lstArea_PropretyGroup_All == null || lstArea_PropretyGroup_All.Count <= 0)
            {
                return(sData);
            }

            // Lấy danh sách các chuỗi Nhóm thuộc tính
            string sListPropretyGroupId_All = string.Empty;
            var    Area_PropretyGroup_All   = lstArea_PropretyGroup_All.Select(o => o.PropertiesGroupId).ToList();
            if (Area_PropretyGroup_All != null)
            {
                foreach (var itemString in Area_PropretyGroup_All)
                {
                    sListPropretyGroupId_All += "," + itemString;
                }

                sListPropretyGroupId_All = sListPropretyGroupId_All.Trim(',');
            }

            // Lấy tất cả nhóm thuộc tính
            List <ModProduct_PropertiesGroupsEntity> lstPropretyGroup_All = ModProduct_PropertiesGroupsService.Instance.CreateQuery()
                                                                            .Where(p => p.Activity == true)
                                                                            .WhereIn(p => p.ID, sListPropretyGroupId_All).OrderByAsc(o => o.Order).ToList();
            if (lstPropretyGroup_All == null || lstPropretyGroup_All.Count <= 0)
            {
                return(sData);
            }

            // Lấy tất cả thuộc tính thuộc các nhóm trên
            List <ModProduct_PropertiesListEntity> lstPropreties_All = ModProduct_PropertiesListService.Instance.CreateQuery()
                                                                       .Where(p => p.Activity == true)
                                                                       .WhereIn(p => p.PropertiesGroupsId, sListPropretyGroupId_All)
                                                                       .OrderByAsc(o => o.Order).ToList();
            if (lstPropreties_All == null)
            {
                lstPropreties_All = new List <ModProduct_PropertiesListEntity>();
            }

            string sPropertiesListId = string.Empty;
            string sListPropretyGroupId_ByPropertiesListId = string.Empty;
            foreach (var itemString in lstPropreties_All)
            {
                sPropertiesListId += "," + itemString.ID;
                sListPropretyGroupId_ByPropertiesListId += "," + itemString.PropertiesGroupsId;
            }

            sPropertiesListId = sPropertiesListId.Trim(',');
            sListPropretyGroupId_ByPropertiesListId = sListPropretyGroupId_ByPropertiesListId.Trim(',');

            // Lấy tất cả những giá trị cũ của các thuộc tính
            List <ModProduct_PropertiesList_ValuesEntity> lstPropertiesList_Values_All = null;
            if (!string.IsNullOrEmpty(sPropertiesListId))
            {
                lstPropertiesList_Values_All = ModProduct_PropertiesList_ValuesService.Instance.CreateQuery().WhereIn(p => p.PropertiesListId, sPropertiesListId).ToList();
            }

            if (lstPropertiesList_Values_All == null)
            {
                lstPropertiesList_Values_All = new List <ModProduct_PropertiesList_ValuesEntity>();
            }
            #endregion


            // Lấy danh sách các giá trị của nhóm thuộc tính
            List <ModProduct_Info_DetailsEntity> lstProduct_Info_Details = ModProduct_Info_DetailsService.Instance.CreateQuery()
                                                                           .Where(p => p.ProductInfoId == item.ID)
                                                                           .WhereIn(p => p.PropertiesGroupsId, sListPropretyGroupId_All)
                                                                           .ToList();
            if (lstProduct_Info_Details == null)
            {
                lstProduct_Info_Details = new List <ModProduct_Info_DetailsEntity>();
            }

            int iProperties = -1;
            int iSTT        = 0;
            List <ModProduct_PropertiesListEntity> lstPropreties_Filter = null;

            sData = "<table class='tbl-properties'>";

            foreach (var itemPropertiesGroup in lstPropretyGroup_All)
            {
                // Quyết định màu của dòng
                iProperties++;

                // Dòng Nhóm thuộc tính
                #region Dòng Nhóm thuộc tính
                sData += "<tr class='row" + iProperties % 2 + "'>";
                sData += "<td colspan='4'>";
                sData += "<div class='div-properties-group'><span>" + itemPropertiesGroup.Name + "</span></div>";
                sData += "</td></tr>";
                #endregion

                lstPropreties_Filter = lstPropreties_All.Where(p => p.PropertiesGroupsId == itemPropertiesGroup.ID)
                                       .OrderBy(o => o.Order)
                                       .ToList();
                if (lstPropreties_Filter == null || lstPropreties_Filter.Count <= 0)
                {
                    continue;
                }

                foreach (ModProduct_PropertiesListEntity itemPropertiesList in lstPropreties_Filter)
                {
                    // Quyết định màu của dòng
                    iProperties++;

                    sData += "<tr class='row" + iProperties % 2 + "'>";

                    sData += "<td align='center' class='td-stt'>";
                    sData += "</td>";

                    // Tên thuộc tính
                    sData += "<td align='left' nowrap='nowrap' class='td-label'>";
                    sData += "<label>" + itemPropertiesList.Name + "</label>";
                    sData += "</td>";

                    sData += "<td class='td-space'>:";
                    sData += "</td>";

                    // Ô nhập giá trị cho thuộc tính
                    sData += "<td class='td-value'>";
                    sData += GetValue_PropertiesValue(lstProduct_Info_Details, itemPropertiesList.ID);

                    // Đơn vị tính
                    if (!string.IsNullOrEmpty(itemPropertiesList.Unit))
                    {
                        sData += "&nbsp;<span>(" + itemPropertiesList.Unit + ")</span>";
                    }
                    sData += "</td>";

                    sData += "</tr>";
                }
            }

            sData += "</table>";

            return(sData);
        }
        public void ActionAdd(ModProduct_Info_DetailsModel model)
        {
            if (model.ProductInfoId > 0)
            {
                // khoi tao gia tri mac dinh khi update
                // Lấy thông tin sản phẩm
                ModProduct_InfoEntity objModProduct_InfoEntity = ModProduct_InfoService.Instance.GetByID(model.ProductInfoId);

                // Lấy thông tin chủng loại
                WebMenuEntity objWebMenuEntity = WebMenuService.Instance.GetByID(objModProduct_InfoEntity.MenuID);

                // Lưu lại Nhóm thuộc tính ID
                model.PropertiesGroupsId = (int)objWebMenuEntity.ProductAreaId;

                if (objWebMenuEntity.ProductAreaId <= 0)
                {
                    CPViewPage.Message.ListMessage.Add("Sản phẩm chưa có nhóm thuộc tính nào. Yêu cầu chọn các nhóm cho Sản phẩm để có thể nhập thông tin");
                    ViewBag.Data = item;
                    ViewBag.Model = model;
                    return;
                }

                model.GetPropertiesList_Value = ModProduct_Info_DetailsService.Instance.CreateQuery()
                    .Where(o => o.PropertiesGroupsId == objWebMenuEntity.ProductAreaId && o.ProductInfoId == model.ProductInfoId)
                    .ToList();

                // Where In Lấy danh sách nhóm thuộc tính chứa thuộc tính SP
                model.PropertiesGroup = ModProduct_PropertiesGroupsService.Instance.CreateQuery()
                    .Where(o => o.ID == objWebMenuEntity.ProductAreaId && o.Activity == true)
                    .OrderByAsc(o => o.Order).ToSingle();

                // Lấy danh sách thuộc tính thuộc nhóm bên trên
                model.GetPropertiesList = ModProduct_PropertiesListService.Instance.CreateQuery()
                    .Where(o => o.PropertiesGroupsId == objWebMenuEntity.ProductAreaId && o.Activity == true)
                    .OrderByAsc(o => o.Order)
                    .ToList();

                // Lấy danh sách thứ tự thuộc tính để cập nhật dữ liệu theo thứ tự này
                string sThuTu = string.Empty;

                foreach (var itemProperties in model.GetPropertiesList)
                {
                    sThuTu += itemProperties.ID + ",";
                }
                model.DanhSachThuTuThuocTinh = sThuTu.Trim(',');

                // Lấy danh sách các giá trị của các thuộc tính có sẵn
                List<ModProduct_PropertiesList_ValuesEntity> lstModProduct_PropertiesList_Values= ModProduct_PropertiesList_ValuesService.Instance.CreateQuery().WhereIn(o => o.PropertiesListId, model.DanhSachThuTuThuocTinh).ToList();
                if (lstModProduct_PropertiesList_Values == null)
                    lstModProduct_PropertiesList_Values = new List<ModProduct_PropertiesList_ValuesEntity>();

                model.GetProduct_PropertiesList_Values = lstModProduct_PropertiesList_Values;
            }
            else
            {
                item = new ModProduct_Info_DetailsEntity();

                // khoi tao gia tri mac dinh khi insert
            }

            ViewBag.Data = item;
            ViewBag.Model = model;
        }