| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.YdmBcPipeManage.Entity;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.YdmBcPipeManage.Demand
- {
- public partial class FrmGpM : FrmBase
- {
- string[] arr = null;
- OpeBase _ob;
- public FrmGpM(string[] plineCode, OpeBase ob)
- {
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- arr = plineCode;
- _ob = ob;
- InitializeComponent();
- }
- private void FrmBcM_Load(object sender, EventArgs e)
- {
- EntityHelper.ShowGridCaption<MatGpMEntity>(ultraGrid2.DisplayLayout.Bands[0]);
- initStorageNo();
- initDemandUser();
- this.ultraDemandUser.SelectedIndex = 0;
- }
- /// <summary>
- /// 加载需求单位
- /// </summary>
- private void initDemandUser()
- {
- BaseMethod.InitDemandUser(ultraDemandUser, _ob, arr);
- }
- /// <summary>
- /// 加载仓库
- /// </summary>
- private void initStorageNo()
- {
- BaseMethod.InitStorageNoGp(cmbStorageNo, _ob);
- }
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "Query":
- doQuery();
- break;
- case "AddDemand":
- addDemand();
- break;
- case"Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 查询库存
- /// </summary>
- private void doQuery()
- {
- string judgeNo = "";
- string flagStoveNo = "";
- if (this.chkJugeHeatNo.Checked && this.txtJugeNo.Text.Trim() != "")
- {
- judgeNo = this.txtJugeNo.Text.Trim();
- }
- if (this.chkFlagStoveNo.Checked && this.txtFlagStoveNo.Text != "")
- {
- flagStoveNo = this.txtFlagStoveNo.Text.ToString();
- }
-
- ArrayList parmList = new ArrayList();
- parmList.Add(judgeNo);
- parmList.Add(flagStoveNo);
- List<MatGpMEntity> listSource = EntityHelper.GetData<MatGpMEntity>(
- "com.steering.Demand.sever.FrmGpM.doQuery", new object[] { parmList, arr }, _ob);
- matGpMEntityBindingSource.DataSource = listSource;
- }
- /// <summary>
- /// 生成需求
- /// </summary>
- private void addDemand()
- {
- this.ultraGrid2.UpdateData();
- string tarStorageNo = "";
- string tarStorageName = "";
- string demandUserCode = "";
- string demandUser = "";
- int acount = 0;
- decimal wgt = 0;
- IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
- if (checkMagRows.Count() == 0)
- {
- MessageUtil.ShowTips("请选择需要申请用车的库存信息!");
- return;
- }
- //int groupStatus = checkMagRows.GroupBy(a => a.GetValue("QcmStaus")).Count();
- //if (groupStatus > 1)
- //{
- // MessageUtil.ShowTips("只有同种交库状态的信息才能同时申请用车!");
- // return;
- //}
- if (this.cmbStorageNo.Text.Trim() == "")
- {
- MessageUtil.ShowTips("申请用车时请选择目标仓库!");
- return;
- }
- else
- {
- tarStorageNo = this.cmbStorageNo.Value.ToString2();
- tarStorageName = this.cmbStorageNo.Text.ToString2();
- }
- if (this.ultraDemandUser.Text == "")
- {
- MessageUtil.ShowTips("申请用车时,请选择需求单位!");
- return;
- }
- else
- {
- demandUserCode = this.ultraDemandUser.Value.ToString2();
- demandUser = this.ultraDemandUser.Text;
- }
- foreach (UltraGridRow row in checkMagRows)
- {
- acount = acount + int.Parse(row.Cells["ActCount"].Text);
- wgt = wgt + decimal.Parse(row.Cells["ActWeight"].Text);
- }
- ArrayList parmList = new ArrayList();
- int s = 0;
- int scrapNum = 0;
- foreach (UltraGridRow row in checkMagRows)
- {
- if (row.Cells["QcmStaus"].Text == "废品")
- {
- if (s > 0)
- {
- break;
- }
- MatGpMEntity matZcMEntity = (MatGpMEntity)row.ListObject;
- matZcMEntity.FlagStoveNo = "000000";
- matZcMEntity.JudgeStoveNo = "000000";
-
- matZcMEntity.PlineCode = row.Cells["PlineCode"].Text;
- matZcMEntity.ActCount = acount;
- matZcMEntity.ActWeight = wgt;
- matZcMEntity.PlineName = row.Cells["PlineName"].Text;
- matZcMEntity.StorageNo = row.Cells["StorageNo"].Text;
- matZcMEntity.StorageName = row.Cells["StorageName"].Text;
- matZcMEntity.MaterialName = "管材废品";
- matZcMEntity.MaterialNo = "";
- matZcMEntity.Dimater = row.Cells["Dimater"].Text;
-
- string matBcEntity = JSONFormat.Format(matZcMEntity);
- parmList.Add(matBcEntity);
- s = s + 1;
- }
- else
- {
- MatGpMEntity matZcMEntity = (MatGpMEntity)row.ListObject;
- string matBcEntity = JSONFormat.Format(matZcMEntity);
- parmList.Add(matBcEntity);
- }
- }
-
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.Demand.sever.FrmGpM";
- ccp.MethodName = "doWriteDemand";
- ccp.ServerParams = new object[] { parmList, UserInfo.GetUserName(), tarStorageNo, tarStorageName,demandUserCode,demandUser };
- ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("申请用车成功!"))
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- }
- private void chkJugeHeatNo_CheckedChanged(object sender, EventArgs e)
- {
- this.txtJugeNo.Enabled = this.chkJugeHeatNo.Checked;
- }
- private void chkFlagStoveNo_CheckedChanged(object sender, EventArgs e)
- {
- this.txtFlagStoveNo.Enabled = this.chkFlagStoveNo.Checked;
- }
- private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
- {
- foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows)
- {
- if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
- {
- uRow.Cells["CHK"].Value = true;
- }
- }
- }
- private void ultraGrid2_CellChange(object sender, CellEventArgs e)
- {
-
- this.ultraGrid2.UpdateData();
- UltraGridRow row = this.ultraGrid2.ActiveRow;
- MatGpMEntity matBc = (MatGpMEntity)row.ListObject;
- if (matBc.ActCount.Equals("") || matBc.ActCount == null)
- {
- matBc.ActCount = 0;
- }
- string matBcEntity = JSONFormat.Format(matBc);
- if (e.Cell.Column.Key == "ActCount")
- {
- DataTable ds = ServerHelper.GetData("com.steering.Demand.sever.FrmGpM.doQueryWeight", new object[] { matBcEntity }, _ob);
- if (ds.Rows.Count > 0)
- {
- ultraGrid2.ActiveRow.Cells["ActWeight"].Value = ds.Rows[0][0].ToString();
- }
- }
- }
-
- }
- }
|