private void getDetails() { PurchaseWeekEntity buyerPriceWeek = logic.purchaseWeek.getById(bpwdid); lblCompany.Text = logic.company.getById(buyerPriceWeek.CompanyId).Company; lblWeek.Text = string.Format("第{0}周", buyerPriceWeek.Week); lblStartTime.Text = buyerPriceWeek.StartTime.ToLongDateString(); lblEndTime.Text = buyerPriceWeek.EndTime.ToLongDateString(); lblCreateAdmin.Text = logic.sysAdmin.getById(buyerPriceWeek.CreateAdminId).Username; lblAuditAdmin.Text = logic.sysAdmin.getById(buyerPriceWeek.AuditAdminId).Username; if (DateTime.MinValue != buyerPriceWeek.InputDt) { lblCreateDt.Text = buyerPriceWeek.InputDt.ToLongDateString(); } if(DateTime.MinValue!=buyerPriceWeek.UpdatestatusDt) { lblAuditDt.Text = buyerPriceWeek.UpdatestatusDt.ToLongDateString(); } if (buyerPriceWeek.UpdatestatusDt != DateTime.MinValue && buyerPriceWeek.AuditAdminId != 0 && buyerPriceWeek.Status == "2") { btnAudit.Enabled = false; } else { btnAudit.Enabled = true; } if (buyerPriceWeek.UpdatestatusDt != DateTime.MinValue) { lblAuditDt.Text = buyerPriceWeek.UpdatestatusDt.ToString(); } companyId = buyerPriceWeek.CompanyId; if (!string.IsNullOrEmpty(Request.QueryString["action"]) && Request.QueryString["action"] == "edit") { // 绑定周价商品 DataTable dt = logic.buyerWeeklyPrice.listWithCompanyWeek(bpwdid); List<WeeklyProductItem> items = new List<WeeklyProductItem>(); WeeklyProductItem product = null; foreach (DataRow row in dt.Rows) { product = new WeeklyProductItem() { ProductId = Convert.ToInt32(row["productId"]), ProductName = row["name"].ToString(), AutoAdd = Convert.ToDecimal(row["initPriceRate"]), AvgSellerPrice = Convert.ToDecimal(row["avgSellerPrice"]), Price = Convert.ToDecimal(row["avgSellerPrice"]) * (1 + Convert.ToDecimal(row["priceRate"])) }; items.Add(product); } hdProductSotre.Value = JsonConvert.SerializeObject(items); } }
// 添加到周报价商品 protected void lbn_AddTo_Click(object sender, EventArgs e) { List<WeeklyProductItem> selectedProduct = null; if (!string.IsNullOrEmpty(hdProductSotre.Value)) { selectedProduct = JsonConvert.DeserializeObject<List<WeeklyProductItem>>(hdProductSotre.Value); } else { selectedProduct = new List<WeeklyProductItem>(); } foreach (RepeaterItem item in rpt_Products.Items) { if (item.ItemType == ListItemType.AlternatingItem || item.ItemType == ListItemType.Item) { CheckBox chk = item.FindControl("cbx_isSelect") as CheckBox; if (chk != null && chk.Checked) { WeeklyProductItem product = new WeeklyProductItem(); product.ProductId = Convert.ToInt32(chk.Attributes["ProductId"]); product.ProductName = chk.Attributes["ProductName"]; product.AvgSellerPrice = Convert.ToDecimal(chk.Attributes["AvgSellerPrice"]); product.AutoAdd = Convert.ToDecimal(chk.Attributes["AutoAdd"]); product.InitAutoAdd = Convert.ToDecimal(chk.Attributes["AutoAdd"]); product.Price = Convert.ToDecimal(product.AvgSellerPrice * (1 + product.AutoAdd)); // 匿名方法查找 //ProductItem current = selectedProduct.Find(delegate(ProductItem productItem) { return productItem.ProductId == product.ProductId; }); // lamdba表达式 WeeklyProductItem current = selectedProduct.Find(productItem => productItem.ProductId == product.ProductId); if (current == null) { selectedProduct.Add(product); } } } } if (selectedProduct != null) { hdProductSotre.Value = JsonConvert.SerializeObject(selectedProduct); } else { hdProductSotre.Value = string.Empty; } BindSelectedProduct(); }