| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453 |
- using com.hnshituo.core.webapp.vo;
- using Common;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Windows.Forms;
- namespace MeterModuleLibrary
- {
- public delegate void EventOpenWgt(string e);
- public partial class ucCarMeterInfo : UserControl
- {
- public ucCarMeterInfo()
- {
- InitializeComponent();
- }
- private frmNumberKey fnk = null;
- private bool bFnk = false;
- private frmApplianceCheck fac = null;
- private bool bFac = false;
- private frmScaleQuery fah = null;
- private bool bFah = false;
- private frmPhNo fpn = null;
- private bool bFpn = false;
- public event EventOpenWgt openWgt;
- public event EventOpenWgt openTareWgt;
- /// <summary>
- /// 斗重
- /// </summary>
- public double dWeight = 0;
- public void setFormControlValue(UltraGridRow ugr)
- {
- txtPREDICTION_NO.Text = "";
- String bussinessNo = ugr.Cells["predictionNo"].Text.Trim();
- if (String.IsNullOrEmpty(bussinessNo))
- {
- bussinessNo = ugr.Cells["matterNo"].Text.Trim() + ugr.Cells["forwardingUnitNo"].Text.Trim() + ugr.Cells["receivingUintNo"].Text.Trim();
- }
- if (!String.IsNullOrEmpty(bussinessNo) && bussinessNo.Length == 9)
- {
- txtPREDICTION_NO.Text = bussinessNo;
- }
- txtMATTER_NAME.Text = ugr.Cells["matterName"].Text.Trim();
- txtFORWARDING_UNIT_NAME.Text = ugr.Cells["forwardingUnitName"].Text.Trim();
- txtRECEIVING_UINT_NAME.Text = ugr.Cells["receivingUintName"].Text.Trim();
- lp = new List<PbModelDb>();
- lp.Add(new PbModelDb { id = "matterNo", text = ugr.Cells["matterNo"].Text.Trim() });
- lp.Add(new PbModelDb { id = "matterName", text = ugr.Cells["matterName"].Text.Trim() });
- lp.Add(new PbModelDb { id = "forwardingUnitNo", text = ugr.Cells["forwardingUnitNo"].Text.Trim() });
- lp.Add(new PbModelDb { id = "forwardingUnitName", text = ugr.Cells["forwardingUnitName"].Text.Trim() });
- lp.Add(new PbModelDb { id = "receivingUintNo", text = ugr.Cells["receivingUintNo"].Text.Trim() });
- lp.Add(new PbModelDb { id = "receivingUintName", text = ugr.Cells["receivingUintName"].Text.Trim() });
- lp.Add(new PbModelDb { id = "meterTypeNo", text = ugr.Cells["meterTypeNo"].Text.Trim() });
- lp.Add(new PbModelDb { id = "meterTypeName", text = ugr.Cells["meterTypeName"].Text.Trim() });
- setAddWgtBtnVisable();
- }
- public void setFormControlValue(MeterWorkCarActualFirst first)
- {
- txtMATTER_NAME.Text = first.matterName;
- txtFORWARDING_UNIT_NAME.Text = first.forwardingUnitName;
- txtRECEIVING_UINT_NAME.Text = first.receivingUintName;
- lp = new List<PbModelDb>();
- lp.Add(new PbModelDb { id = "matterNo", text = first.matterNo });
- lp.Add(new PbModelDb { id = "matterName", text = first.matterName });
- lp.Add(new PbModelDb { id = "forwardingUnitNo", text = first.forwardingUnitNo });
- lp.Add(new PbModelDb { id = "forwardingUnitName", text = first.forwardingUnitName });
- lp.Add(new PbModelDb { id = "receivingUintNo", text = first.receivingUintNo });
- lp.Add(new PbModelDb { id = "receivingUintName", text = first.receivingUintName });
- lp.Add(new PbModelDb { id = "meterTypeNo", text = first.meterTypeNo });
- lp.Add(new PbModelDb { id = "meterTypeName", text = first.meterTypeName });
- txtBATCH_NO.Text = first.batchNo;
- if (!String.IsNullOrEmpty(first.predictionNo) && first.predictionNo.Length == 9)
- {
- txtPREDICTION_NO.Text = first.predictionNo; //2021年6月7日 杨秀东添加,用于临时委托,存到数据库中去
- }
- setAddWgtBtnVisable();
- //如果第一次计量是毛重
- if (first.weightType == "0" && lbWgt.Visible)
- {
- if (first.addWeight != null && first.addWeight.Value > 0)
- {
- lbWgt.Text = first.addWeight.Value + "";
- if (!string.IsNullOrEmpty(first.addWgtNo))
- {
- foreach (string str in first.addWgtNo.Split(','))
- {
- if (lb1.Items.Count < 7)
- {
- lb1.Items.Add(str);
- }
- else
- {
- lb2.Items.Add(str);
- }
- }
- }
- }
- else
- lbWgt.Text = "";
- lbWgt.Enabled = false;
- btnCheck.Visible = false;
- }
- }
- public string getAddWgtPk = "";
- private List<string> ls = new List<string>();
- private void btnCheck_Click(object sender, EventArgs e)
- {
- fac = new frmApplianceCheck();
- fac.ltAddWeightNo = ls == null ? null : ls;
- bFac = true;
- if (fac.ShowDialog() == DialogResult.OK)
- {
- bFac = false;
- lbUTENSIL_UTENSIL_NAME.Text = "";
- lbWgt.Text = "0";
- lb1.Items.Clear();
- lb2.Items.Clear();
- getAddWgtPk = "";
- DataTable dt = fac.dtChecked;
- ls = fac.ltAddWeightNo;
- if (dt != null && dt.Rows.Count > 0)
- {
- double dWgt = 0;
- foreach (DataRow dr in dt.Rows)
- {
- if (lbUTENSIL_UTENSIL_NAME.Text == "")
- {
- lbUTENSIL_UTENSIL_NAME.Text = dr["utensilUtensilName"].ToString();
- }
- if (lb1.Items.Count < 7)
- {
- lb1.Items.Add(dr["utensilNo"].ToString());
- }
- else
- {
- lb2.Items.Add(dr["utensilNo"].ToString());
- }
- dWgt += Convert.ToDouble(dr["utensilWeight"].ToString());
- getAddWgtPk += dr["addWeightNo"].ToString() + ",";
- }
- lbWgt.Text = dWgt + "";
- openWgt(dWgt + "");
- }
- }
- }
- public string getJz()
- {
- string sJz = "";
- foreach (string str in lb1.Items)
- {
- sJz += str + ",";
- }
- foreach (string str in lb2.Items)
- {
- sJz += str + ",";
- }
- return (sJz != "" ? sJz.Substring(0, sJz.Length - 1) : sJz);
- }
- public double getLbWgtValue
- {
- get
- {
- try
- {
- return string.IsNullOrEmpty(lbWgt.Text.Trim()) ? 0 : Convert.ToDouble(lbWgt.Text.Trim());
- }
- catch
- {
- return 0;
- }
- }
- }
- public List<PbModelDb> lp = null;
- /// <summary>
- /// 【业务编号】按钮点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnNo_Click(object sender, EventArgs e)
- {
- fah = new frmScaleQuery();
- bFah = true;
- if (fah.ShowDialog() == DialogResult.OK)
- {
- bFah = false;
- lp = new List<PbModelDb>();
- txtPREDICTION_NO.Text = fah.strValue;
- if (fah.ht != null && fah.ht.Count == 3)
- {
- txtMATTER_NAME.Text = fah.ht[2].text;
- txtFORWARDING_UNIT_NAME.Text = fah.ht[0].text;
- txtRECEIVING_UINT_NAME.Text = fah.ht[1].text;
- lp.Add(new PbModelDb { id = "matterNo", text = fah.ht[2].id });
- lp.Add(new PbModelDb { id = "matterName", text = fah.ht[2].text });
- lp.Add(new PbModelDb { id = "forwardingUnitNo", text = fah.ht[0].id });
- lp.Add(new PbModelDb { id = "forwardingUnitName", text = fah.ht[0].text });
- lp.Add(new PbModelDb { id = "receivingUintNo", text = fah.ht[1].id });
- lp.Add(new PbModelDb { id = "receivingUintName", text = fah.ht[1].text });
- }
- else
- {
- txtMATTER_NAME.Text = "";
- txtFORWARDING_UNIT_NAME.Text = "";
- txtRECEIVING_UINT_NAME.Text = "";
- lp.Add(new PbModelDb { id = "matterNo", text = "" });
- lp.Add(new PbModelDb { id = "matterName", text = "" });
- lp.Add(new PbModelDb { id = "forwardingUnitNo", text = "" });
- lp.Add(new PbModelDb { id = "forwardingUnitName", text = "" });
- lp.Add(new PbModelDb { id = "receivingUintNo", text = "" });
- lp.Add(new PbModelDb { id = "receivingUintName", text = "" });
- }
- setAddWgtBtnVisable();
- #region 如果有可用期限皮,且没有一次计量数据,且当前重量大于期限皮重1000kg 则将期限皮重量填充皮重
- MeterWorkCarActualFirstService workCarActualFirstService = new MeterWorkCarActualFirstService();
- RESTfulResult<List<MeterWorkCarActualFirst>> RESTfulResult = workCarActualFirstService.doQueryWf(new MeterWorkCarActualFirst { carNo = PbCache.collect.carno, valueFlag = "1" });
- if (RESTfulResult.Succeed)
- {
- if (RESTfulResult.Data == null || RESTfulResult.Data.Count == 0)
- {
- openTareWgt("");
- if (PbCache.isTermTare)
- {
- MeterBaseTermTareDataService termTareDate = new MeterBaseTermTareDataService();
- RESTfulResult<List<MeterBaseTermTareData>> rmD = termTareDate.doQueryWf(new MeterBaseTermTareData { carNo = PbCache.collect.carno });
- if (rmD.Succeed)
- {
- if (rmD.Data != null && rmD.Data.Count > 0 && (PbCache.collect.weight - rmD.Data[0].meterWeight.Value >= 1000))
- {
- openTareWgt(rmD.Data[0].meterWeight.Value + "");
- }
- }
- }
- }
- }
- #endregion 如果有可用期限皮,且没有一次计量数据,且当前重量大于期限皮重1000kg 则将期限皮重量填充皮重
- }
- }
- public string meterTypeName = "";
- public void setMeterType(string meterType)
- {
- txtMETER_TYPE.Text = meterType;
- meterTypeName = meterType;
- }
- #region 设置按钮是否可点击
- private bool btnCheckVisible = false;
- public bool BtnCheckVisible
- {
- get { return btnCheckVisible; }
- set
- {
- btnCheckVisible = value;
- SetText(value);
- }
- }
- private void SetText(bool bflag)
- {
- if (btnCheck.InvokeRequired)
- {
- Action<bool> action = new Action<bool>(SetText);
- Invoke(action, new object[] { bflag });
- }
- else
- {
- btnCheck.Visible = bflag;
- }
- }
- private bool btnNoVisible = false;
- public bool BtnNoVisible
- {
- get { return btnNoVisible; }
- set
- {
- btnNoVisible = value;
- SetNoText(value);
- }
- }
- private void SetNoText(bool bflag)
- {
- if (btnCheck.InvokeRequired)
- {
- Action<bool> action = new Action<bool>(SetNoText);
- Invoke(action, new object[] { bflag });
- }
- else
- {
- btnNo.Visible = bflag;
- }
- }
- #endregion 设置按钮是否可点击
- private void lbWgt_Enter(object sender, EventArgs e)
- {
- bFnk = true;
- fnk = new frmNumberKey();
- fnk.bControl = true;
- fnk.sValue = lbWgt.Text.Trim();
- if (fnk.ShowDialog() == DialogResult.OK)
- {
- bFnk = false;
- try
- {
- lbWgt.Text = fnk.sValue;
- }
- catch { }
- }
- }
- private void setAddWgtBtnVisable()
- {
- btnCheck.Visible = false;
- lbWgt.Visible = false;
- lbWgt.Text = "";
- PbCache.addWgt = 0;
- PbCache.isTermTare = false;
- if (lp != null && lp.Count > 0)
- {
- string sql = @"select matter_no id,
- allowed_tare_weight text,
- allowed_add_weight text2
- from meter_base_matter_info
- where valid_Flag = '1' and matter_no = '" + lp[0].text + "'";
- PbModelDbService<List<PbModelDb>> pb = new PbModelDbService<List<PbModelDb>>();
- RESTfulResult<List<PbModelDb>> rm = pb.executeSqlDataWf(sql);
- if (rm.Succeed)
- {
- if (rm.Data != null && rm.Data.Count > 0)
- {
- if (rm.Data[0].text == "1")
- {
- PbCache.isTermTare = true;
- }
- if (rm.Data[0].text2 == "1")
- {
- btnCheck.Visible = true;
- lbWgt.Visible = true;
- }
- }
- }
- }
- }
- private void lbWgt_TextChanged(object sender, EventArgs e)
- {
- openWgt(lbWgt.Text.Trim());
- }
- private void btnPC_Click(object sender, EventArgs e)
- {
- bFpn = true;
- fpn = new frmPhNo();
- if (fpn.ShowDialog() == DialogResult.OK)
- {
- bFpn = false;
- txtBATCH_NO.Text = string.IsNullOrEmpty(fpn.strValue) ? "" : fpn.strValue;
- }
- }
- /// <summary>
- /// 批次编号
- /// </summary>
- /// <returns></returns>
- public string batchNo()
- {
- return txtBATCH_NO.Text.Trim();
- }
- /// <summary>
- /// 业务号
- /// </summary>
- /// <returns></returns>
- public string predictionNo()
- {
- return txtPREDICTION_NO.Text.Trim();
- }
- public void ClosingFrm()
- {
- try
- {
- if (bFnk) fnk.Close();
- }
- catch { }
- try
- {
- if (bFac) fac.Close();
- }
- catch { }
- try
- {
- if (bFah) fah.Close();
- }
- catch { }
- try
- {
- if (bFpn) fpn.Close();
- }
- catch { }
- }
- }
- }
|