| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Windows.Forms;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.YdmBcPipeManage.Entity;
- using CoreFS.CA06;
- namespace Core.StlMes.Client.YdmBcPipeManage.Demand
- {
- public partial class frmAssign : FrmBase
- {
- List<TmsCarBaseEntity> All = new List<TmsCarBaseEntity>();
- private readonly List<TmsDemandM> tmsDemandMs;
- private string startnode = "";
- private string endnode = "";
- public frmAssign(OpeBase _ob, List<TmsDemandM> tmsDemand)
- {
- InitializeComponent();
- //lblCarrierName.Text = tmsDemand[0].CarrierName;
- lblStart.Text = tmsDemand[0].StartNodeDesc;
- lblEnd.Text = tmsDemand[0].EndNodeDesc;
- lblUnplnQty.Text = tmsDemand.Sum(p => p.UnPlanQtyVal).ToString2();
- lblUnplnWt.Text = tmsDemand.Sum(p => p.UnPlanWtVal).ToString2();
- lblRealQty.Text = tmsDemand.Sum(p => p.CanPlanQtyVal).ToString2();
- lblRealWt.Text = tmsDemand.Sum(p => p.CanPlanWtVal).ToString2();
- ob = _ob;
- tmsDemandMs = tmsDemand;
- EntityHelper.ShowGridCaption<TmsCarBaseEntity>(ugStation.DisplayLayout.Bands[0]);
- All = EntityHelper.GetData<TmsCarBaseEntity>(
- "com.steering.Demand.sever.TmsDemandServer.queryCar", new[] {tmsDemand[0].CarrierCode},
- _ob);
- tmsCarBaseEntityBindingSource.DataSource = All;
- GridHelper.RefreshAndAutoSizeExceptColumns(ugStation, "CarDemandQty", "CarDemandWt");
- }
- private void txtQuery_TextChanged(object sender, EventArgs e)
- {
- if (All == null) return;
- tmsCarBaseEntityBindingSource.DataSource = string.IsNullOrWhiteSpace(txtQuery.Text.Trim())
- ? All
- : All.Where(
- p =>
- p.CarLicense.IndexOf(txtQuery.Text.Trim(), StringComparison.Ordinal) >= 0 ||
- p.CarNo.IndexOf(txtQuery.Text.Trim(), StringComparison.Ordinal) >= 0).ToList();
- ugStation.UpdateData();
- ugStation.Update();
- ugStation.Refresh();
- }
- private void ugStation_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- if (e.Cell.Column.Key != "Chk")
- {
- e.Cell.Row.Cells["Chk"].Value = true;
- }
- if (e.Cell.Column.Key == "CarDemandQty")
- {
- if (e.Cell.Text.Replace("_", "") == "") e.Cell.Row.Cells["CarDemandWt"].Value = null;
- else
- {
- try
- {
- e.Cell.Row.Cells["CarDemandWt"].Value = decimal.Round(decimal.Parse(lblRealWt.Text) /
- decimal.Parse(lblRealQty.Text) * decimal.Parse(e.Cell.Text.Replace("_", "")), 3);
- }
- catch (Exception ex)
- {
- e.Cell.Row.Cells["CarDemandWt"].Value = null;
- }
- }
- }
- }
- private void ubtSave_Click(object sender, EventArgs e)
- {
- ugStation.UpdateData();
- var data = tmsCarBaseEntityBindingSource.DataSource as List<TmsCarBaseEntity>;
- if (data == null)
- {
- MessageBox.Show("请选择需要分派的车辆");
- return;
- }
- var cars = data.Where(p => p.Chk).ToList();
- if (!cars.Any())
- {
- MessageBox.Show("请选择需要分派的车辆");
- return;
- }
- if (cars.Any(p => p.CarDemandQty == null || p.CarDemandQty < 0))
- {
- MessageBox.Show("请对勾选上的车辆分派需运输的支数!");
- return;
- }
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.Demand.sever.TmsDemandServer";
- ccp.MethodName = "Assign";
- ccp.ServerParams = new object[]
- {
- tmsDemandMs.Select(JSONFormat.Format).ToList(),
- cars.Select(JSONFormat.Format).ToList(),
- startnode,
- endnode,
- UserInfo.GetUserName()
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("分派成功!"))
- this.DialogResult = DialogResult.OK;
- }
-
- }
- private void ultraButton1_Click(object sender, EventArgs e)
- {
- using (var frmDemandSetting = new frmDemandSetting(ob))
- {
- if (frmDemandSetting.ShowDialog() == DialogResult.OK)
- {
- lblEnd.Text = frmDemandSetting.SelectRow.UnloadingDesc;
- endnode = frmDemandSetting.SelectRow.UnloadingCode;
- }
- }
- }
- }
- }
|