private void btn重排_Click(object sender, EventArgs e) { 转关箱排车暂存组 entity = m_暂存计划区Grid.DisplayManager.CurrentItem as 转关箱排车暂存组; if (entity != null) { if (entity.IsActive) { MessageForm.ShowWarning("此暂存已经确认!"); return; } Clear(true); } }
private void Load排车任务(转关箱排车暂存组 暂存组) { if (暂存组.转关箱排车 == null) { return; } using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <转关箱排车暂存组>()) { rep.Initialize(暂存组.转关箱排车, 暂存组); Dictionary <string, int> dict = new Dictionary <string, int>(); Dictionary <string, Xceed.Grid.Cell> dictCell = new Dictionary <string, Xceed.Grid.Cell>(); foreach (Xceed.Grid.DataRow row in m_待排转关箱任务区Grid.DataRows) { System.Data.DataRowView rowView = row.Tag as System.Data.DataRowView; string s = rowView["序号"].ToString(); string[] ss = s.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); int idx = ConvertHelper.ToInt(ss[0]).Value; s = rowView["任务号"].ToString(); ss = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var i in ss) { dict[i] = idx; dictCell[i] = row.Cells["任务色调"]; } } Dictionary <车辆, Xceed.Grid.DataRow> cls = new Dictionary <车辆, Xceed.Grid.DataRow>(); foreach (Xceed.Grid.DataRow row in m_全部监管车辆及作业现状Grid.DataRows) { cls[row.Tag as 车辆] = row; } foreach (var i in 暂存组.转关箱排车) { if (dict.ContainsKey(i.任务号) && cls.ContainsKey(i.车辆)) { string fieldName = string.Format("第{0}天", i.天数序号); cls[i.车辆].Cells[fieldName].Value = dict[i.任务号].ToString(); cls[i.车辆].Cells[fieldName].Tag = dictCell[i.任务号]; ModifySrcCell(dictCell[i.任务号], -1); } } } }
void m_待排转关箱任务区Grid_GridDragStart(object sender, GridDataGragEventArgs e) { e.Data = null; e.AllowedEffect = System.Windows.Forms.DragDropEffects.None; 转关箱排车暂存组 entity = m_暂存计划区Grid.DisplayManager.CurrentItem as 转关箱排车暂存组; if (entity == null) { return; } Xceed.Grid.Cell srcCell = sender as Xceed.Grid.Cell; if (srcCell == null) { return; } if (srcCell.GridControl == m_待排转关箱任务区Grid && srcCell.ParentColumn.FieldName == m_topGridDragFildeName && srcCell.ParentRow.Cells[m_topGridDragFildeName].Value != null) { string s = srcCell.ParentRow.Cells[m_topGridDragFildeName].Value.ToString(); string[] ss = s.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); int? cnt = ConvertHelper.ToInt(ss[1]); if (cnt.HasValue && cnt.Value > 0) { e.Data = new System.Windows.Forms.DataObject(m_dragDataFormatAdd, srcCell); e.AllowedEffect = System.Windows.Forms.DragDropEffects.Link; } return; } if (srcCell.GridControl == m_全部监管车辆及作业现状Grid && srcCell.Value != null) { e.Data = new System.Windows.Forms.DataObject(m_dragDataFormatDelete, srcCell); e.AllowedEffect = System.Windows.Forms.DragDropEffects.Move; return; } }
void DisplayManager_PositionChanged(object sender, EventArgs e) { Clear(false); 转关箱排车暂存组 entity = m_暂存计划区Grid.DisplayManager.CurrentItem as 转关箱排车暂存组; if (entity == null) { btn计算机辅助优化.Enabled = false; btn全自动化.Enabled = false; btn确认.Enabled = false; btn暂存.Enabled = false; btn重排.Enabled = false; btn打印.Enabled = false; return; } if (entity.IsActive) { btn计算机辅助优化.Enabled = false; btn全自动化.Enabled = false; btn确认.Enabled = false; btn暂存.Enabled = false; btn重排.Enabled = false; } else { btn计算机辅助优化.Enabled = true; btn全自动化.Enabled = true; btn确认.Enabled = true; btn暂存.Enabled = true; btn重排.Enabled = true; } m_待排转关箱任务区Grid.DisplayManager.SearchManager.LoadData(SearchExpression.Eq("暂存组", entity.ID), null); m_待排转关箱任务区Grid.DisplayManager.SearchManager.WaitLoadData(); Load排车任务(entity); }
private void Confirm(转关箱排车暂存组 暂存组, bool 是否确认) { Dictionary <int, string[]> dict = new Dictionary <int, string[]>(); foreach (Xceed.Grid.DataRow row in m_待排转关箱任务区Grid.DataRows) { System.Data.DataRowView rowView = row.Tag as System.Data.DataRowView; string s = rowView["序号"].ToString(); string[] ss = s.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); int idx = ConvertHelper.ToInt(ss[0]).Value; s = rowView["任务号"].ToString(); ss = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); dict[idx] = ss; } Dictionary <int, int> dictIdx = new Dictionary <int, int>(); foreach (var i in dict.Keys) { dictIdx[i] = 0; } using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <转关箱排车暂存组>()) { try { rep.BeginTransaction(); rep.Attach(暂存组); 暂存组.IsActive = 是否确认 ? true : false; 暂存组.预排时间 = System.DateTime.Now; m_dao暂存组.Update(rep, 暂存组); if (暂存组.转关箱排车 != null) { foreach (var i in 暂存组.转关箱排车) { m_dao.Delete(rep, i); } 暂存组.转关箱排车.Clear(); } else { 暂存组.转关箱排车 = new List <转关箱排车计划>(); } foreach (Xceed.Grid.DataRow row in m_全部监管车辆及作业现状Grid.DataRows) { for (int i = 1; i <= Days; ++i) { string fieldName = string.Format("第{0}天", i); if (row.Cells[fieldName].Value != null) { int idx = ConvertHelper.ToInt(row.Cells[fieldName].Value).Value; System.Diagnostics.Debug.Assert(dict.ContainsKey(idx), "必须在现有待排任务中!"); string rwh = dict[idx][dictIdx[idx]]; dictIdx[idx] = dictIdx[idx] + 1; 转关箱排车计划 entity = new 转关箱排车计划(); entity.车辆 = row.Tag as 车辆; entity.任务号 = rwh; entity.日期 = 是否确认 ? (DateTime?)System.DateTime.Today.AddDays(i) : null; entity.天数序号 = i; entity.暂存组 = 暂存组; m_dao.Save(rep, entity); 暂存组.转关箱排车.Add(entity); } } } rep.CommitTransaction(); } catch (Exception ex) { rep.RollbackTransaction(); ExceptionProcess.ProcessWithNotify(ex); } } }