/// <summary> /// 记录 web 页面是否已加载完成 /// </summary> private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { try { int findCount = 1; foreach (SOHeaderEntity bill in this._list) { if (bill == null) { continue; } SortMapSendDataEntity data = new SortMapSendDataEntity() { BillID = bill.BillID, orderId = bill.BillNO, marketName = bill.CustomerName, marketAddress = bill.Address, lat = bill.YCoor, lng = bill.XCoor, boxNum = bill.BoxNum }; if (!this._sendDataList.Contains(data)) { this._sendDataList.Add(data); } findCount = 1; while (findCount > 0) { SortMapSendDataEntity findData = this._sendDataList.Find( u => u.lat == data.lat && u.lng == data.lng && u.BillID != data.BillID); if (findData == null) { findCount = 0; break; } else { data.lng += 0.0005m; } } } if (this._sendDataList.Count > 0) { string result = JsonConvert.SerializeObject(this._sendDataList); // 调用接口(javascript)方法 this.InvokeScript(M_INIT_MAP, result); } } catch (Exception ex) { MsgBox.Err("错误:" + ex.Message); } }
/// <summary> /// 将选择的订单导入到地图中显示 /// </summary> private void toolInsertMap_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { //Dictionary<string, object> settings = GlobeSettings.SystemSettings; //if (settings.ContainsKey("出库方式") && settings["出库方式"].ToString() == "1") //{ // MsgBox.Warn("出库方式已修改,请直接在【拣货计划】里操作!"); // return; //} if (!this._webIsCompleted) { MsgBox.Warn("等待加载地图请稍后..."); return; } int[] bills = this.gridView1.GetSelectedRows(); if (bills == null || bills.Length == 0) { MsgBox.Warn("请选择需要排序的单据!"); return; } using (WaitDialogForm dialog = new WaitDialogForm("正在计算并导入...")) { if (!this._webIsCompleted) { return; } this._list.Clear(); int findCount = 1; #region 组装选择的订单信息 foreach (int rowIndex in bills) { #region SOSummaryEntity bill = this.gridView1.GetRow(rowIndex) as SOSummaryEntity; if (bill == null) { continue; } SortMapSendDataEntity data = new SortMapSendDataEntity() { BillID = bill.BillID, orderId = bill.BillNO, marketName = bill.CustomerName, marketAddress = bill.Address, lat = bill.Ycoor, lng = bill.Xcoor, boxNum = bill.TotalCount }; if (!this._list.Contains(data)) { this._list.Add(data); } findCount = 1; while (findCount > 0) { SortMapSendDataEntity findData = this._list.Find(u => u.lat == data.lat && u.lng == data.lng && u.BillID != data.BillID); if (findData == null) { findCount = 0; break; } else { data.lng += 0.0005m; } } #endregion } #endregion #region 补单 CheckAgionCustomer(bills); #endregion this.SendData(); this.toolInsertMap.Enabled = !(this.toolUndo.Enabled = this.toolSubmit.Enabled = true); } } catch (Exception ex) { MsgBox.Err("错误:" + ex.Message); } }
/// <summary> /// 提交本组 /// </summary> private void toolSubmit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { object obj = null; if (!this._webIsCompleted || (obj = this.InvokeScript(this.Submit)) == null) { MsgBox.Warn("未找到已排序订单!"); return; } List <SortMapReceiveDataEntity> list = JsonConvert.DeserializeObject <List <SortMapReceiveDataEntity> >(obj.ToString()); if (list == null || list.Count == 0) { MsgBox.Warn("未找到已排序订单"); return; } if (list.Count == this._list.Count || MsgBox.AskOK("还有未排序的订单,是否继续提交?") == DialogResult.OK) { string billIDs = string.Empty; List <OrderSortEntity> sortList = new List <OrderSortEntity>(); string soNO = DateTime.Now.ToString("SOyyyyMMddHHmmssms"); foreach (SortMapReceiveDataEntity data in list) { SortMapSendDataEntity sendData = this._list.Find(new Predicate <SortMapSendDataEntity>( (item) => { return(item.orderId == data.orderId); })); if (sendData == null) { continue; } billIDs += string.Format("{0},", sendData.BillID); sortList.Add(new OrderSortEntity() { VehicleNo = soNO, BillNo = data.orderId, InVehicleSort = ConvertUtil.ToInt(data.paixu), PiecesQty = sendData.boxNum, Attri1 = 1 }); this._list.Remove(sendData); } //去除最后一个逗号 billIDs = billIDs.TrimEnd(','); string errBillNO = string.Empty; // 存储排序记录 Insert(sortList); bool recordCount = SaveSortOrders(billIDs, GlobeSettings.LoginedUser.UserName, out errBillNO); if (recordCount) { //this.InvokeScript(M_CLEAR_RIGHT); this.SendData(); //this.WebCompletedAction -= this.SendData; //this.WebCompletedAction += this.SendData; this.RefreshWeb(); this.LoadUnGroupBills(); MsgBox.OK("保存成功。"); } } } catch (Exception ex) { MsgBox.Err("错误:" + ex.Message); } }
/// <summary> /// 补单,检测是否有遗漏的相同客户不同订单 /// </summary> /// <param name="bills"></param> public void CheckAgionCustomer(object bills) { if (bills == null) { return; } try { #region int findCount = 1; foreach (int rowIndex in bills as int[]) { SOSummaryEntity bill = this.gridView1.GetRow(rowIndex) as SOSummaryEntity; if (bill == null) { continue; } #region for (int i = 0; i < gridView1.RowCount; i++) { SOSummaryEntity tmp = gridView1.GetRow(i) as SOSummaryEntity; if (tmp != null && bill.CustomerCode == tmp.CustomerCode && bill.BillNO != tmp.BillNO) { SortMapSendDataEntity data = new SortMapSendDataEntity() { BillID = tmp.BillID, orderId = tmp.BillNO, marketName = tmp.CustomerName, marketAddress = tmp.Address, lat = tmp.Ycoor, lng = tmp.Xcoor, boxNum = tmp.TotalCount }; if (!this._list.Contains(data)) { gridView1.SelectRow(i); this._list.Add(data); } findCount = 1; #region while (findCount > 0) { SortMapSendDataEntity findData = this._list.Find(u => u.lat == data.lat && u.lng == data.lng && u.BillID != data.BillID); if (findData == null) { findCount = 0; break; } else { data.lng += 0.0005m; } } #endregion } } #endregion } #endregion } catch (Exception ex) { throw ex; } }