protected void btnSave_Click(object sender, EventArgs e) { if (this.Action == "edit") { int categoryid = HYRequest.GetQueryInt("categoryid", 0); ProductCategoryModel cate = ProductCategoryFactory.Get(categoryid); cate.categoryname = this.txtcategoryname.Text.Trim(); cate.orderid = Int32.Parse(this.txtorderid.Text.Trim()); cate.parentid = Int32.Parse(this.ddlParentCategory.SelectedValue); ProductCategoryFactory.Update(cate); ClientScript.RegisterStartupScript(this.GetType(), "AddEditTips", "<script language=\"javascript\">alert('修改分类成功!');window.location='productcategorylist.aspx';</script>"); } else if (this.Action == "add") { ProductCategoryModel cate = new ProductCategoryModel(); cate.categoryname = this.txtcategoryname.Text.Trim(); cate.orderid = Int32.Parse(this.txtorderid.Text.Trim()); cate.parentid = Int32.Parse(this.ddlParentCategory.SelectedValue); ProductCategoryFactory.Add(cate); ClientScript.RegisterStartupScript(this.GetType(), "AddEditTips", "<script language=\"javascript\">alert('添加分类成功!');window.location='productcategorylist.aspx';</script>"); } }
private void LoadProductCategorys() { this.ddlProductCategory.DataTextField = "categoryname"; this.ddlProductCategory.DataValueField = "categoryid"; this.ddlProductCategory.DataSource = ProductCategoryFactory.GetAll(); this.ddlProductCategory.DataBind(); }
/// <summary> /// 転送オブジェクトをエンティティに変換します。 /// </summary> /// <returns> /// エンティティを返却します。 /// </returns> public IProductCategoryEntityModel ConvertToEntity() { return(ProductCategoryFactory.Load( categoryId: this.CategoryId, categoryName: this.CategoryName, updateDateTime: this.UpdateDateTime, updateUserId: this.UpdateUserId )); }
//加载 private void LoadListData() { List <ProductCategoryModel> list = new List <ProductCategoryModel>(); DataTable dt = ProductCategoryFactory.GetAll(); BuildCategorys(list, dt, "0"); this.dgProductCategoryList.DataSource = list; this.dgProductCategoryList.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { OdnShop.Core.Business.Security.CheckAdministerAndRedirect(); if (!Page.IsPostBack) { this.ddlSearchCategorys.DataSource = ProductCategoryFactory.GetAll(); this.ddlSearchCategorys.DataBind(); this.ddlSearchCategorys.Items.Insert(0, new ListItem("所有栏目", "0")); LoadListData(); } }
protected void dgProductCategoryList_UpdateCommand(object source, DataGridCommandEventArgs e) { int dataKey = Convert.ToInt32(this.dgProductCategoryList.DataKeys[e.Item.ItemIndex]); ProductCategoryModel info = ProductCategoryFactory.Get(dataKey); info.categoryname = ((TextBox)e.Item.FindControl("txteditname")).Text.Trim(); info.parentid = 0; info.orderid = Int32.Parse(((TextBox)e.Item.FindControl("txteditorderid")).Text.Trim()); ProductCategoryFactory.Update(info); this.dgProductCategoryList.EditItemIndex = -1; this.LoadListData(); }
private void LoadCateData() { if (this.Action == "edit") { int categoryid = HYRequest.GetQueryInt("categoryid", 0); ProductCategoryModel cate = ProductCategoryFactory.Get(categoryid); if (cate != null) { this.txtcategoryname.Text = cate.categoryname; this.txtorderid.Text = cate.orderid.ToString(); this.ddlParentCategory.Items.FindByValue(cate.parentid.ToString()).Selected = true; } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { this.ddlParentCategory.DataTextField = "categoryname"; this.ddlParentCategory.DataValueField = "categoryid"; this.ddlParentCategory.DataSource = ProductCategoryFactory.GetAll(0); this.ddlParentCategory.DataBind(); this.ddlParentCategory.Items.Insert(0, new ListItem("作为顶级分类", "0")); this.LoadCateData(); int parentid = HYRequest.GetQueryInt("parentid", 0); if (parentid != 0) { this.ddlParentCategory.Items.FindByValue(parentid.ToString()).Selected = true; } } }
protected void dgProductCategoryList_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.Item.ItemType == ListItemType.Footer && e.CommandArgument.ToString() == "AddInfo") { ProductCategoryModel info = new ProductCategoryModel(); info.categoryname = ((TextBox)e.Item.FindControl("txtaddname")).Text.Trim(); info.orderid = Int32.Parse(((TextBox)e.Item.FindControl("txtaddorderid")).Text.Trim()); info.parentid = 0; ProductCategoryFactory.Add(info); this.LoadListData(); } if (e.CommandArgument.ToString() == "DeleteInfo") { int dataKey = Convert.ToInt32(this.dgProductCategoryList.DataKeys[e.Item.ItemIndex]); //todo:删除之前,检查该分类下是否有产品。 ProductCategoryFactory.Delete(dataKey); this.LoadListData(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int totalcount = 0; int pagesize = 12; int cid = HYRequest.GetQueryInt("cid", 0); int pageindex = HYRequest.GetQueryInt("p", 1); int od = HYRequest.GetQueryInt("od", 0); string whereSql = " where productcode=1 "; string orderby = " order by productid desc "; string url = "productlist.aspx?p={0}"; if (cid > 0) { whereSql = " where productcode=1 and categoryid=" + cid; url += "&cid=" + cid; } if (od == 1) { orderby = " order by salecount desc "; } else if (od == 2) { orderby = " order by price desc "; } listProducts = ProductFactory.GetList(pagesize, pageindex, whereSql, orderby, out totalcount); //this.rptProducts.DataSource = list; //this.rptProducts.DataBind(); //this.rptAddToCarPopWin.DataSource = list; //this.rptAddToCarPopWin.DataBind(); pagerHtml = Utils.BuildProductListPager(totalcount, pagesize, pageindex, url); if (cid == 0) { this.CategoryName = "全部商品"; } else { ProductCategoryModel pcm = ProductCategoryFactory.Get(cid); if (pcm != null) { this.CategoryName = pcm.categoryname; } } } string action = HYRequest.GetQueryString("action"); if (action == "ajaxloadlist") { int cid = HYRequest.GetInt("cid", 0); int pageindex = HYRequest.GetInt("p", 1); int pagesize = 12; int totalcount = 0; string wheresql = " where productcode=1 "; if (cid > 0) { wheresql = string.Format(" where productcode=1 and categoryid={0} ", cid.ToString()); } List <ProductModel> list = ProductFactory.GetList(pagesize, pageindex, wheresql, string.Empty, out totalcount); StringBuilder sbhtml = new StringBuilder(); foreach (ProductModel pm in list) { sbhtml.AppendLine("<li class=\"item\">"); sbhtml.AppendLine(string.Format("<a href=\"productshow.aspx?id={0}\"><img src=\"{1}\" alt=\"item\" /></a>", pm.productid, pm.includepicpath)); sbhtml.AppendLine(string.Format("<h4><a href=\"productshow.aspx?id={0}\">{1}</a></h4>", pm.productid, pm.productname)); sbhtml.AppendLine(string.Format("<span>¥{0}</span><del style=\"display:none\">¥{0}</del><em>库存:{1} 销量:{2}</em>", pm.price.ToString(), pm.productcount, pm.salecount)); sbhtml.AppendLine(string.Format("<p class=\"add-to-cart\" onClick=\"toshare({0})\"><span>添加到购物车</span></p>", pm.productid)); sbhtml.AppendLine("</li>"); } Response.Write(sbhtml.ToString()); Response.Flush(); Response.End(); } }
/// <inheritdoc/> public IProductCategoriesPutOutputDto Put(IProductCategoriesPutInputDto input) { using var dataAccessContext = this.GetRepository.CreateDataAccessContext(); this.GetRepository.DataAccessContext = dataAccessContext; this.PutRepository.DataAccessContext = dataAccessContext; // トランザクション開始 dataAccessContext.BeginTransaction(); // 取得 var entites = this.GetRepository.Get(); // 更新 foreach (var changedInput in input.ChangedDtos) { var entity = entites.FirstOrDefault(e => e.CategoryId == changedInput.CategoryId); if (entity == null) { continue; } entity.CategoryName = changedInput.CategoryName; entity.UpdateDateTime = this.Executor.ExecuteDateTime; entity.UpdateUserId = this.Executor.UserId; entity.EntityState |= EntityStateOptions.Modified; } // 削除 foreach (var deletedInput in input.DeletedDtos) { var entity = entites.FirstOrDefault(e => e.CategoryId == deletedInput.CategoryId); if (entity == null) { continue; } entity.UpdateDateTime = this.Executor.ExecuteDateTime; entity.UpdateUserId = this.Executor.UserId; entity.EntityState |= EntityStateOptions.Deleted; } // 作成 foreach (var addedInput in input.AddedDtos) { var entity = ProductCategoryFactory.Create( categoryId: addedInput.CategoryId, categoryName: addedInput.CategoryName, updateDateTime: this.Executor.ExecuteDateTime, updateUserId: this.Executor.UserId ); entites.Add(entity); } // マスタ更新 this.PutRepository.Put(entites); // コミット dataAccessContext.CommitTransaction(); return(this.Output); }
//Constructor public ProductCategoriesController(IProductRepository repo) { _repo = repo; _productCategoryFactory = new ProductCategoryFactory(_repo); _productFactory= new ProductFactory(); }
/// <summary> /// <see cref="DataBase"/> クラスの新しいインスタンスを作成します。 /// </summary> static DataBase() { // 商品マスタ DataBase.Products = new List <ProductEntityModel>() { ProductFactory.Load( productId: "000010010001", productName: "ポテトチップス(うすしお)", brandId: "00001", catetoryId: "001", listPrice: 100, productTagType: ProductTagTypeOptions.None, updateDateTime: DateTime.Now, updateUserId: "Stub" ), ProductFactory.Load( productId: "000010010002", productName: "ポテトチップス(のり塩)", brandId: "00001", catetoryId: "001", listPrice: 120, productTagType: ProductTagTypeOptions.None, updateDateTime: DateTime.Now, updateUserId: "Stub" ), ProductFactory.Load( productId: "000010010003", productName: "ポテトチップス(コンソメ)", brandId: "00001", catetoryId: "001", listPrice: 150, productTagType: ProductTagTypeOptions.None, updateDateTime: DateTime.Now, updateUserId: "Stub" ), ProductFactory.Load( productId: "000020020001", productName: "チョコレート(ビター)", brandId: "00002", catetoryId: "002", listPrice: 200, productTagType: ProductTagTypeOptions.None, updateDateTime: DateTime.Now, updateUserId: "Stub" ), ProductFactory.Load( productId: "000020020002", productName: "チョコレート(ミルク)", brandId: "00002", catetoryId: "002", listPrice: 230, productTagType: ProductTagTypeOptions.None, updateDateTime: DateTime.Now, updateUserId: "Stub" ), ProductFactory.Load( productId: "000020020003", productName: "チョコレート(ホワイト)", brandId: "00002", catetoryId: "002", listPrice: 250, productTagType: ProductTagTypeOptions.None, updateDateTime: DateTime.Now, updateUserId: "Stub" ), ProductFactory.Load( productId: "000030010001", productName: "ポテトチップス(ピザ)", brandId: "00003", catetoryId: "001", listPrice: 200, productTagType: ProductTagTypeOptions.MadeToOrder, updateDateTime: DateTime.Now, updateUserId: "Stub" ), ProductFactory.Load( productId: "000030010002", productName: "ポテトチップス(ピリ辛)", brandId: "00003", catetoryId: "001", listPrice: 200, productTagType: ProductTagTypeOptions.LimitedEdition, updateDateTime: DateTime.Now, updateUserId: "Stub" ), ProductFactory.Load( productId: "000030010003", productName: "ポテトチップス(ガーリック)", brandId: "00003", catetoryId: "001", listPrice: 200, productTagType: ProductTagTypeOptions.LimitedEdition | ProductTagTypeOptions.EndOfSale, updateDateTime: DateTime.Now, updateUserId: "Stub" ), ProductFactory.Load( productId: "000030030001", productName: "アイスキャンデー", brandId: "00003", catetoryId: "003", listPrice: 50, productTagType: ProductTagTypeOptions.None, updateDateTime: DateTime.Now, updateUserId: "Stub" ), ProductFactory.Load( productId: "000030030002", productName: "アイスクリーム", brandId: "00003", catetoryId: "003", listPrice: 50, productTagType: ProductTagTypeOptions.None, updateDateTime: DateTime.Now, updateUserId: "Stub" ), ProductFactory.Load( productId: "000030030003", productName: "アイスシャーベット", brandId: "00003", catetoryId: "003", listPrice: 50, productTagType: ProductTagTypeOptions.None, updateDateTime: DateTime.Now, updateUserId: "Stub" ) }; // 商品カテゴリマスタ DataBase.ProductCategories = new List <ProductCategoryEntityModel>() { ProductCategoryFactory.Load( categoryId: "001", categoryName: "ポテトチップス", updateDateTime: DateTime.Now, updateUserId: "Stub" ), ProductCategoryFactory.Load( categoryId: "002", categoryName: "チョコレート", updateDateTime: DateTime.Now, updateUserId: "Stub" ), ProductCategoryFactory.Load( categoryId: "003", categoryName: "アイス", updateDateTime: DateTime.Now, updateUserId: "Stub" ) }; // ブランドマスタ DataBase.Brands = new List <BrandEntityModel>() { BrandFactory.Load( brandId: "00001", brandName: "メーカーA", note: "ポテトチップス専門メーカー。業界最大手とされている。", updateDateTime: DateTime.Now, updateUserId: "Stub" ), BrandFactory.Load( brandId: "00002", brandName: "メーカーB", note: "チョコレート専門メーカー。", updateDateTime: DateTime.Now, updateUserId: "Stub" ), BrandFactory.Load( brandId: "00003", brandName: "メーカーC", note: "総合お菓子メーカー。ポテトチップス・チョコレート・アイスと幅広く商品展開を行っている。", updateDateTime: DateTime.Now, updateUserId: "Stub" ) }; // 得意先マスタ DataBase.Customers = new List <CustomerEntityModel>() { CustomerFactory.Load( customerId: "0000000001", customerName: "アルファ商店", customerKanaName: "アルファショウテン", customerShortName: "α商店", establishmentDate: DateTime.Parse("2020/04/01"), ceo: "アルファ 一郎", postalCode: "0000000", address: "〇〇都〇〇区〇〇丁目〇〇番 〇〇ビル〇〇階", tel: "0000000000", fax: "0000000000", mail: "*****@*****.**", hp: "http://alfa.test.com/", cutoffDateType: CutoffDateTypeOptions.None, cutoffDate: 0, collectionDateType: CollectionDateTypeOptions.None, collectionDate: 0, taxType: TaxTypeOptions.None, taxCalcType: TaxCalcTypeOptions.None, taxRoundType: TaxRoundTypeOptions.None, note: null, updateDateTime: DateTime.Now, updateUserId: "Stub" ), CustomerFactory.Load( customerId: "0000000002", customerName: "ベータ商店", customerKanaName: "ベータショウテン", customerShortName: "β商店", establishmentDate: DateTime.Parse("1920/04/01"), ceo: "ベータ 太郎", postalCode: "0000000", address: "〇〇都〇〇区〇〇丁目〇〇番 〇〇ビル〇〇階", tel: "0000000000", fax: "0000000000", mail: "*****@*****.**", hp: "http://beta.test.com/", cutoffDateType: CutoffDateTypeOptions.None, cutoffDate: 0, collectionDateType: CollectionDateTypeOptions.None, collectionDate: 0, taxType: TaxTypeOptions.None, taxCalcType: TaxCalcTypeOptions.None, taxRoundType: TaxRoundTypeOptions.None, note: null, updateDateTime: DateTime.Now, updateUserId: "Stub" ), CustomerFactory.Load( customerId: "0000000003", customerName: "ガンマ商店", customerKanaName: "ガンマショウテン", customerShortName: "γ商店", establishmentDate: DateTime.Parse("1999/12/31"), ceo: "ガンマ 大治郎", postalCode: "0000000", address: "〇〇都〇〇区〇〇丁目〇〇番 〇〇ビル〇〇階", tel: "0000000000", fax: "0000000000", mail: "*****@*****.**", hp: "http://gamma.test.com/", cutoffDateType: CutoffDateTypeOptions.None, cutoffDate: 0, collectionDateType: CollectionDateTypeOptions.None, collectionDate: 0, taxType: TaxTypeOptions.None, taxCalcType: TaxCalcTypeOptions.None, taxRoundType: TaxRoundTypeOptions.None, note: null, updateDateTime: DateTime.Now, updateUserId: "Stub" ) }; // 回収日区分 DataBase.CollectionDateTypes = CollectionDateTypeFactory.CreateInitialData(); // 締日区分 DataBase.CutoffDateTypes = CutoffDateTypeFactory.CreateInitialData(); // 消費税区分 DataBase.TaxTypes = TaxTypeFactory.CreateInitialData(); // 消費税端数処理区分 DataBase.TaxRoundTypes = TaxRoundTypeFactory.CreateInitialData(); // 消費税計算区分 DataBase.TaxCalcTypes = TaxCalcTypeFactory.CreateInitialData(); // 商品タグ区分 DataBase.ProductTagTypes = ProductTagTypeFactory.CreateInitialData(); // 1000件越えテスト用 for (var i = 0; i < 1000; i++) { DataBase.Products.Add( ProductFactory.Load( productId: $"99999999{i:4}", productName: $"テスト商品 {i}", brandId: "99999", catetoryId: "999", listPrice: 9999, productTagType: ProductTagTypeOptions.None, updateDateTime: DateTime.Now, updateUserId: "Stub" ));; } DataBase.ProductCategories.Add( ProductCategoryFactory.Load( categoryId: "999", categoryName: "テストお菓子", updateDateTime: DateTime.Now, updateUserId: "Stub" )); DataBase.Brands.Add( BrandFactory.Load( brandId: "99999", brandName: "テストメーカー", note: "1000件テスト用", updateDateTime: DateTime.Now, updateUserId: "Stub" )); }