using HStation.Vmo;
|
|
namespace HStation.WinFrmUI.Xhs
|
{
|
public partial class EditProjectDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public EditProjectDlg()
|
{
|
InitializeComponent();
|
this.Load += AddProjectDlg_Load;
|
}
|
|
private async void AddProjectDlg_Load(object sender, EventArgs e)
|
{
|
this.mapSetSimpleMarkerContainer1.LoadCompletedEvent += MapSetSimpleMarkerContainer1_LoadCompletedEvent;
|
this.mapSetSimpleMarkerContainer1.SetMarkerEvent += MapSetSimpleMarkerContainer1_SetMarkerEvent;
|
await this.mapSetSimpleMarkerContainer1.InitialContainer();
|
}
|
|
public event Func<XhsProjectExtensionsVmo, Yw.Vmo.MapInfoVmo, Task<bool>> ReloadDataEvent;
|
|
private XhsProjectExtensionsVmo _xhsProjectExtensions;
|
|
private Yw.Model.Map.Marker _maker = null; //地图点信息
|
|
private Yw.Vmo.MapInfoVmo _mapinfo = null; //地图信息
|
|
public async void SetBindingData(long ID)
|
{
|
var bll = new BLL.XhsProjectExtensions();
|
var select = await bll.GetByID(ID);
|
if (select == null) return;
|
_xhsProjectExtensions = select;
|
this.TextProjectName.Text = _xhsProjectExtensions.Name;
|
this.TextCustomerName.Text = _xhsProjectExtensions.Customer;
|
this.TextDescription.Text = _xhsProjectExtensions.Description;
|
this.TextTagName.Text = _xhsProjectExtensions.TagName;
|
var mapinfo = await new Yw.BLL.MapInfo().Get(HStation.Xhs.DataType.XhsProject, ID, Yw.Map.Kind.Gaodei, Yw.Map.Purpose.Location);
|
if (mapinfo != null)
|
{
|
_mapinfo = mapinfo;
|
this.TextAddress.Text = Yw.Model.Map.Marker.ToModel(_mapinfo.Position).Address;
|
}
|
}
|
|
//数据验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(TextProjectName.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.TextProjectName, "必填项");
|
return false;
|
}
|
if (string.IsNullOrEmpty(TextCustomerName.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.TextCustomerName, "必填项");
|
return false;
|
}
|
return true;
|
}
|
|
//地图加载完成
|
private async void MapSetSimpleMarkerContainer1_LoadCompletedEvent()
|
{
|
if (_mapinfo != null)
|
{
|
await this.mapSetSimpleMarkerContainer1.LoadMarker(Yw.Model.Map.Marker.ToModel(_mapinfo.Position));
|
}
|
}
|
|
//设置位置
|
private void MapSetSimpleMarkerContainer1_SetMarkerEvent(Yw.Model.Map.Marker obj)
|
{
|
_maker = obj;
|
this.TextAddress.EditValue = obj.Address;
|
}
|
|
//确定
|
private async void BtnOk_Click(object sender, EventArgs e)
|
{
|
if (!Valid())
|
return;
|
_xhsProjectExtensions.Address = this.TextAddress.Text.Trim();
|
_xhsProjectExtensions.Customer = this.TextCustomerName.Text.Trim();
|
_xhsProjectExtensions.Description = this.TextDescription.Text.Trim();
|
_xhsProjectExtensions.Name = this.TextProjectName.Text.Trim();
|
_xhsProjectExtensions.TagName = this.TextTagName.Text.Trim();
|
_xhsProjectExtensions.SiteList = new List<XhsProjectSiteVmo>
|
{
|
new XhsProjectSiteVmo
|
{
|
Name=this.TextProjectName.Text,
|
Description=this.TextDescription.Text,
|
}
|
};
|
if (_maker != null)
|
{
|
_mapinfo.Position = _maker.ToJson();
|
}
|
if (await this.ReloadDataEvent.Invoke(_xhsProjectExtensions, _mapinfo))
|
{
|
TipFormHelper.ShowSucceed("修改成功!");
|
}
|
else
|
{
|
TipFormHelper.ShowError("修改失败!");
|
}
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|