using DevExpress.Utils.Extensions;
|
using DevExpress.XtraEditors;
|
using ISupply.Model;
|
using ISupply.WinFrm.Main._UserControls;
|
|
namespace ISupply.WinFrm.Main.Buildings
|
{
|
public partial class EditBuildingForm : DevExpress.XtraEditors.XtraForm
|
{
|
public EditBuildingForm(Model.Building building)
|
{
|
InitializeComponent();
|
this._building = building;
|
LoadForm();
|
this.webView.Source = new Uri(AppDomain.CurrentDomain.BaseDirectory + "/web/html/map_select.html");
|
this.webView.WebMessageReceived += WebView21_WebMessageReceived;
|
this.webView.NavigationCompleted += WebView21_NavigationCompleted;
|
}
|
private BuildBaseModel _buildBaseModel;
|
private BuildWizardForm _buildWizardForm = new BuildWizardForm();
|
private HospitalWizardForm _hospitalWizardForm = new HospitalWizardForm();
|
private SchoolWizardForm _schoolWizardForm = new SchoolWizardForm();
|
private ShopWizardForm _shopWizardForm = new ShopWizardForm();
|
private Model.Building _building;
|
|
private void LoadForm()
|
{
|
this.panelControl1.Controls.Clear();
|
switch (_building.BuildingTypeID)
|
{
|
case 5:
|
this._buildWizardForm.Dock = DockStyle.Fill;
|
this.panelControl1.AddControl(this._buildWizardForm);
|
this._buildBaseModel = Yw.JsonHelper.Json2Object<BuildFormModel>(_building.FormJson);
|
this._buildWizardForm.SetData((BuildFormModel)this._buildBaseModel);
|
break;
|
case 1:
|
this._shopWizardForm.Dock = DockStyle.Fill;
|
this.panelControl1.AddControl(this._shopWizardForm);
|
this._buildBaseModel = Yw.JsonHelper.Json2Object<ShopFormModel>(_building.FormJson);
|
this._shopWizardForm.SetData((ShopFormModel)this._buildBaseModel);
|
break;
|
case 1749326578128654336:
|
this._hospitalWizardForm.Dock = DockStyle.Fill;
|
this.panelControl1.AddControl(this._hospitalWizardForm);
|
this._buildBaseModel = Yw.JsonHelper.Json2Object<HospitalFormModel>(_building.FormJson);
|
this._hospitalWizardForm.SetData((HospitalFormModel)this._buildBaseModel);
|
break;
|
case 1749326605509070848:
|
this._schoolWizardForm.Dock = DockStyle.Fill;
|
this.panelControl1.AddControl(this._schoolWizardForm);
|
this._buildBaseModel = Yw.JsonHelper.Json2Object<SchoolFormModel>(_building.FormJson);
|
this._schoolWizardForm.SetData((SchoolFormModel)this._buildBaseModel);
|
break;
|
}
|
this.TxtMemoEdit.EditValue = this._building.Description;
|
}
|
|
|
|
private void btnOk_Click(object sender, EventArgs e)
|
{
|
this.Hide();
|
switch (_building.BuildingTypeID)
|
{
|
case 5:
|
this._buildBaseModel = this._buildWizardForm.GetData();
|
break;
|
case 1:
|
this._buildBaseModel = this._shopWizardForm.GetData();
|
break;
|
case 1749326578128654336:
|
|
this._buildBaseModel = this._hospitalWizardForm.GetData();
|
break;
|
case 1749326605509070848:
|
|
this._buildBaseModel = this._schoolWizardForm.GetData();
|
break;
|
}
|
this._building.Name = this._buildBaseModel.Name;
|
this._building.Address = this._buildBaseModel.Address;
|
this._building.FormJson = Yw.JsonHelper.Object2Json(this._buildBaseModel);
|
this._building.Description = this.TxtMemoEdit.EditValue.ToString();
|
new BLL.Building().Update(this._building);
|
XtraMessageBox.Show("修改成功!");
|
DialogResult = DialogResult.OK;
|
}
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
{
|
this.Hide();
|
}
|
|
private Model.Building _model = null;
|
private void WebView21_WebMessageReceived(object sender, Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs e)
|
{
|
if (_model == null)
|
return;
|
var j = Yw.JsonHelper.Json2Object<FixationReceivedViewModel>(e.WebMessageAsJson);
|
switch (j.Oper)
|
{
|
case "getLocation":
|
var o = Yw.JsonHelper.Json2Object<AmapLocationViewModel>(j.Json);
|
_model.AmapId = o.id;
|
// _model.Address = buildWizardForm1.= o.address;
|
_model.Coordinate = o.location.lng + "," + o.location.lat;
|
break;
|
}
|
}
|
|
|
private void WebView21_NavigationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e)
|
{
|
if (_model == null)
|
return;
|
try
|
{
|
var obj = new
|
{
|
oper = "setMarker",
|
data = Yw.JsonHelper.Object2Json(new
|
{
|
loc = _model.Coordinate,
|
address = _model.Address,
|
name = _model.Name
|
})
|
};
|
var json = Yw.JsonHelper.Object2Json(obj);
|
webView.CoreWebView2.PostWebMessageAsJson(json);
|
}
|
catch (Exception error)
|
{
|
throw error;
|
}
|
}
|
|
}
|
}
|