using HStation.Vmo;
|
using Yw;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class ImportAssetsExchangerCurveQLByPictureDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public ImportAssetsExchangerCurveQLByPictureDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
|
this.layoutControl1.SetupLayoutControl();
|
this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent;
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public event Action<HStation.Vmo.PhartDiagramRelationVmo> ReloadDataEvent;
|
|
private AssetsExchangerMainVmo _exchanger = null;
|
private PhartDiagramRelationVmo _vmo = null;
|
|
/// <summary>
|
///
|
/// </summary>
|
public void SetBindingData(AssetsExchangerMainVmo exchanger)
|
{
|
if (exchanger == null)
|
{
|
return;
|
}
|
_exchanger = exchanger;
|
_vmo = new PhartDiagramRelationVmo();
|
_vmo.ObjectType = HStation.Assets.DataType.ExchangerMain;
|
_vmo.ObjectID = exchanger.ID;
|
_vmo.Importance = 0;
|
this.txtImportance.EditValue = 0;
|
}
|
|
//验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(this.btnEditPicture.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.btnEditPicture, "必选项");
|
return false;
|
}
|
if (string.IsNullOrEmpty(this.txtName.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtName, "必填项");
|
return false;
|
}
|
return true;
|
}
|
|
//确定
|
private async void GeneralOkAndCancelCtrl1_OkEvent()
|
{
|
if (!Valid())
|
{
|
return;
|
}
|
var diagram = this.universalChartImageImportCtrl1.Get();
|
diagram.Name = this.txtName.Text.Trim();
|
var diagramId = await BLLFactory<Yw.BLL.PhartDiagramExtensions>.Instance.Insert(diagram);
|
if (diagramId < 1)
|
{
|
TipFormHelper.ShowError("图表信息保存失败!");
|
return;
|
}
|
_vmo.DiagramID = diagramId;
|
_vmo.OtherName = this.txtName.Text.Trim();
|
_vmo.Importance = int.Parse(this.txtImportance.EditValue.ToString());
|
_vmo.ID = await BLLFactory<HStation.BLL.PhartDiagramRelation>.Instance.Insert(_vmo);
|
if (_vmo.ID < 1)
|
{
|
TipFormHelper.ShowError("图表关联信息保存失败!");
|
return;
|
}
|
var vmo = await BLLFactory<HStation.BLL.PhartDiagramRelation>.Instance.GetByID(_vmo.ID);
|
this.ReloadDataEvent?.Invoke(vmo);
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
|
//导入图片
|
private void btnEditPicture_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
{
|
var dlg = new OpenFileDialog();
|
dlg.Title = "选择图片文件";
|
dlg.Filter = "图片|*.png;*.jpg";
|
if (dlg.ShowDialog() == DialogResult.OK)
|
{
|
var fileName = dlg.FileName;
|
this.btnEditPicture.EditValue = fileName;
|
this.universalChartImageImportCtrl1.SetBindingData(fileName, Yw.Ahart.eCurveType.QL);
|
}
|
}
|
}
|
}
|