public void Save() { if (GV_List.Rows.Count == 0 || dt.Rows.Count == 0) { return; } int rowIndex = 0; foreach (DataRow dr in dt.Rows) { if (dr["Type"].ToString() == BusinessConstants.PLAN_VIEW_TYPE_PLAN) { string timePeriodType = dr["TimePeriodType"].ToString(); for (int j = 0; j < GV_List.Columns.Count - _firstDynColIndex; j++) { int itemFlowPlanId = (int)dr["ItemFlowPlanId"]; DateTime date = this.dateList[j]; ItemFlowPlan ifp = TheItemFlowPlanMgr.LoadItemFlowPlan(itemFlowPlanId); try { string editControlID = this.GetDynControlID(j); TextBox _editControl = (TextBox)GV_List.Rows[rowIndex].Cells[j + _firstDynColIndex].FindControl(editControlID); string colName = "DynCol_" + j.ToString(); decimal newValue = 0; if (_editControl.Text.Trim() != string.Empty) { newValue = decimal.Parse(_editControl.Text.Trim()); } decimal oldValue = (decimal)dr[colName]; if (newValue != 0 || oldValue != 0) { ItemFlowPlanDetail ifpd = new ItemFlowPlanDetail(); ifpd.ItemFlowPlan = ifp; ifpd.TimePeriodType = timePeriodType; ifpd.ReqDate = date; ifpd.PlanQty = newValue; //ifpd.LastModifyDate = DateTime.Now; //ifpd.LastModifyUser = this.Session["UserCode"].ToString(); if (ifpd.PlanQty < 0) { ShowErrorMessage("MRP.Error.Save", ifp.FlowDetail.Item.Code, GetHeaderText(timePeriodType, date)); return; } TheItemFlowPlanDetailMgr.SaveItemFlowPlanDetail(ifpd); dr[colName] = newValue; ShowSuccessMessage("Common.Business.Result.Save.Successfully"); } } catch (Exception) { ShowErrorMessage("MRP.Error.Save", ifp.FlowDetail.Item.Code, GetHeaderText(timePeriodType, date)); return; } } } rowIndex++; } this.ListView(); }
protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView drv = (DataRowView)e.Row.DataItem; string planViewType = drv["Type"].ToString(); if (planViewType == string.Empty) { //Group line e.Row.BackColor = Color.Gray; e.Row.ForeColor = Color.Snow; } else if (planViewType == BusinessConstants.PLAN_VIEW_TYPE_DEMAND) { //Demand e.Row.BackColor = Color.Aquamarine; e.Row.Cells[3].Text = "${MRP.PlanViewType.Demand}"; //ToolTip e.Row.Cells[2].ToolTip = "${MRP.PlanViewType.TotalDemand}"; //demand source foreach (DateTime date in dateList) { int dynColIndex = dateList.IndexOf(date); if ((decimal)drv["DynCol_" + dynColIndex.ToString()] > 0) { int itemFlowPlanId = (int)drv["ItemFlowPlanId"]; string timePeriodType = (string)drv["TimePeriodType"]; ItemFlowPlanDetail ifpd = TheItemFlowPlanDetailMgr.GetItemFlowPlanDetail(itemFlowPlanId, timePeriodType, date); IList <ItemFlowPlanTrack> ifptList = TheItemFlowPlanTrackMgr.GetItemFlowPlanTrackList(ifpd, null, null); e.Row.Cells[dynColIndex + _firstDynColIndex].Attributes.Add("title", this.GetToolTip(ifptList)); } } } else if (planViewType == BusinessConstants.PLAN_VIEW_TYPE_PLAN) { //Plan if (ModuleType != BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_DMDSCHEDULE) { e.Row.Cells[_firstDynColIndex - 1].Text = "${MRP.PlanViewType.Plan}"; //ToolTip e.Row.Cells[1].ToolTip = "${Common.Business.MaxInv}"; e.Row.Cells[2].ToolTip = "${MRP.PlanViewType.TotalPlan}"; } for (int j = 0; j < GV_List.Columns.Count - _firstDynColIndex; j++) { //首次加载动态控件 TextBox _editControl = new TextBox(); _editControl.ID = this.GetDynControlID(j); _editControl.Width = 50; decimal planQty = (decimal)drv["DynCol_" + j.ToString()]; if (planQty > 0) { _editControl.Text = planQty.ToString("0.########"); } _editControl.Attributes.Add("onclick", "this.select()"); if (!e.Row.Cells[j + _firstDynColIndex].Controls.Contains(_editControl)) { e.Row.Cells[j + _firstDynColIndex].Controls.Add(_editControl); } } } //else if (planViewType == BusinessConstants.PLAN_VIEW_TYPE_ORDER) //{ // e.Row.Cells[3].Text = "订单"; //} else if (planViewType == BusinessConstants.PLAN_VIEW_TYPE_PAB) { //PAB e.Row.Cells[_firstDynColIndex - 1].Text = "${MRP.PlanViewType.PAB}"; //ToolTip e.Row.Cells[1].ToolTip = "${Common.Business.SafeInv}"; e.Row.Cells[2].ToolTip = "${Common.Business.StartPAB}"; decimal safeStock = decimal.Parse(drv["StaCol_1"].ToString()); for (int j = 0; j < GV_List.Columns.Count - _firstDynColIndex; j++) { decimal PAB = decimal.Parse(drv["DynCol_" + j.ToString()].ToString()); if (PAB < 0) { e.Row.Cells[j + _firstDynColIndex].BackColor = Color.Red; } else if (PAB < safeStock) { e.Row.Cells[j + _firstDynColIndex].BackColor = Color.Yellow; } else { e.Row.Cells[j + _firstDynColIndex].BackColor = Color.LawnGreen; } } } } else if (e.Row.RowType == DataControlRowType.Header) { e.Row.Cells[0].Text = "${Common.Business.ItemCode}"; e.Row.Cells[1].Text = "${Common.Business.ItemDescription}"; if (ModuleType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_DMDSCHEDULE) { e.Row.Cells[2].Text = "${Common.Business.ReferenceItemCode}"; e.Row.Cells[3].Text = "${Common.Business.Uom}"; } else { e.Row.Cells[2].Text = "${Common.Business.Total}"; e.Row.Cells[3].Text = "${Common.Business.Date}"; } } }