public shBanner Insert_Update(string BannerGuid, int?BannerId, string BannerName, string Url, int?PositionBanner, int?SortOrder, bool?Status, DateTime?CreateDate) { shBannerService _banner = new shBannerService(); shBanner banner = new shBanner(); if (!string.IsNullOrWhiteSpace(BannerGuid) || !string.IsNullOrEmpty(BannerGuid)) { banner = _banner.FindByKey(BannerGuid); } else { banner.BannerGuid = GuidUnique.getInstance().GenerateUnique(); } banner.BannerName = BannerName; banner.Url = Url; banner.PositionBanner = PositionBanner; banner.SortOrder = SortOrder; banner.Status = Status; banner.CreatedDate = CreateDate; if (banner.BannerId > 0) { _banner.Update(banner); } else { _banner.Insert(banner); } return(banner); }
public shProductSet Insert_UpdateSection(string SectionGuid, int?SectionId, string ProductGuid, string SectionName, int?SortOrder, int?ItemStatus, bool?Status, DateTime?CreateDate, string ParentId) { shSectionService _section = new shSectionService(); shProductSet section = new shProductSet(); try { // Your code... // Could also be before try if you know the exception occurs in SaveChanges if (!string.IsNullOrWhiteSpace(SectionGuid)) { section = _section.FindByKey(SectionGuid); } else { SectionGuid = GuidUnique.getInstance().GenerateUnique(); } section.SectionGuid = SectionGuid; //section.SectionId = SectionId; section.ProductGuid = ProductGuid; section.SectionName = SectionName; section.SortOrder = SortOrder; section.ItemStatus = ItemStatus; section.Status = Status; section.CreateDate = CreateDate; section.MetaTitle = "/" + StringHelper.ToUnsignString(section.SectionName).ToLower(); section.ParentId = ParentId; if (section.SectionId > 0) { _section.Update(section); } else { _section.Insert(section); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(section); }
public shOrderDetail Insert_Update( string OrderDetailGuid, int?OrderDetailId, string OrderDetailName, string OrderGuid, string MemberGuid, string ProductGuid, string ProductName, string SectionGuid, string SizeGuid, int?Number, decimal?Prices, decimal?Total, bool?Status, DateTime?CreateDate, DateTime?NgayDat) { shOrderDetailService _orderDetail = new shOrderDetailService(); shOrderDetail orderDetail = new shOrderDetail(); if (!string.IsNullOrWhiteSpace(OrderDetailGuid) || !string.IsNullOrEmpty(OrderDetailGuid)) { orderDetail = _orderDetail.FindByKey(OrderDetailGuid); } else { orderDetail.OrderDetailGuid = GuidUnique.getInstance().GenerateUnique(); } //orderDetail.OrderDetailId = OrderDetailId; orderDetail.OrderDetailName = OrderDetailName; orderDetail.OrderGuid = OrderGuid; orderDetail.MemberGuiId = MemberGuid; orderDetail.ProductGuid = ProductGuid; orderDetail.ProductName = ProductName; orderDetail.SectionGuid = SectionGuid; orderDetail.SizeGuid = SizeGuid; orderDetail.Number = Number; orderDetail.Prices = Prices; orderDetail.Total = Total; orderDetail.Status = Status; orderDetail.CreateDate = CreateDate; orderDetail.NgayDat = NgayDat; if (orderDetail.OrderDetailId > 0) { _orderDetail.Update(orderDetail); } else { _orderDetail.Insert(orderDetail); } return(orderDetail); }
public shNew ThemMoi_HieuChinhshNew(string NewGuid, int?NewId, string TitleNew, string Descriptions, string ImageFile, string Summary, string Contents, int?SortOrder, bool?Status, DateTime?CreatedDate) { shNewService _new = new shNewService(); shNew tintuc = new shNew(); if (!string.IsNullOrWhiteSpace(NewGuid)) { tintuc = _new.FindByKey(NewGuid); } else { NewGuid = GuidUnique.getInstance().GenerateUnique(); } try { // Your code... // Could also be before try if you know the exception occurs in SaveChanges tintuc.NewGuiId = NewGuid; tintuc.TitleNew = TitleNew; tintuc.Descriptions = Descriptions; tintuc.ImageFile = ImageFile; tintuc.Summary = Summary; tintuc.Contents = Contents; tintuc.SortOrder = SortOrder; tintuc.Status = Status; tintuc.CreatedDate = CreatedDate; tintuc.MetaTitle = "/tin-tuc/" + StringHelper.ToUnsignString(TitleNew).ToLower(); if (tintuc.NewId > 0) { _new.Update(tintuc); } else { _new.Insert(tintuc); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(tintuc); }
public shSale Insert_Update( string SaleGuid, int?SaleId, string SaleName, string SaleCode, string Description, int?CachTinhGiaTriKhuyenMai, string GiaTri, int?DieuKienApDung, DateTime?StartTime, DateTime?EndTime, int?SaleStatus, int?UserId, string MetaTitle, bool?Status, DateTime?CreateDate) { shSaleService _sale = new shSaleService(); shSale sale = new shSale(); if (!string.IsNullOrEmpty(SaleGuid) || !string.IsNullOrWhiteSpace(SaleGuid)) { sale = _sale.FindByKey(SaleGuid); } else { sale.SaleGuid = GuidUnique.getInstance().GenerateUnique(); } //sale.SaleDetailGuid sale.SaleName = SaleName; sale.SaleCode = SaleCode; sale.Description = Description; sale.CachTinhGiaTriKhuyenMai = CachTinhGiaTriKhuyenMai; sale.GiaTri = GiaTri; sale.DieuKienApDung = DieuKienApDung; sale.StartTime = StartTime; sale.EndTime = EndTime; sale.SaleStatus = SaleStatus; sale.UserId = UserId; sale.MetaTitle = MetaTitle; sale.Status = Status; sale.CreateDate = CreateDate; if (sale.SaleId > 0) { _sale.Update(sale); } else { _sale.Insert(sale); } return(sale); }
public shMember ThemMoi_HieuChinhMember( string MemberGuid, int?MemberId, string MemberName, string MemberLogin, string Password, string ImageFile, string Address, int?Sex, string Email, string Tel, string Phone, string Notes, bool?Status, DateTime?CreatedDate, string MapPath, string urlFolder) { shMemberService _member = new shMemberService(); shMember member = new shMember(); if (!string.IsNullOrWhiteSpace(MemberGuid)) { member = _member.FindByKey(MemberGuid); if (member.Password != Password) { member.Password = EncryptUtil.EncryptMD5(Password); } } else { member.Password = EncryptUtil.EncryptMD5(Password); MemberGuid = GuidUnique.getInstance().GenerateUnique(); } member.MemberGuiId = MemberGuid; member.MemberName = MemberName; member.MemberLogin = MemberLogin; //string forderUpload = CommonHelper.UploadFile(ImageFile, MapPath); //if (forderUpload != "" && forderUpload != null) //{ // member.ImageFile = forderUpload; //} member.ImageFile = ImageFile; member.Address = Address; member.Sex = Sex; member.Email = Email; member.Tel = Tel; member.Phone = Phone; member.Notes = Notes; member.Status = Status; member.CreateDate = CreatedDate; if (member.MemberId > 0) { _member.Update(member); } else { _member.Insert(member); } return(member); }
public shGoodReceiptIsuueDetail Insert_Update( string ReceiptIsuueDetailGuid, int?ReceiptIsuueDetailId, string ReceiptIsuueGuid, string ProductGuid, string SectionGuid, string SizeGuid, int?Number, bool?Status, DateTime?CreateDate, int?Phieu ) { shGoodReceiptIsuueDetailService _receipt = new shGoodReceiptIsuueDetailService(); shGoodReceiptIsuueDetail receipt = new shGoodReceiptIsuueDetail(); if (!string.IsNullOrEmpty(ReceiptIsuueDetailGuid) || !string.IsNullOrWhiteSpace(ReceiptIsuueDetailGuid)) { receipt = _receipt.FindByKey(ReceiptIsuueGuid); } else { receipt.ReceiptIsuueDetailGuid = GuidUnique.getInstance().GenerateUnique(); } //receipt.ReceiptIsuueDetailId = ReceiptIsuueDetailId; receipt.ReceiptIsuueGuid = ReceiptIsuueGuid; receipt.ProductGuid = ProductGuid; receipt.SectionGuid = SectionGuid; receipt.SizeGuid = SizeGuid; receipt.Number = Number; receipt.Status = Status; receipt.CreateDate = CreateDate; receipt.Phieu = Phieu; if (receipt.ReceiptIsuueDetailId > 0) { _receipt.Update(receipt); } else { _receipt.Insert(receipt); } return(receipt); }
public shComment Insert_UpdateComment( string CommentGuid, int?CommentId, string MemberGuiId, string ProductGuid, string Email, string MemberName, int?Rating, string Contents, bool?Status, DateTime?CreateDate) { shCommentService _comment = new shCommentService(); shComment comment = new shComment(); if (!string.IsNullOrEmpty(CommentGuid) || !string.IsNullOrWhiteSpace(CommentGuid)) { comment = _comment.FindByKey(CommentGuid); } else { comment.CommentGuid = GuidUnique.getInstance().GenerateUnique(); } comment.MemberGuiId = MemberGuiId; comment.ProductGuid = ProductGuid; comment.Email = Email; comment.MemberName = MemberName; comment.Rating = Rating; comment.Contents = Contents; comment.Status = Status; comment.CreatedDate = CreateDate; if (comment.CommentId > 0) { _comment.Update(comment); } else { _comment.Insert(comment); } return(comment); }
public shSetSize InsertUpdateSize(string SizeGuid, int?SizeId, string ProductGuid, string SectionGuid, string SizeName, string Description, decimal?PriceCurrent, int?PercentCurrent, decimal?PriceAfterPercents, int?Number, int?SizeStatus, int?SortOrder, bool?Status, DateTime?CreateDate, string Stuff, string Parent) { shSizeService _size = new shSizeService(); shSetSize size = new shSetSize(); if (!string.IsNullOrWhiteSpace(SizeGuid)) { size = _size.FindByKey(SizeGuid); } else { size.SizeGuid = GuidUnique.getInstance().GenerateUnique(); } //size.SizeId = SizeId size.ProductGuid = ProductGuid; size.SectionGuid = SectionGuid; size.SizeName = SizeName; size.Description = Description; size.PriceCurrent = PriceCurrent; size.PercentCurrent = PercentCurrent; size.PriceAfterPercents = PriceAfterPercents; size.Number = Number; size.SizeStatus = SizeStatus; size.SortOrder = SortOrder; size.Status = Status; size.CreateDate = CreateDate; Stuff = Stuff.Trim().TrimEnd().TrimStart(); size.Stuff = Stuff; size.ParentId = Parent; if (size.SizeId > 0) { _size.Update(size); } else { _size.Insert(size); } return(size); }
public shProductImage Insert_UpdateProductImage( string ProductImageGuid, int? ProductImageId, string ProductGuid, string FileName, string FileNameGoc, int? UserId, bool? Status, DateTime? CreateDate, string ProductImageCategory, string Image) { shProductImageService _productImage = new shProductImageService(); shProductImage productImage = new shProductImage(); if (!string.IsNullOrWhiteSpace(ProductImageGuid)) productImage = _productImage.FindByKey(ProductImageGuid); else productImage.ProductImageGuid = GuidUnique.getInstance().GenerateUnique(); //productImage.ProductImageId = ProductImageId; productImage.ProductGuid = ProductGuid; productImage.FileName = FileName; productImage.FileNameGoc = FileNameGoc; productImage.UserId = UserId; productImage.Status = Status; productImage.CreateDate = CreateDate; productImage.ProductImageCategory = ProductImageCategory; productImage.Image = Image; if (productImage.ProductImageId > 0) _productImage.Update(productImage); else _productImage.Insert(productImage); return productImage; }
public shOrder Insert_Update( string OrderGuid, int?OrderId, string OrderName, string MemberGuid, string FullName, string Email, string Phone, string Address, decimal?Total, int?OrderStatus, int?SortOrder, int?DistrictId, int?ProvinceId, decimal FeeShip, bool?Status, DateTime?CreateDate, int?PayType, DateTime?NgayDat, int?UserId ) { shOrderService _order = new shOrderService(); shOrder order = new shOrder(); try { // Your code... // Could also be before try if you know the exception occurs in SaveChanges if (!string.IsNullOrWhiteSpace(OrderGuid) || !string.IsNullOrEmpty(OrderGuid)) { order = _order.FindByKey(OrderGuid); } else { order.OrderGuid = GuidUnique.getInstance().GenerateUnique(); } //order.OrderGuid = OrderGuid; order.MemberGuid = MemberGuid; order.FullName = FullName; order.Email = Email; order.Phone = Phone; order.Address = Address; order.Total = Total; order.OrderStatus = OrderStatus; order.SortOrder = SortOrder; order.Status = Status; order.CreateDate = CreateDate; order.FeeShip = FeeShip; order.PayType = PayType; order.NgayDat = NgayDat; order.UserId = UserId; if (order.OrderId > 0) { _order.Update(order); } else { _order.Insert(order); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(order); }
public shCategory ThemMoi_HieuChinhCategory(string CategoryGuid, int?CategoryId, string CategoryName, string ParentId, int?UserId, bool?Status, DateTime?CreatedDate, string MetaTitle, string Description, int?SortOrder, string FileName) { shCategoryService _category = new shCategoryService(); shCategory category = new shCategory(); if (!string.IsNullOrWhiteSpace(CategoryGuid)) { category = _category.FindByKey(CategoryGuid); } else { CategoryGuid = GuidUnique.getInstance().GenerateUnique(); } try { // Your code... // Could also be before try if you know the exception occurs in SaveChanges category.CategoryGuid = CategoryGuid; category.CategoryName = CategoryName; category.ParentId = ParentId; category.UserId = UserId; category.Status = Status; category.CreatedDate = CreatedDate; category.Description = Description; category.SortOrder = SortOrder; if (string.IsNullOrWhiteSpace(ParentId) || string.IsNullOrEmpty(ParentId)) { category.MetaTitle = "/" + StringHelper.ToUnsignString(CategoryName).ToLower() + "/" + StringHelper.ToUnsignString(Description.Substring(0, 60)).ToLower(); } else { category.MetaTitle = TaoLinkUrl(CategoryGuid, CategoryName); } category.FileName = FileName; if (category.CategoryId > 0) { _category.Update(category); } else { _category.Insert(category); } return(category); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } return(category); } }
public shSaleDetail InsertOrUpdate( string SaleDetailGuid, int?SaleDetailId, string SaleGuid, int?CachTinhGiaTriKhuyenMai, string GiaTri, int?DieuKienApDung, DateTime?StartDate, DateTime?EndDate, String CategoryGuid, // string ProductGuid, // int?Percents, // string Description, // string Notes, // decimal?PriceAfterPercents, // string SaleAttach, // bool?Status, // DateTime?CreateDate, // string MaCauHinh, string CategoryGuidProductGuid ) { shSaleDetailService _sale = new shSaleDetailService(); shSaleDetail sale = new shSaleDetail(); if (!string.IsNullOrEmpty(SaleDetailGuid) || !string.IsNullOrWhiteSpace(SaleDetailGuid)) { sale = _sale.FindByKey(SaleDetailGuid); } else { sale.SaleDetailGuid = GuidUnique.getInstance().GenerateUnique(); } //sale.SaleDetailId = SaleDetailId; sale.SaleGuid = SaleGuid; sale.CachTinhGiaTriKhuyenMai = CachTinhGiaTriKhuyenMai; sale.GiaTri = GiaTri; sale.DieuKienApDung = DieuKienApDung; sale.StartDate = StartDate; sale.EndDate = EndDate; sale.CategoryGuid = CategoryGuid; sale.ProductGuid = ProductGuid; sale.Percents = Percents; sale.Description = Description; sale.Notes = Notes; sale.PriceAfterPercents = PriceAfterPercents; sale.SaleAttach = SaleAttach; sale.Status = Status; sale.CreateDate = CreateDate; sale.CategoryGuidProductGuid = CategoryGuidProductGuid; sale.MaCauHinh = MaCauHinh; if (sale.SaleDetailId > 0) { _sale.Update(sale); } else { _sale.Insert(sale); } return(sale); }
public shProduct Inser_UpdateProduct( string ProductGuid, int ProductId, string CategoryGuid, string ProductName, decimal?PriceCurrent, string CompleteSetInclude, string Details, string UserManual, int?PercentCurrent, decimal?PriceAfterPercents, int?Number, string Image, int?ViewsProduct, int?ProductStatus, int?SortOrder, string Color, string Size, bool?Status, DateTime?CreateDate, string Description) { shProductService _product = new shProductService(); shProduct product = new shProduct(); try { // Your code... // Could also be before try if you know the exception occurs in SaveChanges if (!string.IsNullOrWhiteSpace(ProductGuid)) { product = _product.FindByKey(ProductGuid); } else { product.ProductGuid = GuidUnique.getInstance().GenerateUnique(); } //product.ProductId = ProductId; product.CategoryGuid = CategoryGuid; product.ProductName = ProductName; product.PriceCurrent = PriceCurrent; product.CompleteSetInclude = CompleteSetInclude; product.Details = Details; product.UserManual = UserManual; product.PercentCurrent = PercentCurrent; product.PriceAfterPercents = PriceAfterPercents; product.Number = Number; product.ViewsProduct = ViewsProduct; product.ProductStatus = ProductStatus; product.SortOrder = SortOrder; product.Color = Color; product.Size = Size; product.Status = Status; product.CreateDate = CreateDate; product.Description = Description; if (!string.IsNullOrWhiteSpace(Image) || !string.IsNullOrEmpty(Image)) { product.Image = Image; } product.MetaTitle = TaoLinkUrl(CategoryGuid, ProductName); if (product.ProductId > 0) { _product.Update(product); } else { _product.Insert(product); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(product); }
public shGoodReceiptIsuue Insert_Update( string ReceiptIsuueGuid, int?ReceiptIssueId, int?Phieu, string ReceiptIsuueName, string SKU, int?MaKho, string TenKho, int?LoaiPhieu, string MaDonHang, string GhiChu, int?UserId, int?TrangThai, bool?Status, DateTime?CreateDate ) { shGoodReceiptIsuueService _receipt = new shGoodReceiptIsuueService(); shGoodReceiptIsuue receipt = new shGoodReceiptIsuue(); if (!string.IsNullOrEmpty(ReceiptIsuueGuid) || !string.IsNullOrWhiteSpace(ReceiptIsuueGuid)) { receipt = _receipt.FindByKey(ReceiptIsuueGuid); } else { receipt.ReceiptIsuueGuid = GuidUnique.getInstance().GenerateUnique(); qtUnitService _unit = new qtUnitService(); string _TenKho = _unit.UnitName(MaKho); if (string.IsNullOrEmpty(receipt.ReceiptIsuueName) && string.IsNullOrWhiteSpace(receipt.ReceiptIsuueName)) { receipt.ReceiptIsuueName = StringHelper.ToUnsignString(_TenKho) + "-" + receipt.CreateDate.GetValueOrDefault(DateTime.Now).ToString("dd-MM-yyyy"); } receipt.TenKho = _TenKho; } receipt.Phieu = Phieu; receipt.SKU = SKU; receipt.MaKho = MaKho; receipt.LoaiPhieu = LoaiPhieu; receipt.MaDonHang = MaDonHang; receipt.GhiChu = GhiChu; receipt.UserId = UserId; receipt.TrangThai = TrangThai; receipt.Status = Status; receipt.CreateDate = CreateDate; if (receipt.ReceiptIssueId > 0) { _receipt.Update(receipt); } else { _receipt.Insert(receipt); } return(receipt); }
public shCategoryImage Insert_UpdateCategoryImage( string CategoryImageGuid, int?CategoryId, string CategoryGuid, string FileName, string FileNameGoc, int?UserId, bool?Status, DateTime?CreateDate, string Image) { try { // Your code... // Could also be before try if you know the exception occurs in SaveChanges shCategoryImageService _categoryimage = new shCategoryImageService(); shCategoryImage category = new shCategoryImage(); if (!string.IsNullOrWhiteSpace(CategoryImageGuid)) { category = _categoryimage.FindByKey(CategoryImageGuid); } else { CategoryImageGuid = GuidUnique.getInstance().GenerateUnique(); } category.CategoryImageGuid = CategoryImageGuid; //category.CategoryId = CategoryId; category.CategoryGuid = CategoryGuid; category.FileName = FileName; category.FileNameGoc = FileNameGoc; category.UserId = UserId; category.Status = Status; category.CreateDate = CreateDate; //category.CategoryImage = CategoryImage; category.Image = Image; if (category.CategoryId > 0) { _categoryimage.Update(category); } else { _categoryimage.Insert(category); } return(category); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } return(null); } }