123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- 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
- {
- /// <summary>
- /// 读取检测车信息
- /// </summary>
- class jiancecheShowClass
- {
- /// <summary>
- /// combobox显示函数
- /// </summary>
- /// <param name="isLoad">是否更新检测车信息</param>
- /// <param name="box">需要更新的ComboBoxEdit</param>
- public static void comboboxShowMain(bool isLoad,ref ComboBoxEdit box01, ref ComboBoxEdit box02)
- {
- List<string> res = new List<string>();
- 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();
- }
- /// <summary>
- /// 更新数据库中检测车信息
- /// </summary>
- /// <param name="GC1">几何GridControl</param>
- /// <param name="GC2">轮轨力GridControl</param>
- /// <param name="cbeJH">几何combox</param>
- /// <param name="GVJH">几何gridview</param>
- /// <param name="cbeLGL">轮轨力combox</param>
- /// <param name="GVLGL">轮轨力gridview</param>
- /// <param name="tabname">当前tab名</param>
- /// <param name="iswhat">执行删除还是更新检测车?true为更新、false为删除数据</param>
- 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<T_file_account> daochaLists = DataAnalysisToPG.getfile("mat") as List<T_file_account>;
- //GC2.DataSource = daochaLists;
- }
- else if (tabname == "xtraTabPageJH")
- {
- updataJccxx2PGFun(ref cbeJH, ref GVJH, iswhat);
- //List<T_file_account> daochaLists = DataAnalysisToPG.getfile("geo") as List<T_file_account>;
- //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<T_jihefenxi_account> whichupdata = (List<T_jihefenxi_account>)DataAnalysisToPG.QueryToPGByName(hz);
- // DataAnalysisToPG.DelToPGJHBX(whichupdata);
- // DataAnalysisToPG.DelToPGJH(tarr);
- //}
- //else
- //{
- // List<T_lunguili_account> whichupdata = (List<T_lunguili_account>)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;
- }
- }
- }
- }
|