//private void GetBFChemcialData() //{ // dsChemical.L3DataAdapter = Adapter; // dsChemical.LoadData(); // if (dsChemical.Tables[0].Rows.Count > 0) // { // ptbC.Text = dsChemical.Tables[0].Rows[0]["C"].ToString(); // ptbSi.Text = dsChemical.Tables[0].Rows[0]["Si"].ToString(); // ptbMn.Text = dsChemical.Tables[0].Rows[0]["Mn"].ToString(); // ptbP.Text = dsChemical.Tables[0].Rows[0]["P"].ToString(); // ptbS.Text = dsChemical.Tables[0].Rows[0]["S"].ToString(); // ptbTi.Text = dsChemical.Tables[0].Rows[0]["Ti"].ToString(); // } //} private void ptbWT_Leave(object sender, EventArgs e) { if (sender.GetType().Name != "PxTextBox") { return; } PxDataValid.PxTextBox ptbtxt = (PxDataValid.PxTextBox)sender; try { float fTare = 0; if (ptbTare.Text.Length > 0) { fTare = float.Parse(ptbTare.Text); } float fCross = 0; if (ptbCross.Text.Length > 0) { fCross = float.Parse(ptbCross.Text); } ; if (sender.Equals(ptbCross) && fCross < 47) { MessageBox.Show("毛重至少大于47吨", "提示"); return; } float ftemp = fCross - fTare; ptbNet.Text = string.Format("{0:F}", ftemp); } catch { ptbtxt.Text = "0"; ptbNet.Text = "0"; } }
//计算重量20081227Liao private void CalculateWegint(object sender, EventArgs e) { try { PxDataValid.PxTextBox ctrl = (PxDataValid.PxTextBox)sender; string strctrlText = ctrl.Text; switch (ctrl.Name) { case "tbxWasterCount1": //tbxWasterWeight1.Text =( string.Format("{0:F}", fWTPerMM * (strctrlText.Length < 1 ? 0 : Convert.ToInt32(strctrlText))); tbxWasterWeight1.Text = Convert.ToString(Math.Round(fWTPerMM * (strctrlText.Length < 1 ? 0 : Convert.ToDouble(strctrlText)), 3)); break; case "tbxWasterCount2": //tbxWasterWeight2.Text = string.Format("{0:F}", fWTPerMM * (strctrlText.Length < 1 ? 0 : Convert.ToInt32(strctrlText))); tbxWasterWeight2.Text = Convert.ToString(Math.Round(fWTPerMM * (strctrlText.Length < 1 ? 0 : Convert.ToDouble(strctrlText)), 3)); break; case "tbxWasterCount3": //tbxWasterWeight3.Text = string.Format("{0:F}", fWTPerMM * (strctrlText.Length < 1 ? 0 : Convert.ToInt32(strctrlText))); tbxWasterWeight3.Text = Convert.ToString(Math.Round(fWTPerMM * (strctrlText.Length < 1 ? 0 : Convert.ToDouble(strctrlText)), 3)); break; default: break; } string strCnt1 = tbxWasterCount1.Text; strCnt1.Trim(); string strCnt2 = tbxWasterCount2.Text; strCnt2.Trim(); string strCnt3 = tbxWasterCount3.Text; strCnt3.Trim(); //总甩废长度 double WasterCount = (strCnt1.Length < 1 ? 0 : Convert.ToDouble(strCnt1)) + (strCnt2.Length < 1 ? 0 : Convert.ToDouble(strCnt2)) + (strCnt3.Length < 1 ? 0 : Convert.ToDouble(strCnt3)); tbxWasterCount.Text = WasterCount.ToString(); //总甩废重量 string strWWT1 = tbxWasterWeight1.Text; strWWT1.Trim(); string strWWT2 = tbxWasterWeight2.Text; strWWT2.Trim(); string strWWT3 = tbxWasterWeight3.Text; strWWT3.Trim(); double dWasterWT = (strWWT1.Length < 1 ? 0 : Convert.ToDouble(strWWT1)) + (strWWT2.Length < 1 ? 0 : Convert.ToDouble(strWWT2)) + (strWWT3.Length < 1 ? 0 : Convert.ToDouble(strWWT3)); tbxWasterWeight.Text = dWasterWT.ToString(); ////总甩废重量 = 总甩废长度 * 单位重量 //double dWasterWeight = WasterCount * fWTPerMM; //tbxWasterWeight.Text = string.Format("{0:F}", dWasterWeight); //理论重量 double dBloomWeight = (tbxBloomWeight.Text.Length < 1 ? 0 : Convert.ToDouble(tbxBloomWeight.Text.Trim())); //合格重量 = 理论重量 + 甩废总重量 //tbxRightWeight.Text = string.Format("{0:F}", dBloomWeight + dWasterWeight); tbxRightWeight.Text = Convert.ToString(Math.Round((dBloomWeight + dWasterWT), 3)); } catch { } }
//计算重量20081231Liao private void CalculateWeightNew(object sender, EventArgs e) { /*1非试轧:试轧支数 == 0,试轧重量 == 0;合格支数 + 不合格总支数 = 钢坯总支数; * 2试轧: 合格支数 == 0,合格重量 == 0;试轧指数 + 不合格总支数 = 钢坯总支数;*/ try { // bsFinalJudge.EndEdit(); PxDataValid.PxTextBox ctrl = (PxDataValid.PxTextBox)sender; string strctrlText = ctrl.Text; switch (ctrl.Name) { case "tbxWrongCount1": tbxWrongWeight1.Text = Convert.ToString(Math.Round(fweight * (strctrlText.Length < 1 ? 0 : Convert.ToInt32(strctrlText)), 3)); //string.Format("{0:F}", fweight * (strctrlText.Length < 1 ? 0 : Convert.ToInt32(strctrlText))); break; case "tbxWrongCount2": tbxWrongWeight2.Text = Convert.ToString(Math.Round(fweight * (strctrlText.Length < 1 ? 0 : Convert.ToInt32(strctrlText)), 3)); // string.Format("{0:F}", fweight * (strctrlText.Length < 1 ? 0 : Convert.ToInt32(strctrlText))); break; case "tbxWrongCount3": tbxWrongWeight3.Text = Convert.ToString(Math.Round(fweight * (strctrlText.Length < 1 ? 0 : Convert.ToInt32(strctrlText)), 3)); // string.Format("{0:F}", fweight * (strctrlText.Length < 1 ? 0 : Convert.ToInt32(strctrlText))); break; default: break; } string strCnt1 = tbxWrongCount1.Text; strCnt1.Trim(); string strCnt2 = tbxWrongCount2.Text; strCnt2.Trim(); string strCnt3 = tbxWrongCount3.Text; strCnt3.Trim(); //计算不合格总支数 int iWrongCount = (strCnt1.Length < 1 ? 0 : Convert.ToInt32(strCnt1)) + (strCnt2.Length < 1 ? 0 : Convert.ToInt32(strCnt2)) + (strCnt3.Length < 1 ? 0 : Convert.ToInt32(strCnt3)); //不合格总支数 tbxWrongCount.Text = iWrongCount.ToString(); //不合格总总量 double WrongWeight = iWrongCount * fweight; tbxWrongWeight.Text = Convert.ToString(Math.Round(WrongWeight, 3));//string.Format("{0:F}", WrongWeight); //钢坯总支数 string strBloomCount = tbxBloomCount.Text; strBloomCount.Trim(); int iBloomCount = strBloomCount.Length < 1 ? 0 : Convert.ToInt32(strBloomCount); //非试轧 if (!(ckbProcessType.Checked)) { //合格支数 = 钢坯支数 - 不合格总支数 int iRightCount = iBloomCount - iWrongCount; tbxRightCount.Text = iRightCount.ToString(); //合格重量 = 表判钢坯合格重量 - 不合格重量【2009-03-02Liao】 double dRightWeight = fBloomWeight - WrongWeight; //iRightCount * fweight; tbxRightWeight.Text = Convert.ToString(Math.Round(dRightWeight, 3)); //string.Format("{0:F}", dRightWeight); return; } else { //试轧支数 = 钢坯支数 - 不合格总支数 int iTestCount = iBloomCount - iWrongCount; txtTestCount.Text = iTestCount.ToString(); //试轧重量 double dTestWeight = iTestCount * fweight; txtTestWeight.Text = Convert.ToString(Math.Round(dTestWeight, 3));; //string.Format("{0:F}", dTestWeight); return; } } catch { } }