123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- using DevExpress.XtraEditors;
- using ExtensionsDev;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using DW5S.App.Model;
- using DW5S.Entity;
- using DW5S.Repostory;
- namespace DW5S.App.PopupControl
- {
- public partial class ShowCgCtrl : DevExpress.XtraEditors.XtraUserControl
- {
- PosRes posItem;
- List<ModelCg> listCg = new List<ModelCg>();
- List<ModelCgXgf> listXgf = new List<ModelCgXgf>();
- public ShowCgCtrl()
- {
- InitializeComponent();
- this.layoutControl1.UseDefault();
- gridShowCg.UseDefault(listCg);
- gridCgXgf.UseDefault(listXgf).UseRowNumber();
- }
- public ShowCgCtrl(PosRes posItem)
- : this()
- {
- this.posItem = posItem;
- }
- private async void ShowCgCtrl_Load(object sender, EventArgs e)
- {
- List<SatInfo> sats = null;
- using (RHDWContext db = new RHDWContext())
- {
- sats = await db.SatInfos.ToListAsync();
- }
- List<ModelCg> list = new List<ModelCg>();
- using (RHDWPartContext db = RHDWPartContext.GetContext(posItem.SigTime))
- {
- if (db == null) return;
- var cgEntity = db.CgRes.Where(p => p.ID == posItem.CgResID).FirstOrDefault();
- if (cgEntity == null) return;
- //主邻1
- if (cgEntity.Adja1Code != null)
- {
- ModelCg item = new ModelCg()
- {
- ID = cgEntity.ID,
- CreateTime = cgEntity.CreateTime,
- UpdateTime = cgEntity.UpdateTime,
- SigTime = cgEntity.SigTime,
- Dto = cgEntity.Dto1,
- Dfo = cgEntity.Dfo1,
- Snr = cgEntity.Snr1,
- MainSat = cgEntity.MainCode?.ToString(),
- AdjaSat = cgEntity.Adja1Code.ToString(),
- CgType = 0,
- };
- var find = sats.Find(p => p.SatCode == cgEntity.MainCode.Value);
- if (find != null)
- item.MainSat = find.Sat;
- find = sats.Find(p => p.SatCode == cgEntity.Adja1Code.Value);
- if (find != null)
- item.AdjaSat = find.Sat;
- list.Add(item);
- }
- //主邻2
- if (cgEntity.Adja2Code != null)
- {
- ModelCg item = new ModelCg()
- {
- ID = cgEntity.ID,
- CreateTime = cgEntity.CreateTime,
- UpdateTime = cgEntity.UpdateTime,
- SigTime = cgEntity.SigTime,
- Dto = cgEntity.Dto2,
- Dfo = cgEntity.Dfo2,
- Snr = cgEntity.Snr2,
- MainSat = cgEntity.MainCode?.ToString(),
- AdjaSat = cgEntity.Adja2Code.ToString(),
- CgType = 1,
- };
- var find = sats.Find(p => p.SatCode == cgEntity.MainCode.Value);
- if (find != null)
- item.MainSat = find.Sat;
- find = sats.Find(p => p.SatCode == cgEntity.Adja2Code.Value);
- if (find != null)
- item.AdjaSat = find.Sat;
- list.Add(item);
- }
- //超短
- if (cgEntity.DtoCdb != null)
- {
- ModelCg item = new ModelCg()
- {
- ID = cgEntity.ID,
- CreateTime = cgEntity.CreateTime,
- UpdateTime = cgEntity.UpdateTime,
- SigTime = cgEntity.SigTime,
- Dto = cgEntity.DtoCdb,
- Dfo = cgEntity.DfoCdb,
- Snr = cgEntity.SnrCdb,
- MainSat = cgEntity.MainCode?.ToString(),
- AdjaSat = "超短站",
- CgType = 2,
- };
- var find = sats.Find(p => p.SatCode == cgEntity.MainCode.Value);
- if (find != null)
- item.MainSat = find.Sat;
- list.Add(item);
- }
- }
- this.listCg.Clear();
- this.listCg.AddRange(list);
- }
- private async void gridView1_FocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
- {
- listXgf.Clear();
- var cgItem = e.Row as ModelCg;
- if (cgItem != null)
- {
- using (RHDWPartContext db = RHDWPartContext.GetContext(cgItem.SigTime))
- {
- if (db != null)
- {
- var data = await db.CgXgfRes.Where(p => p.CgResID == cgItem.ID && p.CgType == cgItem.CgType).ToListAsync();
- listXgf.AddRange(data.Select(p => new ModelCgXgf
- {
- ID = p.ID,
- Dto = p.Dto,
- Dfo = p.Dfo,
- Snr = p.Snr,
- CreateTime = p.CreateTime,
- UpdateTime = p.UpdateTime,
- }));
- }
- }
- //查询相关峰结果
- }
- this.gridView2.RefreshData();
- }
- }
- }
|