| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using DevExpress.LookAndFeel;
- using DevExpress.Xpo.DB.Exceptions;
- using DevExpress.Xpo;
- using DevExpress.XtraEditors;
- using Ips.Library.Basic;
- using Ips.Library.DxpLib;
- 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 DevExpress.XtraLayout.Utils;
- using Ips.Library.Entity;
- namespace Ips.Sps.Emts
- {
- public partial class EmtEditForm : DevExpress.XtraEditors.XtraForm
- {
- public EmtEditForm()
- {
- InitializeComponent();
- EmtTypeImageComboBoxEdit.Properties.Items.AddEnum<EmtType>();
- }
- public EmtEditForm(int? id) : this()
- {
- this.Id = id;
- }
- public int? Id { get; private set; }
- protected UnitOfWork UnitOfWork { get; private set; }
- public Emt EditModel { get => (Emt)bsEmt.DataSource; }
- private void EmtEditForm_Load(object sender, EventArgs e)
- {
- UnitOfWork = new UnitOfWork();
- if (Id.HasValue)
- bsEmt.DataSource = UnitOfWork.GetObjectByKey<Emt>(Id.Value);
- else
- bsEmt.DataSource = new Emt(UnitOfWork);
- }
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- UnitOfWork.CommitChanges();
- Id = ((Emt)(bsEmt.DataSource)).Oid;
- this.DialogResult = DialogResult.OK;
- Close();
- }
- catch (LockingException)
- {
- MsgHelper.ShowError("对象已被修改,请关闭后重新打开进行编辑!");
- }
- }
- private void btnCancel_Click(object sender, EventArgs e)
- {
- Close();
- }
- private void SampleFileButtonEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
- {
- string sampleFile = ToolDialog.OpenFile("", "选择信号样本");
- if (sampleFile.IsNullOrWhitespace()) return;
- gvEmtSampleList.SetFocusedRowCellValue(colSampleFile, sampleFile);
- }
- private void lcgSamples_CustomButtonClick(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
- {
- string caption = e.Button.Properties.Caption;
- switch (caption)
- {
- case "添加":
- gvEmtSampleList.AddNewRow();
- break;
- case "删除":
- gvEmtSampleList.DeleteSelectedRows();
- break;
- }
- }
- private void HasSampleCheckEdit_CheckedChanged(object sender, EventArgs e)
- {
- lcgSamples.Visibility = HasSampleCheckEdit.Checked ? LayoutVisibility.Always : LayoutVisibility.Never;
- }
- private void EmtTypeImageComboBoxEdit_SelectedIndexChanged(object sender, EventArgs e)
- {
- var emtType = (EmtType)EmtTypeImageComboBoxEdit.EditValue;
- ItemForLon.Visibility = ItemForLat.Visibility = emtType == EmtType.FixSation ? LayoutVisibility.Always : LayoutVisibility.Never;
- }
- }
- }
|