using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using DevExpress.XtraEditors; using DevExpress.XtraGrid.Views.Grid; using DevExpress.XtraGrid; using System.IO; using Uninpho.DBOperation.Operation; using Uninpho.DBOperation.Model; namespace Uninpho.Tools.components.DataAnalysis { /// /// 读取检测车信息 /// class jiancecheShowClass { /// /// combobox显示函数 /// /// 是否更新检测车信息 /// 需要更新的ComboBoxEdit public static void comboboxShowMain(bool isLoad,ref ComboBoxEdit box01, ref ComboBoxEdit box02) { List res = new List(); string[] arr = new string[] { "轨检车"};//,"CRH2C-2061","CRH2C-2068","CRH2C-2150","CRH2J-0205","CRH5J-0501","CRH380AJ-0201", // "CRH380AJ-0202","CRH380AJ-0203","CRH380AJ-2808","CRH380AJ-2818","CRH380AM-0204","CRH380BJ-0301","CRH380BJ-A-0504" foreach (var item in arr) { res.Add(item); } string jccxxpath = Application.StartupPath+ "\\检测车信息.txt"; if (isLoad) { var dialog = new OpenFileDialog(); dialog.Multiselect = false; dialog.Title = "请选择检测车信息文件"; dialog.Filter = "txt文件(*.txt)|*.txt"; if (dialog.ShowDialog() == DialogResult.OK) { DACommon.FileCopy(dialog.FileName, jccxxpath); XtraMessageBox.Show("检测车信息更新成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (File.Exists(jccxxpath)) { res.Clear(); //读txt文件 StreamReader SR = new StreamReader(jccxxpath); while (!SR.EndOfStream) { res.Add(SR.ReadLine().Trim()); } } DACommon.jccList = res; box01.Properties.Items.Clear(); box02.Properties.Items.Clear(); foreach (var item in res) { box01.Properties.Items.Add(item); box02.Properties.Items.Add(item); } box01.Text = box01.Properties.Items[0].ToString(); box02.Text = box01.Properties.Items[0].ToString(); } /// /// 更新数据库中检测车信息 /// /// 几何GridControl /// 轮轨力GridControl /// 几何combox /// 几何gridview /// 轮轨力combox /// 轮轨力gridview /// 当前tab名 /// 执行删除还是更新检测车?true为更新、false为删除数据 public static void updataJccxx2PG(bool iswhat,ref GridControl GC1,ref GridControl GC2,ref ComboBoxEdit cbeJH,ref GridView GVJH, ref ComboBoxEdit cbeLGL, ref GridView GVLGL, string tabname) { if (tabname == "xtraTabPageLGL") { updataJccxx2PGFun(ref cbeLGL, ref GVLGL, iswhat); //List daochaLists = DataAnalysisToPG.getfile("mat") as List; //GC2.DataSource = daochaLists; } else if (tabname == "xtraTabPageJH") { updataJccxx2PGFun(ref cbeJH, ref GVJH, iswhat); //List daochaLists = DataAnalysisToPG.getfile("geo") as List; //GC1.DataSource = daochaLists; } } private static void updataJccxx2PGFun(ref ComboBoxEdit cbe, ref GridView GV,bool iswhat) { try { var row = GV.GetSelectedRows(); if (row.Length == 0) { XtraMessageBox.Show("请先选择文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (iswhat) { foreach (var i in row) { var va1 = GV.GetRowCellValue(i, "Id").ToString(); var hz = GV.GetRowCellValue(i, "Yswjm").ToString(); T_file_account tarr = new T_file_account() { Id = Convert.ToInt32(va1), Jccxx = cbe.SelectedItem.ToString(), Yswjm = hz }; DataAnalysisToPG.UpdataToPG(tarr); GV.SetRowCellValue(i, "Jccxx", "轨检车"); // "轨检车" cbe.SelectedItem.ToString() } XtraMessageBox.Show("已修所选文件正检测车信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (XtraMessageBox.Show("是否删除所选?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { for (int i = row.Length - 1; i >= 0; i--) { var va1 = GV.GetRowCellValue(row[i], "Id").ToString(); var hz = GV.GetRowCellValue(row[i], "Yswjm").ToString(); T_file_account tarr = new T_file_account() { Id = Convert.ToInt32(va1), Jccxx = cbe.SelectedItem.ToString(), Yswjm = hz }; DataAnalysisToPG.DelToPG(tarr); GV.DeleteRow(row[i]); } //if (Path.GetExtension(hz) == ".geo") //{ // List whichupdata = (List)DataAnalysisToPG.QueryToPGByName(hz); // DataAnalysisToPG.DelToPGJHBX(whichupdata); // DataAnalysisToPG.DelToPGJH(tarr); //} //else //{ // List whichupdata = (List)DataAnalysisToPG.QueryToPGByNameL(hz); // DataAnalysisToPG.DelToPGLGLBX(whichupdata); // DataAnalysisToPG.DelToPGLGL(tarr); //} XtraMessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } catch (Exception) { if (iswhat) { XtraMessageBox.Show("修正检测车信息失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { XtraMessageBox.Show("删除失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } throw; } } } }