示例#1
0
        public ProdutionWeightStd GetStandard(string spec, string length)
        {
            ProdutionWeightStd pws = null;
            DataRow[] drs = _dt.Select("FS_SPEC ='" + spec + "' and FN_LENGTH = '"+length+"'");
            if(drs.Length > 0)
            {
                try
                {
                    DataRow dr = drs[0];
                    pws = new ProdutionWeightStd();
                    pws.SeqNo = int.Parse(dr["FN_ID"].ToString());
                    pws.Spec = double.Parse(dr["FS_SPEC"].ToString());
                    pws.Lenght = double.Parse(dr["FN_LENGTH"].ToString());
                    pws.MinWeight = double.Parse(dr["FS_BUNDLEMINWWEIGHT"].ToString());
                    pws.MaxWeight = double.Parse(dr["FS_BUNDLEMAXWWEIGHT"].ToString());
                }
                catch (Exception ex)
                {

                }
            }
            return pws;
        }
示例#2
0
        public ProdutionWeightStd GetStandard(string spec, string length)
        {
            ProdutionWeightStd pws = null;

            DataRow[] drs = _dt.Select("FS_SPEC ='" + spec + "' and FN_LENGTH = '" + length + "'");
            if (drs.Length > 0)
            {
                try
                {
                    DataRow dr = drs[0];
                    pws           = new ProdutionWeightStd();
                    pws.SeqNo     = int.Parse(dr["FN_ID"].ToString());
                    pws.Spec      = double.Parse(dr["FS_SPEC"].ToString());
                    pws.Lenght    = double.Parse(dr["FN_LENGTH"].ToString());
                    pws.MinWeight = double.Parse(dr["FS_BUNDLEMINWWEIGHT"].ToString());
                    pws.MaxWeight = double.Parse(dr["FS_BUNDLEMAXWWEIGHT"].ToString());
                }
                catch (Exception ex)
                {
                }
            }
            return(pws);
        }
示例#3
0
        /// <summary>
        /// 绑定当前批次号的预报信息到界面
        /// </summary>
        /// <param name="dr"></param>
        private void BindPlanDataToControls(DataRow dr)
        {
            //if (m_bRunningForPoundRoom == false || dr == null)//线程已经关闭或数据为空
            //{
            //    return;
            //}

            if (dr == null)//线程已经关闭或数据为空
            {
                return;
            }

            string strSteelType = dr["FS_STEELTYPE"].ToString().Trim();

            if (strSteelType.Substring(strSteelType.Length - 2, 1) != "E" && strSteelType.Substring(strSteelType.Length - 1, 1)!="B")
            {
                strSteelType = strSteelType + "E";
            }

            this.txtZZBH.Text = dr["FS_BATCHNO"].ToString().Trim();//轧制批号
            this.txtDDH.Text = dr["FS_PRODUCTNO"].ToString().Trim();//订单号
            this.txtDDXMH.Text = dr["FS_ITEMNO"].ToString().Trim();//订单项目号
            //this.cbWLMC.Text = dr["FS_MATERIALNAME"].ToString().Trim();//物料名称
            if (dr["FS_FLOW"].ToString().Trim() != "")
                this.cbLX.Text = dr["FS_FLOW"].ToString().Trim();//流向
            this.cbGZ.Text = strSteelType;//钢种
            this.cbGG.Text = dr["FS_SPEC"].ToString().Trim();//规格
            this.cbLXIN.Text = dr["FS_FCLFLAG"].ToString().Trim().Equals("1") ? "非定尺" : "定尺";//类型
            if (dr["SENDER"].ToString().Trim() != "")
                this.cbFHDW.Text = dr["SENDER"].ToString().Trim();//发货单位
            if (dr["RECEIVER"].ToString().Trim() != "")
                this.cbSHDW.Text = dr["RECEIVER"].ToString().Trim();//收货单位
            this.txtZS.Text = dr["FN_SINGLENUM"].ToString().Trim();//单捆支数
            this.cbDCCD.Text = dr["FN_LENGTH"].ToString().Trim();//定尺长度
            this.cbPrintType.Text = dr["FS_PRINTTYPE"].ToString().Trim();//打印类型
            this.tbx_BandCount.Text = dr["FN_BANDCOUNT"].ToString().Trim(); //预报捆数

            //判断重量是否超限
            if (_weightStdManage != null)
            {
                try
                {
                    _produtionWeightStd = _weightStdManage.GetStandard(dr["FS_SPEC"].ToString().Trim(), dr["FN_LENGTH"].ToString().Trim());
                    if (_produtionWeightStd !=null)
                    {
                        this.textMaxWeight.Text = (this._produtionWeightStd.MaxWeight/1000).ToString()+"t";//
                        this.textMinWeight.Text = (this._produtionWeightStd.MinWeight/1000).ToString()+"t";
                    }
                }
                catch (Exception ex)
                {
                }
            }

            //查询本轧编打牌类型,理论重量
            _printType = dr["FS_PRINTWEIGHTTYPE"].ToString().Trim();
            //switch (_printType)
            //{
            //    case "0":
            //        checkBox1.Checked = true;
            //        checkBox2.Checked = false;
            //        break;
            //    case "1":
            //        checkBox1.Checked = false;
            //        checkBox2.Checked = true;
            //        break;
            //    case "2":
            //        checkBox1.Checked = true;
            //        checkBox2.Checked = true;
            //        break;
            //    default:
            //        checkBox1.Checked = false;
            //        checkBox2.Checked = false;
            //        break;
            //}
            _theoryWeight = dr["FN_SINGLEWEIGHT"].ToString();
        }
示例#4
0
        //public void ClearWeightFun()
        //{
        //    Thread.Sleep(3000);
        //    m_MainThreadCloseLight = new CloseLight(CloseLight);
        //    Invoke(m_MainThreadCloseLight); //用委托播放声音
        //}
        //private void CloseLight()
        //{
        //    if (_measApp.IoLogik.ReadDO[0])
        //    {
        //        _measApp.IoLogik.DO[0] = false;
        //        _measApp.IoLogik.WriteDO();
        //    }
        //}
        /// <summary>
        /// 手工录入
        /// </summary>
        private void SaveWeightDataByHand()
        {
            try
            {
                //DataRow dr = QueryPlanDataByBatchNo(txtZZBH.Text.Trim());//从预报内存表中查询某一批次的相关信息
                //if (dr == null)
                //{
                //    MessageBox.Show("没有该批次的预报信息!", "提示", MessageBoxButtons.OK);
                //}
                string strMaterialCode = "";

                if (cbWLMC.SelectedIndex > 0)
                {
                    strMaterialCode = cbWLMC.SelectedValue.ToString();
                }

                float p_FN_LENGTH = 0;
                string p_FS_BATCHNO = txtZZBH.Text.Trim();//批次号
                m_szCurBatchNo = p_FS_BATCHNO;

                string p_FS_PRODUCTNO = txtDDH.Text.Trim();//订单号
                if (p_FS_PRODUCTNO.Length == 9)
                {
                    p_FS_PRODUCTNO = "000" + p_FS_PRODUCTNO;
                }
                string p_FS_ITEMNO = txtDDXMH.Text.Trim();//定单项目号
                string p_FS_MATERIALNO = strMaterialCode;//物料代码
                string p_FS_MATERIALNAME = cbWLMC.Text.Trim();//物料名称

                string p_FS_MRP = "";
                if (cbFHDW.SelectedIndex >= 0)
                {
                    p_FS_MRP = cbFHDW.SelectedValue.ToString();//发货单位(车间名称)
                }
                string p_FS_STORE = "";
                if (cbSHDW.SelectedIndex >= 0)
                {
                    p_FS_STORE = cbSHDW.SelectedValue.ToString();//收货单位(库存点)
                }
                string p_FS_STEELTYPE = cbGZ.Text.Trim();//钢种
                string p_FS_SPEC = cbGG.Text.Trim();//规格
                WeightNo = Guid.NewGuid().ToString();//计量作业编号
                string p_FS_WEIGHTNO = WeightNo;
                int p_FN_BANDBILLETCOUNT = 0;//支数
                if (txtZS.Text.Trim().Length > 0)
                {
                    p_FN_BANDBILLETCOUNT = Convert.ToInt32(txtZS.Text.Trim());
                }
                string p_FS_TYPE = cbLXIN.Text.Trim();//类型

                //if (cbDCCD.Text != "0")
                //p_FN_LENGTH = Convert.ToSingle(cbDCCD.Text.Trim());
                if (!float.TryParse(cbDCCD.Text.Trim(), out p_FN_LENGTH))
                {
                    p_FN_LENGTH = 0;
                }

                //if (p_FS_TYPE == "非定尺" || p_FS_TYPE == "非定尺(3-6m)")
                //{
                //    p_FN_LENGTH = 0;
                //    p_FN_BANDBILLETCOUNT = 0;
                //}

                double p_FN_WEIGHT = Convert.ToDouble(string.Format("{0:F3}", Single.Parse(this.tbx_hWeight.Text.Trim())));//重量
                string p_FS_PERSON = m_szCurUser;//计量员
                string p_FS_POINT = _measApp.Params.FS_POINTCODE;//计量点编号
                string p_FS_SHIFT = m_szCurBC;//班次
                string p_FS_TERM = m_szCurBZ;
                //string p_FS_LABELID = "00000000";//条码号
                string p_FS_LABELID = p_FS_BATCHNO;
                string p_FS_FLOW = "";//流向
                if (cbLX.SelectedIndex > 0)
                {
                    p_FS_FLOW = cbLX.SelectedValue.ToString();
                }
                float p_FN_DECWEIGHT = 0;
                if (txtYKL.Text.Trim().Length > 0)
                {
                    p_FN_DECWEIGHT = Convert.ToSingle(string.Format("{0:F3}", Single.Parse(txtYKL.Text.Trim())));//应扣重量
                }

                //判断重量是否超限
                if (_weightStdManage != null)
                {
                    try
                    {
                        _produtionWeightStd = _weightStdManage.GetStandard(p_FS_SPEC, p_FN_LENGTH.ToString());
                        if (_produtionWeightStd != null && (p_FN_WEIGHT * 1000 > _produtionWeightStd.MaxWeight || p_FN_WEIGHT * 1000 < _produtionWeightStd.MinWeight))
                        {
                            messageForm.SetMessage("重量超出范围!");
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }

                CoreClientParam ccp = new CoreClientParam();
                ccp.ServerName = "ygjzjl.bar.StoreageWeight_BC";
                ccp.MethodName = "addBatchNo";
                ccp.ServerParams = new object[] { p_FS_BATCHNO,
                                                p_FS_PRODUCTNO,
                                                p_FS_ITEMNO,
                                                p_FS_MATERIALNO,
                                                p_FS_MRP,
                                                p_FS_STORE,
                                                p_FS_STEELTYPE,
                                                p_FS_SPEC,
                                                p_FS_WEIGHTNO,
                                                p_FN_BANDBILLETCOUNT,
                                                p_FS_TYPE,
                                                p_FN_LENGTH,
                                                p_FN_WEIGHT,
                                                p_FS_PERSON,
                                                p_FS_POINT,
                                                p_FS_SHIFT,
                                                p_FS_TERM,
                                                p_FS_LABELID,
                                                p_FS_MATERIALNAME,
                                                p_FS_FLOW,
                                                p_FN_DECWEIGHT};
                CoreClientParam ret = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
                string reVal = "";
                if (ret.ReturnCode != 0)
                {
                    MessageBox.Show("数据保存失败!");
                    return;
                }
                else
                {
                    reVal = "";
                    if (ccp.ReturnObject != null)
                    {
                        reVal = ccp.ReturnObject.ToString();
                    }
                    //返回为空表示没有下一预报
                    if (reVal == "" || reVal != this.m_szCurBatchNo)
                    {
                        messageForm.SetMessage("批次" + txtZZBH.Text.Trim() + "  已完炉!");
                        this.bCompleteStove = true;
                        ClearControl();
                        QueryWeightDataByBatchNo();
                        //自动跳到下一个预报,而不是第一条
                        for (int iNext = 0; iNext < ultraGrid1.Rows.Count; iNext++)
                        {
                            if (ultraGrid1.Rows[iNext].Cells["FS_BATCHNO"].Text.ToString() == m_szCurBatchNo)
                            {
                                if (iNext + 1 < ultraGrid1.Rows.Count)
                                {
                                    m_szCurBatchNo = ultraGrid1.Rows[iNext+1].Cells["FS_BATCHNO"].Text.ToString();

                                }
                                else
                                {
                                    m_szCurBatchNo = "";
                                }

                                break;
                            }
                        }
                        m_WeightDataTable.Rows.Clear();
                        QueryLastStoveNo();
                    }
                    else
                    {
                        messageForm.SetMessage("保存成功!");
                        QueryWeightDataByBatchNo();
                        bCompleteStove = false;
                    }
                }
                QueryPlanData();

                //存储图片
                this._strBatchNo = p_FS_BATCHNO;
                this._strBandNo = GetMaxBandNoOfBatchNo(_strBatchNo);

                #region 自动播放语音
                if (bCompleteStove)
                {
                    m_AlarmVoicePath = Constant.RunPath + "\\sound\\计量完成 请离开秤台.wav";
                }
                else
                {
                    m_AlarmVoicePath = Constant.RunPath + "\\sound\\ProductComplete.wav";
                }

                if (CustomInfo.Equals("BC01"))    //只有棒材1#秤才播报计量结束
                {
                    if (chkAutoSave.Checked)
                    {
                        m_MainThreadAlarmVoice = new AlarmVoice(AutoAlarmVoice);
                        Invoke(m_MainThreadAlarmVoice); //用委托播放声音
                    }
                    else
                    {
                        AutoAlarmVoice();
                    }
                }

                #endregion

                #region 控制灯
                if (_measApp.IoLogik != null && !_measApp.IoLogik.ReadDO()[0])
                {
                    _measApp.IoLogik.DO[0] = true;
                    _measApp.IoLogik.WriteDO();
                }
                #endregion

                #region 条码打印

                DataRow dRow = QueryTheoryWeightByBatchNo(p_FS_WEIGHTNO);
                if (cbx_print.Checked)
                {
                    if (_measApp.Printer != null)
                    {
                        _measApp.Printer.Data = new HgLable();
                        _measApp.Printer.PrinterName = new PrintDocument().PrinterSettings.PrinterName;
                        _measApp.Printer.Data.BatchNo = p_FS_BATCHNO; //批次号

                        _measApp.Printer.Data.Spec = p_FS_SPEC;//规格
                        //_measApp.Printer.Data.Weight = (int)Math.Round((double.Parse(p_FN_WEIGHT.ToString().Trim()) * 1000));  //重量
                        _measApp.Printer.Data.Date = DateTime.Now;
                        string strTerm = string.Empty;
                        switch (UserInfo.GetUserGroup())
                        {
                            case "1": strTerm = "A"; break;
                            case "2": strTerm = "B"; break;
                            case "3": strTerm = "C"; break;
                            case "4": strTerm = "D"; break;
                            default: strTerm = "A"; break;
                        }

                        _measApp.Printer.Data.Term = strTerm; //班别
                        _measApp.Printer.Data.PrintAddress = true; //地址

                        //查询标准
                        string sql = "select fs_Standard from BT_PRINTCARDSTANDARD t where t.fs_steeltype='" + p_FS_STEELTYPE.ToUpper() + "'";

                        CoreClientParam ccp9 = new CoreClientParam();
                        ccp9.ServerName = "ygjzjl.basedatamanage.OtherBaseInfo";
                        ccp9.MethodName = "ExcuteQuery";
                        ccp9.ServerParams = new object[] { sql };
                        DataTable db = new DataTable();
                        ccp9.SourceDataTable = db;
                        this.ExecuteQueryToDataTable(ccp9, CoreInvokeType.Internal);

                        if (db.Rows.Count > 0)
                        {

                            _measApp.Printer.Data.Standard = db.Rows[0][0].ToString();
                        }

                        else
                        {
                            _measApp.Printer.Data.Standard = "";
                        }

                        _measApp.Printer.Data.SteelType = p_FS_STEELTYPE; //牌号
                        _measApp.Printer.Data.Length = p_FN_LENGTH.ToString();
                        _measApp.Printer.Data.Count = p_FN_BANDBILLETCOUNT.ToString(); //支数
                        if (p_FS_TYPE == "非定尺" || p_FS_TYPE == "非定尺(3-6m)")
                        {
                            _measApp.Printer.Data.Count = "非";
                        }
                        _measApp.Printer.Data.Type = LableType.BIG;

                        string theoryWeight = "0";
                        //根据界面支数和规格 查询单捆重量

                        if (dRow != null)
                        {
                            _measApp.Printer.Data.BandNo = dRow["FN_BANDNO"].ToString();
                            theoryWeight = dRow["FN_THEORYWEIGHT"].ToString();
                        }
                        else
                        {
                            _measApp.Printer.Data.BandNo = "1";
                        }

                        _measApp.Printer.Data.BarCode = GetBarCode(p_FS_LABELID, _measApp.Printer.Data.BandNo); ; //条码号

                        //理重
                        if (checkBox1.Checked)
                        {
                            _measApp.Printer.Data.Weight = (double.Parse(theoryWeight.Trim()) * 1000).ToString();
                            _measApp.Printer.Copies = 2;
                            _measApp.Printer.Print();
                        }
                        if (checkBox2.Checked)
                        {
                            _measApp.Printer.Data.Weight = (p_FN_WEIGHT * 1000).ToString();
                            _measApp.Printer.Copies = 2;
                            _measApp.Printer.Print();
                        }
                    }
                }
                #endregion

                //上传垛帐系统

                string strSql = "select e.fs_material  from dt_productweightmain a,  IT_PRODUCTDETAIL e where  a.FS_PRODUCTNO = e.FS_PRODUCTNO(+) and a.fs_batchno='" + p_FS_BATCHNO + "'";
                CoreClientParam ccp2 = new CoreClientParam();
                ccp2.ServerName = "ygjzjl.basedatamanage.OtherBaseInfo";
                ccp2.MethodName = "ExcuteQuery";
                ccp2.ServerParams = new object[] { strSql };
                DataTable dt_materialno = new DataTable();
                ccp2.SourceDataTable = dt_materialno;
                this.ExecuteQueryToDataTable(ccp2, CoreInvokeType.Internal);

                strMaterialno = dt_materialno.Rows[0][0].ToString();

                DepotObject depotObj = new DepotObject();
                depotObj.BatchNo = p_FS_BATCHNO;
                depotObj.BatchIndex = _strBandNo;
                depotObj.Weight = p_FN_WEIGHT.ToString();
                depotObj.TheoryWeight = dRow["FN_THEORYWEIGHT"].ToString();
                depotObj.Barcode = GetBarCode(p_FS_LABELID, _strBandNo);
                depotObj.Material = strMaterialno;
                _depotManage.UploadDepot(depotObj);
            }
            catch (System.Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }
示例#5
0
        /// <summary>
        /// 保存计量信息
        /// </summary>
        private void SaveWeightData()
        {
            //输入内容验证
            if (CheckInput() == false)
            {
                return;
            }
            int i = m_iSelectedPound;

            try
            {
                double dbContent = 0;
                if (Convert.ToDouble(textMinWeight.Text) < Convert.ToDouble(txtXSZL.Text))
                {

                    dbContent = Convert.ToDouble(textMinWeight.Text) - Convert.ToDouble(txtXSZL.Text);
                    dbContent = dbContent * 1000;

                    if (DialogResult.No == MessageBox.Show("重量低于下限值" + dbContent.ToString() + "公斤,是否继续保存重量?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                    {
                        return;
                    }
                }
            }
            catch
            {

            }

            //复磅
            if (this.cbx_fb.CheckState == CheckState.Checked)
            {
                if (this.tb_zzbh_fb.Text.Trim() == "" || this.tb_bandno_fb.Text.Trim() == "")
                {
                    MessageBox.Show("复磅信息不全!");
                    return;
                }

                if ((IsUpLoadForDetail(tb_zzbh_fb.Text.Trim(), this.tb_bandno_fb.Text.Trim())) == true)
                {
                    MessageBox.Show("该数据已经上传,不允许复磅!");
                    return;
                }

                DoReWeightForBC(this.tb_zzbh_fb.Text.Trim(), this.tb_bandno_fb.Text.Trim(), this.txtXSZL.Text.Trim());
                QueryPlanData();
                #region 自动播放语音
                m_AlarmVoicePath = Constant.RunPath + "\\sound\\ProductComplete.wav";

                AutoAlarmVoice();

                #endregion

                return;
            }

            //手工录入
            if (this.cbx_Hand.CheckState == CheckState.Checked)
            {
                if (CheckIsNumber(this.tbx_hWeight.Text.Trim()))
                {
                    SaveWeightDataByHand();
                }
                else
                {
                    MessageBox.Show("手工录入的重量不是有效的数字!");
                }
                return;
            }

            if (_saved)//是否已经保存
            {
                MessageBox.Show("数据已经保存过了,不允许再次保存!", "提示", MessageBoxButtons.OK);
                return;
            }
            if(txtXSZL.Text == "0.000")
            {
                MessageBox.Show("仪表数据为零,请联系管理员!");
                return;
            }
            try
            {
                //DataRow dr = QueryPlanDataByBatchNo(txtZZBH.Text.Trim());//从预报内存表中查询某一批次的相关信息
                //if (dr == null)
                //{
                //    MessageBox.Show("没有该批次的预报信息!", "提示", MessageBoxButtons.OK);
                //}
                string strMaterialCode = "";

                if (cbWLMC.SelectedIndex > 0)
                {
                    strMaterialCode = cbWLMC.SelectedValue.ToString();
                }

                float p_FN_LENGTH = 0;
                string p_FS_BATCHNO = txtZZBH.Text.Trim();//批次号

                m_szCurBatchNo = p_FS_BATCHNO;

                string p_FS_PRODUCTNO = txtDDH.Text.Trim();//订单号
                if (p_FS_PRODUCTNO.Length == 9)
                {
                    p_FS_PRODUCTNO = "000" + p_FS_PRODUCTNO;
                }
                string p_FS_ITEMNO = txtDDXMH.Text.Trim();//定单项目号
                string p_FS_MATERIALNO = strMaterialCode;//物料代码
                string p_FS_MATERIALNAME = cbWLMC.Text.Trim();//物料名称

                string p_FS_MRP = "";
                if (cbFHDW.SelectedIndex >= 0)
                {
                    p_FS_MRP = cbFHDW.SelectedValue.ToString();//发货单位(车间名称)
                }
                string p_FS_STORE = "";
                if (cbSHDW.SelectedIndex >= 0)
                {
                    p_FS_STORE = cbSHDW.SelectedValue.ToString();//收货单位(库存点)
                }
                string p_FS_STEELTYPE = cbGZ.Text.Trim();//钢种
                string p_FS_SPEC = cbGG.Text.Trim();//规格
                WeightNo = Guid.NewGuid().ToString();//计量作业编号
                string p_FS_WEIGHTNO = WeightNo;
                int p_FN_BANDBILLETCOUNT = 0;//支数
                if (txtZS.Text.Trim().Length > 0)
                {
                    p_FN_BANDBILLETCOUNT = Convert.ToInt32(txtZS.Text.Trim());
                }
                string p_FS_TYPE = cbLXIN.Text.Trim();//类型

                //if (cbDCCD.Text != "0")
                    //p_FN_LENGTH = Convert.ToSingle(cbDCCD.Text.Trim());
                if (!float.TryParse(cbDCCD.Text.Trim(), out p_FN_LENGTH))
                {
                    p_FN_LENGTH = 0;
                }
                    //if (p_FS_TYPE == "非定尺" || p_FS_TYPE == "非定尺(3-6m)")
                    //{
                    //    p_FN_LENGTH = 0;
                    //    p_FN_BANDBILLETCOUNT = 0;
                    //}

                double p_FN_WEIGHT = Convert.ToDouble(string.Format("{0:F3}", Single.Parse(this.txtZL.Text.Trim())));//重量
                string p_FS_PERSON = UserInfo.GetUserName();//计量员
                string p_FS_POINT = _measApp.Params.FS_POINTCODE;//计量点编号
                string p_FS_SHIFT = UserInfo.GetUserOrder();//班次
                string p_FS_TERM = UserInfo.GetUserGroup();//班别
                //string p_FS_LABELID = "00000000";//条码号
                string p_FS_LABELID = p_FS_BATCHNO;
                string strBarCode = GetBarCode(p_FS_BATCHNO,txtZS.Text);
                string p_FS_FLOW = "";//流向
                if (cbLX.SelectedIndex > 0)
                {
                    p_FS_FLOW = cbLX.SelectedValue.ToString();
                }
                float p_FN_DECWEIGHT = 0;
                if (txtYKL.Text.Trim().Length > 0)
                {
                    p_FN_DECWEIGHT = Convert.ToSingle(string.Format("{0:F3}", Single.Parse(txtYKL.Text.Trim())));//应扣重量
                }

                //判断重量是否超限
                if(_weightStdManage != null)
                {
                    try
                    {
                        _produtionWeightStd = _weightStdManage.GetStandard(p_FS_SPEC, p_FN_LENGTH.ToString());
                        if (_produtionWeightStd != null && (p_FN_WEIGHT * 1000 > _produtionWeightStd.MaxWeight || p_FN_WEIGHT * 1000 < _produtionWeightStd.MinWeight))
                        {
                            messageForm.SetMessage("重量超出范围!");
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }

                CoreClientParam ccp = new CoreClientParam();
                ccp.ServerName = "ygjzjl.bar.StoreageWeight_BC";
                ccp.MethodName = "addBatchNo";
                ccp.ServerParams = new object[] { p_FS_BATCHNO,
                                                p_FS_PRODUCTNO,
                                                p_FS_ITEMNO,
                                                p_FS_MATERIALNO,
                                                p_FS_MRP,
                                                p_FS_STORE,
                                                p_FS_STEELTYPE,
                                                p_FS_SPEC,
                                                p_FS_WEIGHTNO,
                                                p_FN_BANDBILLETCOUNT,
                                                p_FS_TYPE,
                                                p_FN_LENGTH,
                                                p_FN_WEIGHT,
                                                p_FS_PERSON,
                                                p_FS_POINT,
                                                p_FS_SHIFT,
                                                p_FS_TERM,
                                                strBarCode,
                                                p_FS_MATERIALNAME,
                                                p_FS_FLOW,
                                                p_FN_DECWEIGHT};
               CoreClientParam ret = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
               string reVal = "";
               if (ret.ReturnCode != 0)
               {
                   MessageBox.Show("数据保存失败!");
                   return;
               }
               else
               {
                   reVal = "";
                   if (ccp.ReturnObject != null)
                   {
                       reVal = ccp.ReturnObject.ToString();
                   }
                   //返回为空表示没有下一预报
                   if (reVal == "" || reVal != this.m_szCurBatchNo)
                   {
                       messageForm.SetMessage("批次" + txtZZBH.Text.Trim() + "  已完炉!");
                       bCompleteStove = true;
                       ClearControl();
                       QueryWeightDataByBatchNo();
                       for (int iNext = 0; iNext < ultraGrid1.Rows.Count; iNext++)
                       {
                           if (ultraGrid1.Rows[iNext].Cells["FS_BATCHNO"].Text.ToString() == m_szCurBatchNo)
                           {
                               if (iNext + 1 < ultraGrid1.Rows.Count)
                               {
                                   m_szCurBatchNo = ultraGrid1.Rows[iNext+1].Cells["FS_BATCHNO"].Text.ToString();
                               }
                               else
                               {
                                   m_szCurBatchNo = "";
                               }

                               break;
                           }
                       }
                       m_WeightDataTable.Rows.Clear();
                       //重新绑定新预报到界面
                       QueryLastStoveNo();
                   }
                   else
                   {
                       messageForm.SetMessage("保存成功!");
                       QueryWeightDataByBatchNo();
                       bCompleteStove = false;
                   }

               }
                //保存成功后保存和完炉按钮不可操作,直到下一吊上称后
                //btnBC.Enabled = false;

                _saved = true;
                QueryPlanData();

                //存储图片
                this._strBatchNo = p_FS_BATCHNO;
                this._strBandNo = GetMaxBandNoOfBatchNo(_strBatchNo);

                GraspAndSaveImage();

                #region RTU控制
                try
                {
                    //if (m_iSelectedPound >= 0 && _measApp.Rtu != null)
                    //{
                    //    _measApp.Rtu.SendRtuCommand((byte)1, (byte)5, (byte)0x50, (byte)(0xDF - 1), (byte)0x00, (byte)0);
                    //    _measApp.Rtu.SendRtuCommand((byte)1, (byte)5, (byte)0x50, (byte)(0xDD - 1), (byte)0xFF, (byte)0);
                    //    _measApp.Rtu.SendRtuCommand((byte)1, (byte)5, (byte)0x50, (byte)(0xE0 - 1), (byte)0x00, (byte)0);
                    //    _measApp.Rtu.SendRtuCommand((byte)1, (byte)5, (byte)0x50, (byte)(0xE0 - 1), (byte)0xFF, (byte)0);
                    //}
                }
                catch (Exception e)
                {
                    WriteLog("SaveWeightData  RTU控制命令发送失败");
                }

                #endregion

                #region 自动播放语音
                if (bCompleteStove) //完炉
                {
                    m_AlarmVoicePath = Constant.RunPath + "\\sound\\计量完成 请离开秤台.wav";
                }
                else
                {
                    m_AlarmVoicePath = Constant.RunPath + "\\sound\\ProductComplete.wav";
                }
                if (CustomInfo.Equals("BC01"))    //只有棒材1#秤才播报计量结束
                {
                    if (chkAutoSave.Checked)
                    {
                        m_MainThreadAlarmVoice = new AlarmVoice(AutoAlarmVoice);
                        Invoke(m_MainThreadAlarmVoice); //用委托播放声音
                    }
                    else
                    {
                        AutoAlarmVoice();
                    }
                }

                #endregion
                #region 条码打印
                DataRow dRow = QueryTheoryWeightByBatchNo(p_FS_WEIGHTNO);
                if (cbx_print.Checked)
                {
                    if (_measApp.Printer != null)
                    {

                        _measApp.Printer.Data = new HgLable();
                        _measApp.Printer.Data.BatchNo = p_FS_BATCHNO; //批次号
                        _measApp.Printer.PrinterName = new PrintDocument().PrinterSettings.PrinterName;
                        _measApp.Printer.Data.Spec = p_FS_SPEC;//规格
                        //_measApp.Printer.Data.Weight = (int)Math.Round((double.Parse(p_FN_WEIGHT.ToString().Trim()) * 1000));  //重量
                        _measApp.Printer.Data.Date = DateTime.Now;
                        string strTerm = string.Empty;
                        switch (UserInfo.GetUserGroup())
                        {
                            case "1": strTerm = "A"; break;
                            case "2": strTerm = "B"; break;
                            case "3": strTerm = "C"; break;
                            case "4": strTerm = "D"; break;
                            default: strTerm = "A"; break;
                        }
                        _measApp.Printer.Data.Term = strTerm; //班别

                        _measApp.Printer.Data.PrintAddress = true; //地址

                        string sql = "select fs_Standard from BT_PRINTCARDSTANDARD t where t.fs_steeltype='" + p_FS_STEELTYPE.ToUpper() + "'";

                        CoreClientParam ccp9 = new CoreClientParam();
                        ccp9.ServerName = "ygjzjl.basedatamanage.OtherBaseInfo";
                        ccp9.MethodName = "ExcuteQuery";
                        ccp9.ServerParams = new object[] { sql };
                        DataTable db = new DataTable();
                        ccp9.SourceDataTable = db;
                        this.ExecuteQueryToDataTable(ccp9, CoreInvokeType.Internal);

                        if (db.Rows.Count > 0)
                        {

                            _measApp.Printer.Data.Standard = db.Rows[0][0].ToString();
                        }

                        else
                        {
                            _measApp.Printer.Data.Standard = "";
                        }

                        //if (p_FS_STEELTYPE.ToUpper() == "22MNB")
                        //{
                        //    _measApp.Printer.Data.Standard = "KGB.4 3001";
                        //}
                        //else if (p_FS_STEELTYPE.ToUpper() == "18B")
                        //{
                        //    _measApp.Printer.Data.Standard = "KGB.3 3001";
                        //}
                        //else
                        //{
                        //    _measApp.Printer.Data.Standard = ""; //标准
                        //}
                        _measApp.Printer.Data.SteelType = p_FS_STEELTYPE; //牌号
                        _measApp.Printer.Data.Length = p_FN_LENGTH.ToString();
                        _measApp.Printer.Data.Count = p_FN_BANDBILLETCOUNT.ToString(); //支数
                        if (p_FS_TYPE == "非定尺" || p_FS_TYPE == "非定尺(3-6m)")
                        {
                            _measApp.Printer.Data.Count = "非";
                        }
                        _measApp.Printer.Data.Type = LableType.BIG;

                        string theoryWeight = "0";
                        //根据界面支数和规格 查询单捆重量

                        if (dRow != null)
                        {
                            _measApp.Printer.Data.BandNo = dRow["FN_BANDNO"].ToString();
                            theoryWeight = dRow["FN_THEORYWEIGHT"].ToString();
                        }
                        else
                        {
                            _measApp.Printer.Data.BandNo = "1";
                        }

                        _measApp.Printer.Data.BarCode = GetBarCode(p_FS_LABELID, _measApp.Printer.Data.BandNo); //条码号

                        //理重
                        if (checkBox1.Checked)
                        {
                            _measApp.Printer.Data.Weight = (double.Parse(theoryWeight.Trim()) * 1000).ToString();
                            _measApp.Printer.Copies = 2;
                            _measApp.Printer.Print();

                        }
                        if (checkBox2.Checked)
                        {
                            _measApp.Printer.Data.Weight = (p_FN_WEIGHT * 1000).ToString();
                            _measApp.Printer.Copies = 2;
                            _measApp.Printer.Print();
                        }
                    }
                }

                //上传垛帐系统

                string strSql = "select e.fs_material  from dt_productweightmain a,  IT_PRODUCTDETAIL e where  a.FS_PRODUCTNO = e.FS_PRODUCTNO(+) and a.fs_batchno='" + p_FS_BATCHNO + "'";
                CoreClientParam ccp2 = new CoreClientParam();
                ccp2.ServerName = "ygjzjl.basedatamanage.OtherBaseInfo";
                ccp2.MethodName = "ExcuteQuery";
                ccp2.ServerParams = new object[] { strSql };
                DataTable dt_materialno = new DataTable();
                ccp2.SourceDataTable = dt_materialno;
                this.ExecuteQueryToDataTable(ccp2, CoreInvokeType.Internal);

                strMaterialno = dt_materialno.Rows[0][0].ToString();

                DepotObject depotObj = new DepotObject();
                depotObj.BatchNo = p_FS_BATCHNO;
                depotObj.BatchIndex = _strBandNo;
                depotObj.Weight = p_FN_WEIGHT.ToString();
                depotObj.TheoryWeight = dRow["FN_THEORYWEIGHT"].ToString();
                depotObj.Barcode = GetBarCode(p_FS_LABELID, _strBandNo);
                depotObj.Material = strMaterialno;
                _depotManage.UploadDepot(depotObj);
                #endregion
                #region 自动下载新的订单信息
                if (this.txtDDH.Text.Trim() != p_FS_PRODUCTNO)
                {
                    //messageForm.SetMessage("已使用新的订单号,系统将自动下载新的订单信息!");
                    //Thread.Sleep(2000);
                    //GetOrderInfo(this.txtDDH.Text.Trim());
                }
                #endregion

            }
            catch (System.Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }