protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e) { int columnCount = this.GV_List.Columns.Count; if (e.Row.RowType == DataControlRowType.DataRow) { ScheduleBody body = (com.Sconit.Entity.MRP.ScheduleBody)(e.Row.DataItem); e.Row.Cells[0].Text = seq.ToString(); //LinkButton lbnItem = e.Row.Cells[1].Controls[0] as LinkButton; Item item = this.TheItemMgr.CheckAndLoadItem(body.Item); e.Row.Cells[2].Text = item.Description; e.Row.Cells[3].Text = item.DefaultSupplier; string lblUom = e.Row.Cells[4].Text; string lblUnitCount = e.Row.Cells[5].Text; seq++; //lbnItem.Text = body.Item; if (!isExport) { for (int i = 6; i < columnCount; i++) { string headerText = this.GV_List.Columns[i].SortExpression; string lastHeaderText = this.GV_List.Columns[i].FooterText; DateTime headerTextTime = DateTime.Parse(headerText); DateTime?lastHeaderTextTime = null; if (lastHeaderText != string.Empty) { lastHeaderTextTime = DateTime.Parse(lastHeaderText); } } } else { e.Row.Cells[1].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); } } }
protected void GV_Order_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ScheduleBody body = (com.Sconit.Entity.MRP.ScheduleBody)(e.Row.DataItem); e.Row.Cells[0].Text = seq.ToString(); Item item = this.TheItemMgr.LoadItem(body.Item); e.Row.Cells[2].Text = item.Description; e.Row.Cells[3].Text = item.DefaultSupplier; decimal uc = Convert.ToDecimal(e.Row.Cells[5].Text); decimal qty = body.Qty0; if (qty % uc != 0) { qty = qty - qty % uc + uc; } ((TextBox)e.Row.Cells[7].FindControl("tbQty")).Text = qty.ToString("0.##"); seq++; } }
public ScheduleView TransferCustomerScheduleDetails2ScheduleView(IList <CustomerScheduleDetail> customerScheduleDetails, DateTime effDate) { customerScheduleDetails = this.GetEffectiveCustomerScheduleDetail(customerScheduleDetails, effDate).ToList(); #region 头 List <ScheduleHead> scheduleHeads = (from det in customerScheduleDetails group det by new { det.DateFrom, det.DateTo, det.Type, det.CustomerSchedule.ReleaseDate } into result select new ScheduleHead { DateFrom = result.Key.DateFrom, DateTo = result.Key.DateTo, Type = result.Key.Type, ReleaseDate = result.Key.ReleaseDate }).ToList(); scheduleHeads = scheduleHeads.OrderBy(c => c.DateFrom).Take(41).ToList(); #endregion #region 明细 List <ScheduleBody> scheduleBodys = (from det in customerScheduleDetails group det by new { det.Item, det.Uom, det.UnitCount, det.Location, det.ItemDescription, det.ItemReference } into result select new ScheduleBody { Item = result.Key.Item, Uom = result.Key.Uom, UnitCount = result.Key.UnitCount, Location = result.Key.Location, ItemDescription = result.Key.ItemDescription, ItemReference = result.Key.ItemReference }).ToList(); #endregion #region 赋值 #region 方法1 if (false) { foreach (CustomerScheduleDetail customerScheduleDetail in customerScheduleDetails) { var q_scheduleHeads = scheduleHeads.Where(c => c.DateFrom == customerScheduleDetail.DateFrom && c.DateTo == customerScheduleDetail.DateTo && StringHelper.Eq(c.Type, customerScheduleDetail.Type)); if (q_scheduleHeads.Count() == 1) { int index = scheduleHeads.IndexOf(q_scheduleHeads.Single()); string qtyIndex = "Qty" + index.ToString(); var q_scheduleBodys = scheduleBodys.Where(c => StringHelper.Eq(c.Item, customerScheduleDetail.Item) && c.UnitCount == customerScheduleDetail.UnitCount && StringHelper.Eq(c.Uom, customerScheduleDetail.Uom) && StringHelper.Eq(c.Location, customerScheduleDetail.Location)); if (q_scheduleBodys.Count() == 1) { ScheduleBody scheduleBody = q_scheduleBodys.Single(); PropertyInfo[] scheduleBodyPropertyInfo = typeof(ScheduleBody).GetProperties(); foreach (PropertyInfo pi in scheduleBodyPropertyInfo) { if (pi.Name != null && StringHelper.Eq(pi.Name.ToLower(), qtyIndex)) { pi.SetValue(scheduleBody, customerScheduleDetail.Qty, null); break; } } } } } } #endregion #region 方法2 foreach (ScheduleBody scheduleBody in scheduleBodys) { int i = 0; foreach (ScheduleHead scheduleHead in scheduleHeads) { string qty = "Qty" + i.ToString(); var q = customerScheduleDetails .Where(c => StringHelper.Eq(c.Item, scheduleBody.Item) && StringHelper.Eq(c.Uom, scheduleBody.Uom) && c.UnitCount == scheduleBody.UnitCount && c.DateFrom == scheduleHead.DateFrom && c.DateTo == scheduleHead.DateTo && c.Type == scheduleHead.Type); if (q.Count() == 1) { PropertyInfo[] scheduleBodyPropertyInfo = typeof(ScheduleBody).GetProperties(); foreach (PropertyInfo pi in scheduleBodyPropertyInfo) { if (pi.Name != null && StringHelper.Eq(pi.Name.ToLower(), qty)) { pi.SetValue(scheduleBody, q.Single().Qty, null); break; } } } i++; } } #endregion #endregion #region 过滤全部是0的 scheduleBodys = scheduleBodys.Where(s => s.TotalQty > 0).ToList(); #endregion ScheduleView scheduleView = new ScheduleView(); scheduleView.ScheduleHeads = scheduleHeads; scheduleView.ScheduleBodys = scheduleBodys; return(scheduleView); }