| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.LgCommon;
- using Core.StlMes.Client.LgResMgt.Mcms.entity;
- using CoreFS.CA06;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- namespace Core.StlMes.Client.LgResMgt.Mcms
- {
- public partial class FrmBuyGpIn : FrmBase
- {
- public FrmBuyGpIn()
- {
- InitializeComponent();
- IsLoadUserView = true;
-
- }
- private string defaulStorage = "";
- private string defaulLocation = "";
- private string WeightPerMeterFormula = string.Empty;
- private Dictionary<string,List<LocationInfo>> storageList = new Dictionary<string, List<LocationInfo>>();
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- RegStartTime.Value = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00"));
- RegEndTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
- RegStartTime1.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
- RegEndTime1.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
- matGrid.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default;
- matGrid.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
- EntityHelper.ShowGridCaption<YdmGpInlistEntity>(ugInlist.DisplayLayout.Bands[0]);
-
- GetWeightPerMeterFormula();
- BindStorageDropDown();
- Query1();
- Query2();
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "DoQuery":
- Query();
- break;
- case "doSave":
- doSave();
- break;
- case "DoAdd":
- DoAdd();
- break;
- case "DoDelete":
- DoDelete();
- break;
- case "DoBeside":
- DoBeside();
- break;
- case "DoClose":
- Close();
- break;
- case "Export":
- Export();
- break;
-
- }
- }
- private void doSave(bool showOkMessage = true)
- {
- CmmWeightResultEntity entity = ugData.ActiveRow.ListObject as CmmWeightResultEntity;
- if (entity == null) return;
- matGrid.UpdateData();
- List<CmmWeightMatEntityFull> data = cmmWeightMatEntityBindingSource.DataSource as List<CmmWeightMatEntityFull>;
- if (data != null && data.Any(p => p.Chk))
- {
- data = data.Where(p => p.Chk).ToList();
- }
- else
- {
- MessageBox.Show("请勾选需要保存的信息");
- return;
- }
- //if (data.Any(p => p.InstoreType == "1" && p.ActWeight != p.EditWt))
- //{
- // MessageBox.Show("入库重量需和过磅重量一致!");
- // return;
- //}
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.Mcms.BuyGpInServer";
- ccp.MethodName = "doSave";
- ccp.ServerParams = new object[]
- {
- data.Select(JSONFormat.Format).ToList()
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Contains("成功"))
- {
- if (showOkMessage)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- ugData_AfterRowActivate(null, null);
- }
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- }
- private void Export()
- {
- if (tabC.ActiveTab == null) return;
- if (tabC.ActiveTab.Key == "1")
- {
- GridHelper.ulGridToExcel(ugData, "磅单明细");
- }
- else if (tabC.ActiveTab.Key == "2")
- {
- GridHelper.ulGridToExcel(ugInlist, "入库记录");
- }
-
- }
- private void DoBeside()
- {
- List<string> list;
- if ((ugData.Selected.Rows.Count <= 0) && (ugData.ActiveRow == null))
- {
- MessageBox.Show("请选择需要完成的数据!");
- return;
- }
- if (ugData.Selected.Rows.Count <= 0)
- list = new List<string>
- {
- (ugData.ActiveRow.ListObject as CmmWeightResultEntity).ResultNo
- };
- else
- list = (from UltraGridRow p in ugData.Selected.Rows
- select p.ListObject as CmmWeightResultEntity).Select(p => p.ResultNo).ToList();
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.Mcms.ResultServer";
- ccp.MethodName = "DoFinish";
- ccp.ServerParams = new object[]
- {
- list
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Contains("成功!"))
- Query1();
- }
- }
- private void DoDelete()
- {
- ugInlist.UpdateData();
- List<YdmGpInlistEntity> list = ydmGpInlistEntityBindingSource.DataSource as List<YdmGpInlistEntity>;
- if(list==null ) return;
- list = list.Where(p => p.Chk).ToList();
- if (!list.Any())
- {
- MessageBox.Show("请勾选需要撤销入库的数据!");
- return;
- }
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.Mcms.BuyGpInServer";
- ccp.MethodName = "DoDelete";
- ccp.ServerParams = new object[]
- {
- list.Select(JSONFormat.Format).ToList()
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Contains("成功!"))
- Query2();
- }
- }
- private void DoAdd()
- {
- CmmWeightResultEntity entity = ugData.ActiveRow.ListObject as CmmWeightResultEntity;
- if (entity == null) return;
- matGrid.UpdateData();
- List<CmmWeightMatEntityFull> data= cmmWeightMatEntityBindingSource.DataSource as List<CmmWeightMatEntityFull>;
- if (data != null && data.Any(p => p.Chk))
- {
- data = data.Where(p => p.Chk).ToList();
- }
- else
- {
- MessageBox.Show("请勾选需求要入库的信息");
- return;
- }
- if (data.Any(p =>
- {
- decimal editWt, actWt;
- if (decimal.TryParse(p.ActTheoryWeight.ToString3(), out actWt) &&
- decimal.TryParse(p.EditWt.ToString3(), out editWt))
- {
- if (Math.Abs(actWt - editWt) > 1)
- {
- return true;
- }
- }
- else
- {
- return true;
- }
- return false;
- }))
- {
- if (MessageUtil.ShowYesNoAndQuestion("入库重量与理论重量差别过大,请确认是否继续入库?") ==
- DialogResult.No) return;
- }
- //int quoteIndex = 0;//小数位数
- //double quoteValue = 0.0;
- //IQueryable<UltraGridRow> checkMagRows = this.matGrid.Rows.AsQueryable().Where(" CHK = 'True'");
- //foreach (UltraGridRow uRow in checkMagRows)
- //{
- // quoteValue = double.Parse(uRow.Cells["EditWt"].Text.ToString3()) / double.Parse(uRow.Cells["EditInstockNum"].Text.ToString3());
- // quoteIndex = quoteValue.ToString3().Length - quoteValue.ToString3().IndexOf('.') - 1;//小数位数
- // if (quoteIndex > 3)
- // {
- // MessageBox.Show("单支入库重量精度不对,请分多次入库。!");
- // return;
- // }
- //}
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.Mcms.BuyGpInServer";
- ccp.MethodName = "DoAdd";
- ccp.ServerParams = new object[]
- {
- data.Select(JSONFormat.Format).ToList(),entity.ResultNo, this.UserInfo.GetUserName()
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Contains("成功"))
- Query();
- }
- }
- private void Query()
- {
- if(tabC.ActiveTab==null) return;
- if (tabC.ActiveTab.Key == "1")
- {
- Query1();
- }
- else if (tabC.ActiveTab.Key == "2")
- {
- Query2();
- }
- }
- private void Query1()
- {
- var dic = new Dictionary<string, object>();
- if (chkTim.Checked)
- {
- dic.Add("time", RegStartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- dic.Add("time1", RegEndTime.Value.ToString("yyy-MM-dd HH:mm:ss"));
- }
- dic.Add("matType", "钢坯采购");
- if (chkShippersName.Checked)
- dic.Add("shippersName", uteShippersName.Text);
- dic.Add("validflag", new List<string> { "1" });
- if (chkJudgeStove.Checked)
- dic.Add("judgeStoveNo", uteJudgeStoveNo.Text);
- if (chkOrder.Checked)
- dic.Add("orderNo", utOrderNo.Text);
- dic.Add("storageFlag", new List<string>() { "1", "0" });
- List<CmmWeightResultEntity> list = EntityHelper.GetData<CmmWeightResultEntity>(
- "com.steering.Mcms.ResultServer.doQuery",
- new object[] { dic },
- ob);
- cmmWeightMatEntityBindingSource.Clear();
- if (list.Count == 0) return;
- List<CmmWeightResultEntity> listProject = EntityHelper.GetData<CmmWeightResultEntity>(
- "com.steering.Mcms.ResultServer.doCmmWeightMat",
- new object[] { list.Select(p => p.ResultNo).ToArray() }, ob);
- foreach (CmmWeightResultEntity entity in list)
- {
- entity.OrderFull = String.Join(",", listProject.Where(q => q.ResultNo == entity.ResultNo).Select(q => q.OrderFull).Distinct().ToList());
- entity.SpecName = String.Join(",", listProject.Where(q => q.ResultNo == entity.ResultNo).Select(q => q.SpecName).Distinct().ToList());
- entity.ActDimater = String.Join(",", listProject.Where(q => q.ResultNo == entity.ResultNo).Select(q => q.ActDimater).Distinct().ToList());
- entity.Steelname = String.Join(",", listProject.Where(q => q.ResultNo == entity.ResultNo).Select(q => q.Steelname).Distinct().ToList());
- entity.Producname = String.Join(",", listProject.Where(q => q.ResultNo == entity.ResultNo).Select(q => q.Producname).Distinct().ToList());
- entity.Gradename = String.Join(",", listProject.Where(q => q.ResultNo == entity.ResultNo).Select(q => q.Gradename).Distinct().ToList());
- entity.JudgeStoveNo = String.Join(",", listProject.Where(q => q.ResultNo == entity.ResultNo).Select(q => q.JudgeStoveNo).Distinct().ToList());
- }
- QueryBS.DataSource = list;
- Comm.RefreshAndAutoSize(ugData);
- }
- private void Query2()
- {
- var dic = new Dictionary<string, object>();
- if (chkTim.Checked)
- {
- dic.Add("time", RegStartTime1.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- dic.Add("time1", RegEndTime1.Value.ToString("yyy-MM-dd HH:mm:ss"));
- }
- if (chkJudgeStove1.Checked)
- dic.Add("judgeStoveNo", uteJudgeStoveNo1.Text);
- if (chkOrder1.Checked)
- dic.Add("orderNo", utOrderNo1.Text);
- List<YdmGpInlistEntity> list = EntityHelper.GetData<YdmGpInlistEntity>(
- "com.steering.Mcms.BuyGpInServer.doQueryInList",
- new object[] { dic },
- ob);
- ydmGpInlistEntityBindingSource.DataSource = list;
- Comm.RefreshAndAutoSize(ugInlist);
- }
- private void FrmBuyGpIn_Shown(object sender, EventArgs e)
- {
- if (toolMenu == null) return;
- if (toolMenu.Toolbars[0].Tools.Exists("DoDelete"))
- {
- toolMenu.Toolbars[0].Tools["DoDelete"].InstanceProps.Visible = DefaultableBoolean.False;
- }
- if (toolMenu.Toolbars[0].Tools.Exists("doSave"))
- {
- toolMenu.Toolbars[0].Tools["doSave"].InstanceProps.Visible = DefaultableBoolean.True;
- }
- }
- private void tabC_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
- {
- if (toolMenu == null) return;
- if (toolMenu.Toolbars[0].Tools.Exists("DoDelete"))
- toolMenu.Toolbars[0].Tools["DoDelete"].InstanceProps.Visible = tabC.SelectedTab.Key == "1" ? DefaultableBoolean.False : DefaultableBoolean.True;
- if (toolMenu.Toolbars[0].Tools.Exists("doSave"))
- toolMenu.Toolbars[0].Tools["doSave"].InstanceProps.Visible = tabC.SelectedTab.Key == "1" ? DefaultableBoolean.True : DefaultableBoolean.False;
- if (toolMenu.Toolbars[0].Tools.Exists("DoAdd"))
- toolMenu.Toolbars[0].Tools["DoAdd"].InstanceProps.Visible = tabC.SelectedTab.Key == "2" ? DefaultableBoolean.False : DefaultableBoolean.True;
- if (toolMenu.Toolbars[0].Tools.Exists("DoBeside"))
- toolMenu.Toolbars[0].Tools["DoBeside"].InstanceProps.Visible = tabC.SelectedTab.Key == "2" ? DefaultableBoolean.False : DefaultableBoolean.True;
- }
- private void ugData_AfterRowActivate(object sender, EventArgs e)
- {
- CmmWeightResultEntity data = ugData.ActiveRow.ListObject as CmmWeightResultEntity;
- if (data == null) return;
- List<CmmWeightMatEntityFull> list = EntityHelper.GetData<CmmWeightMatEntityFull>(
- "com.steering.Mcms.PoundMatServer.doQuery",
- new object[] { data.ResultNo },
- ob);
- for (var i = 0; i < list.Count; i++)
- {
- CmmWeightMatEntityFull p = list[i];
- decimal num = 0;
- if (decimal.TryParse(p.UnInstockNum, out num))
- {
- //入库支不等于0的自动勾上
- //p.Chk = num > 0;
- if (p.EditInstockNum == null || (!string.IsNullOrWhiteSpace(p.InstockNum) &&decimal.Parse( p.InstockNum)>0))
- p.EditInstockNum = num;
- }
- if (string.IsNullOrWhiteSpace(p.InstockNum)) p.InstockNum = "0";
-
- decimal len = 0;
- if (decimal.TryParse(p.ActLenTemp, out len) && p.EditLength==null)
- p.EditLength = len;
- decimal actCount = p.ActCount ?? 0;
- decimal dimater = 0;
- decimal.TryParse(p.ActDimater.ToString3(), out dimater);
-
- p.ActTheoryWeight = GetActTheoryWt(len,p.ActDimater) * p.ActCount;
- if (p.EditWt == null || (p.InstockNum != null && decimal.Parse(p.InstockNum) > 0))
- {
- if (p.InstoreType == "1")
- {
- if (p.EditInstockNum != null && p.EditInstockNum <= decimal.Parse(p.UnInstockNum) && p.PerWt != null)
- {
- try
- {
- p.EditWt = p.EditInstockNum == decimal.Parse(p.UnInstockNum)
- ? decimal.Parse(p.UnInstockWt)
- : Math.Round((decimal)(decimal.Parse(p.UnInstockWt) / decimal.Parse(p.UnInstockNum) * p.EditInstockNum), 3);
-
- }
- catch (Exception)
- {
- p.EditWt = null;
- }
- }
- else
- {
- p.EditWt = null;
- }
- }
- else
- {
- if (p.EditInstockNum != null && p.EditInstockNum <= p.RemainNum && p.PerWt != null)
- {
- try
- {
- p.EditWt = p.EditInstockNum == p.RemainNum
- ? p.RemainWt
- : Math.Round((decimal) (p.PerWt*p.EditInstockNum*p.EditLength), 3);
- }
- catch (Exception)
- {
- p.EditWt = null;
- }
- }
- else
- {
- p.EditWt = null;
- }
- }
- }
- else
- {
- //预报标记了来料清单 且是最后几支 不取保存的重量
- if (p.InstoreType != null && p.InstoreType == "2" && p.EditInstockNum == p.RemainNum)
- {
- p.EditWt = p.RemainWt;
- }
- }
- try
- {
- p.ActTheoryWeight = GetActTheoryWt(p.EditLength, p.ActDimater) * p.EditInstockNum;
- }
- catch (Exception)
- {
- p.ActTheoryWeight = null;
- }
- if (uceStorageNo.Items.Count > 0)
- {
- p.StorageNo = string.IsNullOrWhiteSpace(defaulStorage) ? uceStorageNo.Items[0].DataValue.ToString2() : defaulStorage;
- List<LocationInfo> locationInfos;
- if (!storageList.ContainsKey(p.StorageNo))
- {
- locationInfos = EntityHelper.GetData<LocationInfo>(
- "Core.LgMes.Server.LgDeviceManager.StorageManage.GetStorageLocationInfoNew",
- new[] {p.StorageNo}, ob);
- storageList.Add(p.StorageNo, locationInfos);
- }
- else
- {
- locationInfos = storageList[p.StorageNo];
- }
- if (locationInfos != null && locationInfos.Any())
- {
- var selectLoc = locationInfos.Where(no => no.LocationNo == defaulLocation).ToList();
- if (selectLoc.Any())
- {
- p.LocationNo = selectLoc[0].LocationNo;
- p.LocationName = selectLoc[0].LocationName;
- }
- else
- {
- p.LocationNo = locationInfos[0].LocationNo;
- p.LocationName = locationInfos[0].LocationName;
- }
-
- }
- }
- p.LaryNo = "1";
-
- }
- // uceStorageNoEdit.SelectedIndex = -1;
- cmmWeightMatEntityBindingSource.DataSource = list;
- if (matGrid.Rows.Count>0)
- {
- matGrid.Rows[0].Cells["EditWt"].EditorComponent = uteInputWt;
- }
- Comm.RefreshAndAutoSize(matGrid, new string[] { "EditWt" });
- }
- private decimal? GetActTheoryWt( decimal? len, decimal? actDimater)
- {
- try
- {
- var dt = new DataTable();
- decimal weightPerMeter;
- decimal.TryParse(
- dt.Compute(WeightPerMeterFormula.Replace("断面", actDimater.ToString2().Replace("250", "251")),
- null).ToString(),
- out weightPerMeter);
- return Math.Round(decimal.Parse((weightPerMeter*len/1000).ToString2()),3);
- }
- catch (Exception)
- {
- }
- return null;
- }
- private void matGrid_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
- {
- CmmWeightMatEntityFull list = e.Row.ListObject as CmmWeightMatEntityFull;
- if(list==null ) return;
- if (string.IsNullOrWhiteSpace(list.DocumentNo)) e.Row.Cells["OrderFull"].Appearance.BackColor = Color.Red;
- //if (!list.Chk) e.Row.Cells["Chk"].Appearance.BackColor = Color.DarkGray;
- //入库支为0时整行变灰
- if (int.Parse( e.Row.Cells["EditInstockNum"].Text.Replace("_", "").ToString3()) == 0)
- {
- e.Row.Appearance.BackColor = Color.DarkGray;
- }
-
- }
- private void matGrid_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- if (e.Cell.Column.Key == "Chk")
- {
- matGrid.UpdateData();
-
- //if((bool)e.Cell.Value) e.Cell.Appearance.ResetBackColor();
- //else e.Cell.Appearance.BackColor = Color.DarkGray;
- }
- else if (e.Cell.Column.Key == "StorageNo")
- {
- matGrid.UpdateData();
- List<LocationInfo> locationInfos;
- if (!storageList.ContainsKey(e.Cell.Value.ToString2()))
- {
- locationInfos = EntityHelper.GetData<LocationInfo>(
- "Core.LgMes.Server.LgDeviceManager.StorageManage.GetStorageLocationInfoNew",
- new[] { e.Cell.Value.ToString2() }, ob);
- storageList.Add(e.Cell.Value.ToString2(), locationInfos);
- }
- else
- {
- locationInfos = storageList[e.Cell.Value.ToString2()];
- }
- e.Cell.Row.Cells["LocationNo"].Value = locationInfos != null && locationInfos.Any()
- ? locationInfos[0].LocationNo
- : "";
- e.Cell.Row.Cells["LocationName"].Value = locationInfos != null && locationInfos.Any()
- ? locationInfos[0].LocationName
- : "";
- }
- else if (e.Cell.Column.Key == "EditInstockNum" || e.Cell.Column.Key == "EditLength")
- {
- try
- {
- e.Cell.Row.Cells["ActTheoryWeight"].Value = GetActTheoryWt(
- decimal.Parse(
- e.Cell.Row.Cells["EditLength"].Text.Replace(
- "_", "")),
- decimal.Parse(
- e.Cell.Row.Cells["ActDimater"].Value.ToString3()))
- *
- decimal.Parse(
- e.Cell.Row.Cells["EditInstockNum"].Text.Replace(
- "_", ""));
- }
- catch (Exception)
- {
- e.Cell.Row.Cells["ActTheoryWeight"].Value = null;
- }
- if (e.Cell.Row.Cells["InstoreType"].Value.ToString2() == "1")
- {
- if (string.IsNullOrWhiteSpace(e.Cell.Row.Cells["EditInstockNum"].Text.Replace("_", ""))
- || string.IsNullOrWhiteSpace(e.Cell.Row.Cells["EditLength"].Text.Replace("_", ""))
- || string.IsNullOrWhiteSpace(e.Cell.Row.Cells["PerWt"].Text.Replace("_", ""))
- )
- e.Cell.Row.Cells["EditWt"].Value = null;
- else
- {
- decimal num = decimal.Parse(e.Cell.Row.Cells["EditInstockNum"].Text.Replace("_", ""));
- decimal len = decimal.Parse(e.Cell.Row.Cells["EditLength"].Text.Replace("_", ""));
- decimal perWt = decimal.Parse(e.Cell.Row.Cells["PerWt"].Text.Replace("_", ""));
- decimal UnInstockNum = decimal.Parse(e.Cell.Row.Cells["UnInstockNum"].Value.ToString3());
- decimal UnInstockWt = decimal.Parse(e.Cell.Row.Cells["UnInstockWt"].Value.ToString3());
- if (num <= UnInstockNum)
- {
- decimal wt = num == UnInstockNum
- ? UnInstockWt
- : Math.Round(UnInstockWt / UnInstockNum * num, 3);
- if (wt > UnInstockWt) wt = UnInstockWt;
- e.Cell.Row.Cells["EditWt"].Value = wt;
- }
- else
- {
- e.Cell.Row.Cells["EditWt"].Value = null;
- }
- }
- }else
- {
- if (string.IsNullOrWhiteSpace(e.Cell.Row.Cells["EditInstockNum"].Text.Replace("_", ""))
- || string.IsNullOrWhiteSpace(e.Cell.Row.Cells["EditLength"].Text.Replace("_", ""))
- || string.IsNullOrWhiteSpace(e.Cell.Row.Cells["PerWt"].Text.Replace("_", ""))
- )
- e.Cell.Row.Cells["EditWt"].Value = null;
- else
- {
- decimal num = decimal.Parse(e.Cell.Row.Cells["EditInstockNum"].Text.Replace("_", ""));
- decimal len = decimal.Parse(e.Cell.Row.Cells["EditLength"].Text.Replace("_", ""));
- decimal perWt = decimal.Parse(e.Cell.Row.Cells["PerWt"].Text.Replace("_", ""));
- decimal RemaindNum = decimal.Parse(e.Cell.Row.Cells["RemainNum"].Value.ToString3());
- decimal RemainWt = decimal.Parse(e.Cell.Row.Cells["RemainWt"].Value.ToString3());
- if (num <= RemaindNum)
- {
- decimal wt = num == RemaindNum
- ? RemainWt
- : Math.Round(perWt*len*num, 3);
- if (wt > RemainWt) wt = RemainWt;
- e.Cell.Row.Cells["EditWt"].Value = wt;
- }
- else
- {
- e.Cell.Row.Cells["EditWt"].Value = null;
- }
- }
- }
- if (e.Cell.Column.Key == "EditLength")
- {
- //CmmWeightResultEntity data = ugData.ActiveRow.ListObject as CmmWeightResultEntity;
- //if (data == null) return;
- //List<CmmWeightMatEntityFull> list =
- // cmmWeightMatEntityBindingSource.DataSource as List<CmmWeightMatEntityFull>;
- //decimal singleLenWt = (decimal)data.NetWt / list.Where(p => p.ActCount != null && StringUtil.IsInt(p.ActLenTemp))
- // .Select(p => (decimal)p.ActCount * decimal.Parse(p.ActLenTemp) * decimal.Parse(p.ActDimater.ToString3()) * decimal.Parse(p.ActDimater.ToString3())).Sum();
- //decimal usedWt = 0;
- //for (var i = 0; i < matGrid.Rows.Count; i++)
- //{
- // decimal actCount, editLength,actDimater;
- // if (!decimal.TryParse(matGrid.Rows[i].Cells["ActCount"].Text.Replace(
- // "_", ""), out actCount))
- // {
- // actCount = 0;
- // }
- // if (!decimal.TryParse(matGrid.Rows[i].Cells["EditLength"].Text.Replace(
- // "_", ""), out editLength))
- // {
- // editLength = 0;
- // }
- // if (!decimal.TryParse(matGrid.Rows[i].Cells["ActDimater"].Text.Replace(
- //"_", ""), out actDimater))
- // {
- // actDimater = 0;
- // }
- // decimal actWt =
- // Math.Round(
- // i == list.Count - 1
- // ? (decimal)data.NetWt - usedWt
- // : singleLenWt * actCount * editLength * actDimater * actDimater, 3);
- // matGrid.Rows[i].Cells["ActWeight"].Value = actWt;
- // if (matGrid.Rows[i].Cells["EditLength"].Value.ToString2() == "1")
- // matGrid.Rows[i].Cells["EditWt"].Value = actWt;
- // usedWt = usedWt + actWt;
- //}
- }
-
- }
-
-
- }
- public void GetWeightPerMeterFormula()
- {
- try
- {
- var strErr = "";
- var arry = new ArrayList();
- arry.Add("frmBaseInfo_Parent.select");
- arry.Add("405202");
- var ccs = new CommonClientToServer();
- ccs.ob = ob;
- var ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry,
- out strErr);
- if ((ds != null) && (ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count > 0))
- WeightPerMeterFormula = Convert.ToString(ds.Tables[0].Rows[0]["BASENAME"]);
- }
- catch
- {
- }
- }
- public void BindStorageDropDown()
- {
- var dic = new Dictionary<string, object>();
- var customInfo = CustomInfo.ToString2();
- if (!string.IsNullOrWhiteSpace(customInfo))
- dic.Add("storageTypeNo", customInfo.Split(','));
- dic.Add("managementNo", ValidDataPurviewIds);
- var dt = ServerHelper.GetData("Core.LgMes.Server.LgDeviceManager.StorageManage.GetStorageNoList",
- new object[] { dic }, ob);
- if ((dt != null) && (dt.Rows.Count > 0))
- {
- uceStorageNo.DataSource = dt;
- uceStorageNo.ValueMember = "STORAGE_NO";
- uceStorageNo.DisplayMember = "STORAGE_NAME";
- uceStorageNoEdit.DataSource = dt;
- uceStorageNoEdit.ValueMember = "STORAGE_NO";
- uceStorageNoEdit.DisplayMember = "STORAGE_NAME";
- if (dt.AsEnumerable().Any(p => p["STORAGE_NO"].ToString2() == "LSG2"))
- {
- defaulStorage = "LSG2";
- }
- }
- }
- private void uteUpload2_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- if (string.IsNullOrWhiteSpace(matGrid.ActiveRow.Cells["StorageNo"].Value.ToString2())) return;
- using (var s = new StorageInfoSelect(matGrid.ActiveRow.Cells["StorageNo"].Value.ToString2(),ob))
- {
- if (s.ShowDialog() == DialogResult.OK)
- {
- matGrid.ActiveRow.Cells["LocationNo"].Value = s.SelectLocation.LocationNo;
- matGrid.ActiveRow.Cells["LocationName"].Value = s.SelectLocation.LocationName;
- matGrid.DisplayLayout.Bands[0].Columns["LocationName"].PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand, true);
- }
- }
- }
- private void utbLocaiton_Click(object sender, EventArgs e)
- {
- if (uceStorageNoEdit.SelectedIndex<0) return;
- using (var s = new StorageInfoSelect(uceStorageNoEdit.SelectedItem.DataValue.ToString2(), ob))
- {
- if (s.ShowDialog() == DialogResult.OK)
- {
- defaulLocation = s.SelectLocation.LocationNo;
- defaulStorage = s.SelectLocation.StorageNo;
- if (matGrid.Selected.Rows.Count > 0)
- {
- foreach (var ultraGridRow in matGrid.Selected.Rows)
- {
- ultraGridRow.Cells["StorageNo"].Value = s.SelectLocation.StorageNo;
- ultraGridRow.Cells["LocationNo"].Value = s.SelectLocation.LocationNo;
- ultraGridRow.Cells["LocationName"].Value = s.SelectLocation.LocationName;
- }
- }
- else
- {
- foreach (var ultraGridRow in matGrid.Rows)
- {
- ultraGridRow.Cells["StorageNo"].Value = s.SelectLocation.StorageNo;
- ultraGridRow.Cells["LocationNo"].Value = s.SelectLocation.LocationNo;
- ultraGridRow.Cells["LocationName"].Value = s.SelectLocation.LocationName;
- }
- }
- }
- }
- }
- private void uceStorageNoEdit_ValueChanged(object sender, EventArgs e)
- {
- defaulStorage = uceStorageNoEdit.Value.ToString2();
- if (matGrid.Selected.Rows.Count > 0)
- {
- foreach (var ultraGridRow in matGrid.Selected.Rows)
- {
- ultraGridRow.Cells["StorageNo"].Value = uceStorageNoEdit.Value.ToString2();
-
- List<LocationInfo> locationInfos;
- if (!storageList.ContainsKey( uceStorageNoEdit.Value.ToString2()))
- {
- locationInfos = EntityHelper.GetData<LocationInfo>(
- "Core.LgMes.Server.LgDeviceManager.StorageManage.GetStorageLocationInfoNew",
- new[] { uceStorageNoEdit.Value.ToString2() }, ob);
- storageList.Add( uceStorageNoEdit.Value.ToString2(), locationInfos);
- }
- else
- {
- locationInfos = storageList[uceStorageNoEdit.Value.ToString2()];
- }
- ultraGridRow.Cells["LocationNo"].Value = locationInfos != null && locationInfos.Any()
- ? locationInfos[0].LocationNo
- : "";
- ultraGridRow.Cells["LocationName"].Value = locationInfos != null && locationInfos.Any()
- ? locationInfos[0].LocationName
- : "";
- defaulLocation = locationInfos != null && locationInfos.Any()
- ? locationInfos[0].LocationNo
- : "";
- }
-
- }
- else
- {
- foreach (var ultraGridRow in matGrid.Rows)
- {
- ultraGridRow.Cells["StorageNo"].Value = uceStorageNoEdit.Value.ToString2();
- List<LocationInfo> locationInfos;
- if (!storageList.ContainsKey(uceStorageNoEdit.Value.ToString2()))
- {
- locationInfos = EntityHelper.GetData<LocationInfo>(
- "Core.LgMes.Server.LgDeviceManager.StorageManage.GetStorageLocationInfoNew",
- new[] { uceStorageNoEdit.Value.ToString2() }, ob);
- storageList.Add(uceStorageNoEdit.Value.ToString2(), locationInfos);
- }
- else
- {
- locationInfos = storageList[uceStorageNoEdit.Value.ToString2()];
- }
- ultraGridRow.Cells["LocationNo"].Value = locationInfos != null && locationInfos.Any()
- ? locationInfos[0].LocationNo
- : "";
- ultraGridRow.Cells["LocationName"].Value = locationInfos != null && locationInfos.Any()
- ? locationInfos[0].LocationName
- : "";
- }
- }
- }
- private void uteInputWt_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- decimal wt = 0;
- decimal currentWt = 0;
- bool canInput = false;
- foreach (var ultraGridRow in matGrid.Rows)
- {
- if ((bool) ultraGridRow.Cells["Chk"].Value)
- {
- decimal rowWt = 0;
- decimal rowActWt = 0;
- if (decimal.TryParse(ultraGridRow.Cells["ActTheoryWeight"].Value.ToString2(), out rowWt))
- {
- wt += rowWt;
- canInput = true;
- }
- if (decimal.TryParse(ultraGridRow.Cells["EditWt"].Value.ToString2(), out rowActWt))
- {
- currentWt += rowActWt;
- canInput = true;
- }
- }
- }
- if (!canInput)
- {
- MessageBox.Show("请先勾选数据,或者输入入库支");
- return;
- }
- using (var InputWt = new InputWt(currentWt))
- {
- if (InputWt.ShowDialog() == DialogResult.OK)
- {
- decimal remaidWt = wt;
- decimal remaidInputWt = InputWt.TotalWt;
- decimal perWt = InputWt.TotalWt/wt;
-
- foreach (var ultraGridRow in matGrid.Rows)
- {
- if ((bool)ultraGridRow.Cells["Chk"].Value)
- {
- decimal rowWt = 0;
- if (decimal.TryParse(ultraGridRow.Cells["ActTheoryWeight"].Value.ToString2(), out rowWt))
- {
- remaidWt = remaidWt - rowWt;
- decimal cWt = remaidWt <= 0
- ? remaidInputWt
- : Math.Round(perWt*rowWt, 3);
- ultraGridRow.Cells["EditWt"].Value = cWt;
- remaidInputWt = remaidInputWt - cWt;
- }
- }
- }
- doSave(false);
- }
- }
- }
- }
- }
|