using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; using DevExpress.XtraEditors; using Uninpho.DBOperation.Operation; using Uninpho.DBOperation.Model; using Uninpho.Tools.components.MTLFF; namespace Uninpho.Tools.components.XXXW { public partial class XXXWCtrl : DevExpress.XtraEditors.XtraUserControl { public XXXWCtrl() { InitializeComponent(); ExcelTools.gridControl03 = gridControl1; ExcelTools.gridView03 = gridView1; } List dataSource = null; /// /// 波形查看 /// private void repositoryItemButtonEdit1_Click(object sender, EventArgs e) { } /// /// 数据查看 /// private void repositoryItemButtonEdit2_Click(object sender, EventArgs e) { int rowhandle = gridView1.FocusedRowHandle; string ID = gridView1.GetRowCellValue(rowhandle, "Id").ToString(); ShowDataForm ldf = new ShowDataForm(ID); ldf.StartPosition = FormStartPosition.CenterParent; ldf.ShowDialog(); } /// /// 批量删除 /// private void delPGBtn_Click(object sender, EventArgs e) { if (UserInform.userinf.Pow == 0) { XtraMessageBox.Show("您没有权限执行删除操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { var row = gridView1.GetSelectedRows(); if (row.Length == 0) { XtraMessageBox.Show("请选中删除的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (XtraMessageBox.Show("是否删除所选?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { for (int i = row.Length - 1; i >= 0; i--) { var va1 = gridView1.GetRowCellValue(row[i], "Id").ToString(); DataAnalysisToPG.DelToPGXXXW(va1); gridView1.DeleteRow(row[i]); } XtraMessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } /// /// 导入 /// private void newCreateBtn_Click(object sender, EventArgs e) { var dialog = new OpenFileDialog(); dialog.Multiselect = true; dialog.Title = "请选择文件夹"; dialog.Filter = "csv files(*.csv)|*.csv|All files(*.*)|*.*"; if (dialog.ShowDialog() == DialogResult.OK) { string[] filenames = dialog.FileNames; string[] checkeditem = new string[filenames.Length]; for (int i = 0; i < filenames.Length; i++) { checkeditem[i] = XXXWCommon.saveData2PG(filenames[i]); } var nowdata = DataAnalysisToPG.getfilexxxwL(); gridControl1.DataSource = nowdata; for (int i = 0; i < nowdata.Count; i++) { for (int j = 0; j < checkeditem.Length; j++) { if (gridView1.GetRowCellValue(i, "Id").ToString() == checkeditem[j]) { gridView1.SelectRow(i); } } } } } /// /// 初始化load界面 /// private void XXXWCtrl_Load(object sender, EventArgs e) { if (UserInform.isconnect) { dataSource = DataAnalysisToPG.getfilexxxwL(); gridControl1.DataSource = dataSource; } } /// /// 按时间筛选 /// private void btn_dm_query_Click(object sender, EventArgs e) { FilterDate(this.dateEdit1.DateTime, this.dateEdit2.DateTime); } public void FilterDate(DateTime start, DateTime end) { List filterDS = new List(); foreach (var item in dataSource) { DateTime riqi = DateTime.Parse(item.Jianchariqi); if ((start <= riqi) && (riqi <= end)) { filterDS.Add(item); } } this.gridControl1.DataSource = filterDS; this.gridView1.BestFitColumns(); } /// /// 重置 /// private void simpleButton4_Click_1(object sender, EventArgs e) { this.dateEdit1.EditValue = null; this.dateEdit2.EditValue = null; this.gridControl1.DataSource = dataSource; this.gridView1.BestFitColumns(); } /// /// 新建 /// private void simpleButton1_Click(object sender, EventArgs e) { CreateNewTableXXXW frm = new CreateNewTableXXXW(); frm.StartPosition = FormStartPosition.CenterParent; if (frm.ShowDialog(this) == DialogResult.OK) { } } } }