123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using DevExpress.XtraEditors;
- using DevExpress.XtraGrid.Views.Grid;
- using Uninpho.DBOperation.Operation;
- using System.IO;
- using DevExpress.Spreadsheet;
- namespace Uninpho.Tools.components.MTLFF
- {
- public partial class LookDataFromMTLF : DevExpress.XtraEditors.XtraForm
- {
- string url;
- string uuid;
- int row;
- GridView gv;
- string nowtime = String.Empty;//记录修改时间
- List<StaticLogClass> newlogs = new List<StaticLogClass>();
- public LookDataFromMTLF(string url, GridView gv, int row)
- {
- InitializeComponent();
- this.url = url;
- this.uuid = gv.GetRowCellValue(row, "Id").ToString();
- this.row = row;
- this.gv = gv;
- sheetControl01.LoadDocument(url);
- sheetControl01.ReadOnly = true;
- }
- private void simpleButton1_Click(object sender, EventArgs e)
- {
- SaveFileDialog sfd = new SaveFileDialog();
- sfd.Filter = "xlsx files(*.xlsx)|*.xlsx|xlsx files(*.xlsx)|*.xlsx|All files(*.*)|*.*";
- sfd.FileName = "道岔全面检查记录表";//道岔全面检查记录表
- if (sfd.ShowDialog() == DialogResult.OK)
- {
- sheetControl01.SaveDocument(sfd.FileName);
- XtraMessageBox.Show("导出完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- //this.Close();
- }
- }
- /// <summary>
- /// 开始编辑
- /// </summary>
- private void EditBtn_Click(object sender, EventArgs e)
- {
- if (UserInform.userinf.Pow == 0)
- {
- XtraMessageBox.Show("您没有权限执行删除操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- if (sheetControl01.ReadOnly)
- {
- GengxinrenForm GX = new GengxinrenForm();
- if (GX.ShowDialog() == DialogResult.OK)
- {
- sheetControl01.ReadOnly = false;
- nowtime = DateTime.Now.ToString();
- EditBtn.Text = "结束编辑";
- XtraMessageBox.Show("用户:" + UserInform.userinf.Username + " 已启用编辑!再次点击结束编辑。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- else
- {
- sheetControl01.ReadOnly = true;
- EditBtn.Text = "编辑";
- XtraMessageBox.Show("用户:" + UserInform.userinf.Username + " 已结束编辑!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- }
- /// <summary>
- /// 保存
- /// </summary>
- private void reKeepBtn_Click(object sender, EventArgs e)
- {
- if (sheetControl01.ReadOnly)
- {
- XtraMessageBox.Show("请先启用编辑模式!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- sheetControl01.SaveDocument(url);
- string btyearr = ExcelTools.GetFileData(url);
- string datee = DateTime.Now.ToString();
- DBOperation.Model.T_mitielifeng_filelist tm = MTLFCommon.updataListMessage(gv, url, row);
- gv.SetRowCellValue(row, "Excelbytearr", btyearr);
- gv.SetRowCellValue(row, "Gengxinren", UserInform.userinf.Username);
- gv.SetRowCellValue(row, "Gengxinriqi", datee);
- tm.Id = uuid;
- tm.Excelbytearr = btyearr;
- tm.Gengxinren = UserInform.userinf.Username;
- tm.Gengxinriqi = datee;
- DataAnalysisToPG.UpdataToPGMTLF(tm);
- LogGeneratorFun.WriteLogJT(newlogs, Application.StartupPath + "//log//mt_" + uuid + ".log");
- newlogs.Clear();
- sheetControl01.ReadOnly = true;
- EditBtn.Text = "编辑";
- XtraMessageBox.Show("保存完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- private async void sheetControl01_CellValueChanged(object sender, DevExpress.XtraSpreadsheet.SpreadsheetCellEventArgs e)
- {
- await Task.Run(() =>
- {
- List<StaticLogClass> isExitLog = newlogs.FindAll(delegate (StaticLogClass log)
- {
- return int.Parse(log.Row) == e.RowIndex && int.Parse(log.Column) == e.ColumnIndex;
- });
- if (isExitLog.Count > 0)
- {
- var changedd = newlogs.Where(c => int.Parse(c.Column) == e.ColumnIndex && int.Parse(c.Row) == e.RowIndex).First();
- changedd.Newvalue = e.Value.ToString();
- }
- else
- {
- StaticLogClass sc = new StaticLogClass();
- sc.Column = e.ColumnIndex.ToString();
- sc.Row = e.RowIndex.ToString();
- sc.Username = UserInform.userinf.Username;
- sc.Newvalue = e.Value.ToString();
- sc.Oldvalue = e.OldValue.ToString();
- sc.Date = nowtime;
- newlogs.Add(sc);
- }
- });
- }
- private void XGJLBtn_Click(object sender, EventArgs e)
- {
- LoggingForm frm = new LoggingForm(Application.StartupPath + "//log//mt_" + uuid + ".log");
- frm.StartPosition = FormStartPosition.CenterParent;
- frm.Show(this);
- }
- }
- }
|