using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using WMS.Frm.Base; using WMS.Model.Base; using WMS.Common; using WMS.Base.WebService; using WMS.Ctrl; namespace WMS.FrmBaseData { public partial class FrmLineList : FormBase { /// /// 线路信息MODEL /// LineInfoModel infomodel = new LineInfoModel(); /// /// 线路明细MODEL /// LineListModel listmodel = new LineListModel(); /// /// 线路明细数据源 /// List SourceList = new List(); List copyList = new List(); List addList = new List(); List upList = new List(); List delList = new List(); /// /// 业务类型 /// int workflag;//0 增加 1 修改 2 删除 ; /// /// 初始化 /// /// 线路信息 /// 业务类型 public FrmLineList(LineInfoModel infomodel,int flag) { this.infomodel = infomodel; workflag = flag; InitializeComponent(); } /// /// 页面加载 /// /// /// private void FrmLineList_Load(object sender, EventArgs e) { LEPCreate.LoadData(); LEPWay.LoadData(); bindlookupdeit(); bind(); } /// /// 绑定下拉框 /// private void bindlookupdeit() { string strAddressAreaModel = Newtonsoft.Json.JsonConvert.SerializeObject(new AddressAreaModel()); string strlistAddressAreaModel = WebLockConfig.Instance.WebAddressArea.GetAddressArea(strAddressAreaModel); try { List list = Newtonsoft.Json.JsonConvert.DeserializeObject>(strlistAddressAreaModel); list = list.FindAll(r => r.Lev == "2" || r.Lev == "1"); TLEPSTR.Properties.DataSource = list; TLEPSTR.Properties.DisplayMember = "Add_name"; TLEPSTR.Properties.ValueMember = "Add_id"; TLEPEDD.Properties.DataSource = list; TLEPEDD.Properties.DisplayMember = "Add_name"; TLEPEDD.Properties.ValueMember = "Add_id"; repositoryItemTreeListLookUpEdit1.DataSource = list; repositoryItemTreeListLookUpEdit1.DisplayMember = "Add_name"; repositoryItemTreeListLookUpEdit1.ValueMember = "Add_id"; repositoryItemTreeListLookUpEdit1.TreeList.KeyFieldName = "Add_id"; repositoryItemTreeListLookUpEdit1.TreeList.ParentFieldName = "Add_pid"; } catch (Exception) { SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } } /// /// 绑定信息 /// private void bind() { BSLineInfo.DataSource = infomodel; listmodel.LINE_ID = infomodel.LINE_ID; try { string strLineListModel = Newtonsoft.Json.JsonConvert.SerializeObject(listmodel); string strListLineListModel = WebLockConfig.Instance.WebLineList.execLineListGetList(strLineListModel); SourceList = Newtonsoft.Json.JsonConvert.DeserializeObject>(strListLineListModel); } catch (Exception) { SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } GCLineList.DataSource = SourceList; copyList = SourceList.ToList(); } /// /// 退出按键 /// /// /// private void btnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 页面保存按键 /// /// /// private void btnCommit_Click(object sender, EventArgs e) { BSLineInfo.EndEdit(); GVLineList.CloseEditor(); infomodel = BSLineInfo.DataSource as LineInfoModel; if (string.IsNullOrEmpty(infomodel.LINE_ID)) { SystemCommon.ShowInfoMessageBox("线路编号未填写!"); txtLineID.Focus(); return; } if (string.IsNullOrEmpty(infomodel.LINE_NAME)) { SystemCommon.ShowInfoMessageBox("线路名称未填写!"); txtLineID.Focus(); return; } if (string.IsNullOrEmpty(infomodel.ID)) { infomodel.ID = Guid.NewGuid().ToString(); } string strLineInfoModel = Newtonsoft.Json.JsonConvert.SerializeObject(infomodel); string errtxt = string.Empty; if (workflag == 0) { errtxt = WebLockConfig.Instance.WebLineInfo.execLineInfoAdd(strLineInfoModel); } else if (workflag == 1) { errtxt = WebLockConfig.Instance.WebLineInfo.execLineInfoUp(strLineInfoModel); } if (!string.IsNullOrEmpty(errtxt)) { SystemCommon.ShowErrorMessageBox(errtxt); } else { SystemCommon.ShowInfoMessageBox("操作成功!"); } if (workflag == 0) { infomodel = new LineInfoModel(); } else { this.Close(); } } /// /// 线路明细增加信息 /// /// /// private void btnADD_Click(object sender, EventArgs e) { LineListModel mod = new LineListModel(); mod.LINE_ID = infomodel.LINE_ID; mod.ID = Guid.NewGuid().ToString(); SourceList.Add(mod); BSLineList.DataSource = SourceList; GVLineList.RefreshData(); } /// /// 线路明细删除信息 /// /// /// private void btDel_Click(object sender, EventArgs e) { if (GVLineList.FocusedRowHandle < 0) { SystemCommon.ShowInfoMessageBox("无需删除的线路信息!"); return; } LineListModel mod = SourceList[GVLineList.FocusedRowHandle]; SourceList.Remove(mod); if (addList.Contains(mod)) { addList.Remove(mod); } if (upList.Contains(mod)) { upList.Remove(mod); } if (!string.IsNullOrEmpty(mod.LINE_CITY)) { delList.Add(mod); } BSLineList.DataSource = SourceList; GVLineList.RefreshData(); } /// /// 保存线路明细 /// /// /// private void btSave_Click(object sender, EventArgs e) { if (addList.Count == 0 && delList.Count == 0 && upList.Count == 0) { SystemCommon.ShowInfoMessageBox("无需保存的线路信息!"); return; } string errtxt = string.Empty; string straddList = Newtonsoft.Json.JsonConvert.SerializeObject(addList); string strdelList = Newtonsoft.Json.JsonConvert.SerializeObject(delList); string strupList = Newtonsoft.Json.JsonConvert.SerializeObject(upList); errtxt = WebLockConfig.Instance.WebLineList.newLineListFuc(strupList,straddList,strdelList); if (!string.IsNullOrEmpty(errtxt)) { SystemCommon.ShowErrorMessageBox(errtxt); } else { SystemCommon.ShowInfoMessageBox("操作成功!"); listmodel.LINE_ID = infomodel.LINE_ID; string strLineListModel = Newtonsoft.Json.JsonConvert.SerializeObject(listmodel); string strListLineListModel = WebLockConfig.Instance.WebLineList.execLineListGetList(strLineListModel); SourceList = Newtonsoft.Json.JsonConvert.DeserializeObject>(strListLineListModel); GCLineList.DataSource = SourceList; copyList = SourceList.ToList(); } addList.Clear(); upList.Clear(); delList.Clear(); } /// /// 如果已有城市间距信息自动带出 /// /// /// private void GVLineList_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { labelControl1.Focus(); LineListModel focModel = SourceList[e.RowHandle]; if (!addList.Contains(focModel) && !copyList.Contains(focModel)) { addList.Add(focModel); } if (!upList.Contains(focModel) && copyList.Contains(focModel)) { upList.Add(focModel); } if (e.Column.ColumnEditName == "repositoryItemLookUpEdit2") { InterCityModel mod = new InterCityModel(); if (e.RowHandle > 0) { mod.CITY_START = GVLineList.GetRowCellValue(e.RowHandle - 1, "LINE_CITY").ToString(); } else { mod.CITY_START = infomodel.LINE_START; } mod.CITY_EDD = GVLineList.GetRowCellValue(e.RowHandle, "LINE_CITY").ToString(); string strLineListModel = Newtonsoft.Json.JsonConvert.SerializeObject(mod); string strListInterCityModel = WebLockConfig.Instance.WebInterCity.execInterCityGetList(strLineListModel); List list = Newtonsoft.Json.JsonConvert.DeserializeObject>(strListInterCityModel); if (list.Count > 0) { focModel.LINE_MILEAGE = list[0].CITY_DISTANCE; focModel.LINE_TIME = list[0].CITY_TIME; } GVLineList.RefreshData(); } } } }