using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CoreFS.CA03;
using CoreFS.CA04;
using CoreFS.CA06;
using System.Collections;
using Infragistics.Win.UltraWinGrid;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Tool;
namespace Core.StlMes.Client.SaleOrder
{
public partial class frmOrderLen : FrmBase
{
public frmOrderLen()
{
InitializeComponent();
}
public frmOrderLen(OpeBase ob)
{
InitializeComponent();
this.ob = ob;
}
private string lenNo; //长度编码
public string LenNo
{
get { return lenNo; }
set { lenNo = value; }
}
DataTable dataTable2 = null;
private void frmOrderLen_Load(object sender, EventArgs e)
{
doQuery();
DataTable unLoad = new DataTable();
unLoad.Columns.Add("Name", typeof(System.String));
unLoad.Rows.Add("短尺随炉");
unLoad.Rows.Add("/");
cmbShrtStove.DataSource = unLoad;
ClsBaseInfo.SetComboItemHeight(cmbShrtStove);
}
///
/// 重写基类load事件,屏蔽平台过滤功能。
///
///
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
ultraGrid2.DisplayLayout.Override.FilterUIType = Infragistics.Win.UltraWinGrid.FilterUIType.FilterRow;
ultraGrid2.DisplayLayout.Override.FilterOperatorDefaultValue = Infragistics.Win.UltraWinGrid.FilterOperatorDefaultValue.Contains;
//ultraGrid2.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect;
}
///
/// 复制
///
///
///
private void CopyRowToRow(DataRow srcRow, DataRow desRow)
{
for (int i = 0; i < srcRow.Table.Columns.Count; i++)
{
string columnName = srcRow.Table.Columns[i].ColumnName;
desRow[columnName] = srcRow[columnName];
}
}
///
/// 查询功能
///
private void doQuery()
{
DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderLen.doQuery", new object[] { this.lenNo }, this.ob);
// DataTable dt1 = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderLen.doQuery1", null, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
//dataTable2 = dataTable1.Clone();
// GridHelper.CopyDataToDatatable(ref dt1, ref this.dataTable2, true);
//最近操作的3条记录颜色变换。
//获取最近操作的3条自选记录长度编号。
GetLenNoByLenTyp();
//列自适应
GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, new UltraGridColumn[] { });
foreach (UltraGridRow row in ultraGrid2.Rows)
{
if (row.Cells["LEN_NO"].Value.ToString() == this.lenNo)
{
row.Activate();
break;
}
}
}
///
/// 获取自选最近操作的3条记录,改变其背景色。
///
private void GetLenNoByLenTyp()
{
DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderLen.GetLenNoByLenTyp", null, this.ob);
for (int i = 0; i < dt.Rows.Count; i++)
{
string lenNo = dt.Rows[i]["len_no"].ToString();
for (int j = 0; j < ultraGrid2.Rows.Count; j++)
{
if (ultraGrid2.Rows[j].Cells["len_no"].Value.ToString().Equals(lenNo))
{
ultraGrid2.Rows[j].Appearance.ForeColor = Color.Green;
}
}
}
}
///
/// 委托方法
///
///
public delegate void GetOrderLenHander(DataRow ROrdLen);
public event GetOrderLenHander GetOrderLen;
///
/// Toolbar方法。
///
///
///
private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
if ("doAdd".Equals(e.Tool.Key))
{
if (e.Tool.Index == -1)
{
return;
}
//提交
doAdd();
}
else if ("doUpdate".Equals(e.Tool.Key))
{
if (e.Tool.Index == -1)
{
return;
}
string lenNo = ultraGrid2.ActiveRow.Cells["len_no"].Value.ToString();
doUpdate(lenNo);
}
//else if("doDelete".Equals(e.Tool.Key))
//{
// doDelete();
//}
else
{
this.Close();
}
}
///
/// 删除功能
///
//private void doDelete()
//{
// if (ultraGrid2.ActiveRow == null)
// {
// MessageBox.Show("请选择需要删除的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
// }
// //防止加错,提供自选删除功能。
// string lenType = ultraGrid2.ActiveRow.Cells["len_typ"].Value.ToString();
// if (!"自选".Equals(lenType))
// {
// MessageBox.Show("长度分类为固定选择,不允许删除。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
// }
// else
// {
// ArrayList param = new ArrayList();
// string lenNo = ultraGrid2.ActiveRow.Cells["len_no"].Value.ToString();
// param.Add(lenNo);
// if (param.Count > 0 && MessageBox.Show("是否确认删除选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
// {
// try
// {
// int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreOrderLen.doDelete", new Object[] { param }, this.ob);
// if (count > 0)
// {
// doQuery();
// }
// }
// catch (Exception ex)
// {
// MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// }
// }
// }
//}
///
/// 确认,返回当前选中行给主界面,同时该长度使用次数+1
///
public void doUpdate(string lenNo, DataRow dr)
{
//使用次数与创建时间更新。
ArrayList parm = new ArrayList();
parm.Add(lenNo);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.sale.order.CoreOrderLen";
ccp.MethodName = "doUpdate";
ccp.ServerParams = new object[] { parm };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1) return;
//DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderLen.doQuery1", new object[] { lenNo }, this.ob);
GetOrderLen(dr);
this.Close();
return;
//foreach (DataRow row in this.dataTable1.Rows)
//{
// if (lenNo.Equals(row["len_no"].ToString()))
// {
// GetOrderLen(row);
// this.Close();
// return;
// }
//}
}
public void doUpdate(string lenNo)
{
//使用次数与创建时间更新。
ArrayList parm = new ArrayList();
parm.Add(lenNo);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.sale.order.CoreOrderLen";
ccp.MethodName = "doUpdate";
ccp.ServerParams = new object[] { parm };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1) return;
DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderLen.doQuery1", new object[] { lenNo }, this.ob);
GetOrderLen(dt.Rows[0]);
this.Close();
return;
}
///
/// 验证非空字段。
///
///
private bool ValidInput()
{
if (cmbLenUnit.Value == null || cmbLenUnit.Value == System.DBNull.Value)
{
this.cmbLenUnit.Focus();
this.cmbLenUnit.SelectAll();
MessageBox.Show("请选择长度单位!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
if (txtLenMin.Value == null || txtLenMin.Value == System.DBNull.Value)
{
MessageBox.Show("长度下限不允许为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtLenMin.Focus();
this.txtLenMin.SelectAll();
return false;
}
if (txtLenMax.Value == null || txtLenMax.Value == System.DBNull.Value)
{
MessageBox.Show("长度上限不允许为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtLenMax.Focus();
this.txtLenMax.SelectAll();
return false;
}
if (Convert.ToDouble(txtLenMin.Text) > Convert.ToDouble(txtLenMax.Text))
{
this.txtLenMin.Focus();
this.txtLenMin.SelectAll();
MessageBox.Show("长度下限不能大于长度上限!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
return true;
}
///
/// 提交
///
public void doAdd()
{
DataRow dRow = dataTable1.NewRow();
//长度下限、上限、单位为必填值;
if (ValidInput())
{
//长度单位
string lenUnit = cmbLenUnit.Value.ToString();
//长度下限
string lenMin = txtLenMin.Value.ToString();
//长度上限
string lenMax = txtLenMax.Value.ToString();
//长度描述
string lenDesc = lenMin + "-" + lenMax + lenUnit;
//短尺率
string shrtLenRato = "";
if (txtShrtLenRato.Value == System.DBNull.Value || txtShrtLenRato.Value == null)
{
MessageUtil.ShowWarning("短尺率不能为空,请输入短尺率!");
return;
}
if (txtShrtLenRato.Value != System.DBNull.Value && txtShrtLenRato.Value != null)
{
shrtLenRato = txtShrtLenRato.Value.ToString();
if (!string.IsNullOrEmpty(shrtLenRato))
{
lenDesc += ",短尺率" + txtShrtLenRato.Value.ToString() + "%";
}
if (txtShortest.Text.Trim() == "" && Convert.ToDouble(txtShrtLenRato.Value) != 0)
{
MessageUtil.ShowWarning("短尺率存在,请输入短尺最短!");
return;
}
}
//短尺最短
string shortest = "";
if (txtShortest.Value != System.DBNull.Value && txtShortest.Value != null && Convert.ToDouble(txtShortest.Value) != 0)
{
shortest = txtShortest.Value.ToString();
if (!string.IsNullOrEmpty(shortest))
{
lenDesc += ",短尺最短" + txtShortest.Value.ToString() + lenUnit;
}
if (txtShrtLenRato.Text.Trim() == "")
{
MessageUtil.ShowWarning("短尺最短存在,请输入短尺率!");
return;
}
if (Convert.ToDouble(shortest) > Convert.ToDouble(txtLenMin.Text))
{
MessageUtil.ShowWarning("短尺最短不能超过长度下限");
return;
}
}
//短尺随炉
string shrtStove = "";
if (cmbShrtStove.Value != null)
{
shrtStove = cmbShrtStove.Value.ToString().Trim();
if (!string.IsNullOrEmpty(shrtStove))
{
if (shrtStove.Equals("短尺随炉"))
{
if ((txtShrtLenRato.Value != System.DBNull.Value && txtShrtLenRato.Value != null && Convert.ToDouble(txtShrtLenRato.Value) != 0) ||
(ultraNumericEditor1.Value != System.DBNull.Value && ultraNumericEditor1.Value != null && Convert.ToDouble(ultraNumericEditor1.Value) != 0) ||
(txtSiglLen.Value != System.DBNull.Value && txtSiglLen.Value != null && Convert.ToDouble(txtSiglLen.Value) != 0) ||
(txtShortest.Value != System.DBNull.Value && txtShortest.Value != null && Convert.ToDouble(txtShortest.Value) != 0) ||
(txtDifrncLenMax.Value != System.DBNull.Value && txtDifrncLenMax.Value != null && Convert.ToDouble(txtDifrncLenMax.Value) != 0) ||
(txtLongLenRato.Value != System.DBNull.Value && txtLongLenRato.Value != null && Convert.ToDouble(txtLongLenRato.Value) != 0) ||
(txtLongest.Value != System.DBNull.Value && txtLongest.Value != null && Convert.ToDouble(txtLongest.Value) != 0) ||
(txtAvgLenMin.Value != System.DBNull.Value && txtAvgLenMin.Value != null && Convert.ToDouble(txtAvgLenMin.Value) != 0)
)
{
MessageUtil.ShowWarning("您选择了'短尺随炉',除长度上下限数值外一律不能录入(短尺随炉具有排他性)!");
txtShrtLenRato.Focus();
txtShrtLenRato.SelectAll();
return;
}
}
lenDesc += "," + cmbShrtStove.Value.ToString();
}
}
//长尺率
string longLenRato = "";
if (txtLongLenRato.Value == System.DBNull.Value || txtLongLenRato.Value == null)
{
MessageUtil.ShowWarning("长尺率不能为空,请输入长尺率!");
return;
}
if (txtLongLenRato.Value != System.DBNull.Value && txtLongLenRato.Value != null)
{
longLenRato = txtLongLenRato.Value.ToString();
if (!string.IsNullOrEmpty(longLenRato))
{
lenDesc += ",长尺率" + txtLongLenRato.Value.ToString() + "%";
}
if (txtLongest.Text.Trim() == "" && Convert.ToDouble(txtLongLenRato.Value) != 0)
{
MessageUtil.ShowWarning("长尺率存在,请输入长尺最长!");
return;
}
}
//长尺最长
string longest = "";
if (txtLongest.Value != System.DBNull.Value && txtLongest.Value != null && Convert.ToDouble(txtLongest.Value) != 0)
{
longest = txtLongest.Value.ToString();
if (!string.IsNullOrEmpty(longest))
{
lenDesc += ",长尺最长" + txtLongest.Value.ToString() + lenUnit;
}
if (txtLongLenRato.Text.Trim() == "")
{
MessageUtil.ShowWarning("长尺最长存在,请输入长尺率!");
return;
}
if (Convert.ToDouble(longest) < Convert.ToDouble(txtLenMax.Text))
{
MessageUtil.ShowWarning("长尺最长不能小于长度上限");
return;
}
}
//if (txtShrtLenRato.Value != System.DBNull.Value && txtShrtLenRato.Value != null && Convert.ToDouble(txtShrtLenRato.Value) != 0
// && txtLongLenRato.Value != System.DBNull.Value && txtLongLenRato.Value != null && Convert.ToDouble(txtLongLenRato.Value) != 0
// )
//{
// MessageUtil.ShowWarning("短尺率与长尺率不能同时存在!");
// this.txtShrtLenRato.Focus();
// this.txtShrtLenRato.SelectAll();
// return;
//}
//单倍尺长
string siglLen = "";
if (txtSiglLen.Value != System.DBNull.Value && txtSiglLen.Value != null && Convert.ToDouble(txtSiglLen.Value) != 0)
{
siglLen = txtSiglLen.Value.ToString();
if (txtDifrncLenMax.Value == null || txtDifrncLenMax.Value == System.DBNull.Value) //成品公差
{
MessageBox.Show("请输入成品公差!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
//if (!StringUtil.IsInt(siglLen))
//{
// MessageUtil.ShowWarning("单倍尺长必须是整数!");
// return;
//}
//一般判断整数的正则表示无法判断 11.0 11.0000这样的字符
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"^[1-9]\d*[.]{0,1}[0]*$");
if (!string.IsNullOrEmpty(siglLen))
{
//长度下限
if (!txtLenMin.Text.Equals(""))
{
string remain = (Convert.ToDecimal(txtLenMin.Text) / Convert.ToDecimal(siglLen)).ToString();
if (!reg.IsMatch(remain))
{
MessageBox.Show("长度要求中,长度下限/单倍尺长必须是整数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
if (!txtLenMax.Text.Equals(""))
{
string remain = ((Convert.ToDecimal(txtLenMax.Text) - Convert.ToDecimal(txtDifrncLenMax.Text)) / Convert.ToDecimal(siglLen)).ToString();
if (!reg.IsMatch(remain))
{
MessageUtil.ShowWarning("(长度上限-成品公差)应该是单倍尺长的整数倍!");
return;
}
}
//(长度上限-成品公差-下限值)>0
lenDesc += ",单倍尺长" + txtSiglLen.Value.ToString() + lenUnit;
}
}
//平均长度大于
string avgLenMin = "";
if (txtAvgLenMin.Value != System.DBNull.Value && txtAvgLenMin.Value != null && Convert.ToDouble(txtAvgLenMin.Value) != 0)
{
avgLenMin = txtAvgLenMin.Value.ToString();
if (!string.IsNullOrEmpty(avgLenMin))
{
double a = 0;
double b = 0;
if (txtLenMin.Text.Equals(""))
{
a = 0;
}
else
{
a = Convert.ToDouble(txtLenMin.Text);
}
if (txtLenMax.Text.Equals(""))
{
b = 0;
}
else
{
b = Convert.ToDouble(txtLenMax.Text);
}
double c = Convert.ToDouble(txtAvgLenMin.Value.ToString());
if (c < a || c > b)
{
MessageUtil.ShowWarning("'平均长度大于'应该在长度下限和长度上限之间!");
txtAvgLenMin.Focus();
return;
}
lenDesc += ",平均长度大于" + txtAvgLenMin.Value.ToString() + lenUnit;
}
}
//平均长度小于
string avgLenMax = "";
if (txtAvgLenMax.Value != System.DBNull.Value && txtAvgLenMax.Value != null && Convert.ToDouble(txtAvgLenMax.Value) != 0)
{
avgLenMax = txtAvgLenMax.Value.ToString();
if (!string.IsNullOrEmpty(avgLenMax))
{
double a = 0;
double b = 0;
if (txtLenMin.Text.Equals(""))
{
a = 0;
}
else
{
a = Convert.ToDouble(txtLenMin.Text);
}
if (txtLenMax.Text.Equals(""))
{
b = 0;
}
else
{
b = Convert.ToDouble(txtLenMax.Text);
}
double c = Convert.ToDouble(txtAvgLenMax.Value.ToString());
if (c < a || c > b)
{
MessageUtil.ShowWarning("'平均长度小于'应该在长度下限和长度上限之间!");
txtAvgLenMax.Focus();
return;
}
lenDesc += ",平均长度小于" + txtAvgLenMax.Value.ToString() + lenUnit;
}
}
//成品公差
string difrncLenMax = "";
if (txtDifrncLenMax.Value != System.DBNull.Value && txtDifrncLenMax.Value != null && Convert.ToDouble(txtDifrncLenMax.Value) != 0)
{
difrncLenMax = txtDifrncLenMax.Value.ToString();
if (!string.IsNullOrEmpty(difrncLenMax))
{
lenDesc += ",成品公差" + txtDifrncLenMax.Value.ToString() + lenUnit;
}
}
//最长最短差小于
string maxmin = "";
if (ultraNumericEditor1.Value != System.DBNull.Value && ultraNumericEditor1.Value != null && Convert.ToDouble(ultraNumericEditor1.Value) != 0)
{
maxmin = ultraNumericEditor1.Value.ToString();
if (!string.IsNullOrEmpty(maxmin))
{
lenDesc += ",最长最短差小于" + maxmin + lenUnit;
}
}
dRow["LEN_DESC"] = lenDesc;
dRow["LEN_TYP"] = "自选";
dRow["LEN_UNIT"] = lenUnit;
dRow["LEN_MIN"] = lenMin;
dRow["LEN_MAX"] = lenMax;
dRow["SHRT_LEN_RATO"] = shrtLenRato;
dRow["SHORTEST"] = shortest;
dRow["LONG_LEN_RATO"] = longLenRato;
dRow["LONGEST"] = longest;
dRow["SHRT_STOVE"] = shrtStove;
dRow["AVG_LEN_MIN"] = avgLenMin;
dRow["AVG_LEN_MAX"] = avgLenMax;
dRow["DIFRNC_LEN_MAX"] = maxmin;
dRow["SIGL_LEN"] = siglLen;
dRow["ENDLEN_SPECSTD"] = difrncLenMax;
//获取长度描述所对应的编号。
string lenNo = isRepeat(lenDesc);
if (!string.IsNullOrEmpty(lenNo))
{
dRow["LEN_NO"] = lenNo;
//不为空,存在则执行确认操作。
//不为空,创建时间与使用次数更新,返回该行记录给主界面。
doUpdate(lenNo, dRow);
}
else
{
//为空
if (siglLen != "")
{
//lenMin
//string sum = Convert.ToString(Convert.ToDouble(lenMin) / Convert.ToDouble(siglLen));
//System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"^[0-9]\d*$");
//if (!reg.IsMatch(sum))
//{
// MessageBox.Show("长度要求中,长度下限/单倍尺长必须是整数!" + sum, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
//}
}
//自动生成编号。
string autoLenNo = GetLenNo();
//将该行记录插入数据库。
ArrayList parm = new ArrayList();
//长度编号
parm.Add(autoLenNo);
//长度描述
parm.Add(lenDesc);
//长度分类
parm.Add("自选");
//长度单位
parm.Add(lenUnit);
//长度下限
parm.Add(lenMin);
//长度上限
parm.Add(lenMax);
//短尺率
parm.Add(shrtLenRato);
//短尺最短
parm.Add(shortest);
//短尺随炉
parm.Add(shrtStove);
//长尺率
parm.Add(longLenRato);
//长尺最长
parm.Add(longest);
//单倍尺长
parm.Add(siglLen);
//平均长度大于
parm.Add(avgLenMin);
//平均长度小于
parm.Add(avgLenMax);
//成品公差
parm.Add(difrncLenMax);
//最长最短差小于
parm.Add(maxmin);
//创建人
parm.Add(UserInfo.GetUserID());
//创建时间
//使用次数
parm.Add(1);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.sale.order.CoreOrderLen";
ccp.MethodName = "doAdd";
ccp.ServerParams = new object[] { parm };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1) return;
dRow["LEN_NO"] = autoLenNo;
doQuery();
//DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderLen.doQuery1", new object[] { autoLenNo }, this.ob);
GetOrderLen(dRow);
this.Close();
return;
////找到该行记录并返回给主窗体。
//foreach (DataRow row in this.dataTable1.Rows)
//{
// if (autoLenNo.Equals(row["len_no"].ToString()))
// {
// GetOrderLen(row);
// this.Close();
// return;
// }
//}
}
}
}
///
/// 自动生成编号。
///
///
private string GetLenNo()
{
//获取最大编号加一L0000010,L+7位流水号,不足7位,补0
DataTable dt = new DataTable();
dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderLen.GetLenNo", null, this.ob);
string lenNo = "";
if (dt.Rows.Count > 0)
{
lenNo = dt.Rows[0][0].ToString();
}
while (lenNo.Length < 7)
{
lenNo = "0" + lenNo;
}
return "L" + lenNo;
}
///
/// 判断长度描述是否已存在
///
///
///
private string isRepeat(string lenDesc)
{
//获取已存在长度描述信息对应的编号。
DataTable dt = new DataTable();
dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderLen.isRepeat", new Object[] { lenDesc }, this.ob);
if (dt.Rows.Count > 0)
{
return dt.Rows[0][0].ToString();
}
else
{
return "";
}
}
///
/// 编辑区赋值。
///
///
///
private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
{
//cmbLenUnit,txtLenMin,txtLenMax,txtShrtLenRato,
//txtShortest,cmbShrtStove,txtLongLenRato, txtLongest,
//txtSiglLen,txtAvgLenMin,txtDifrncLenMax
//len_unit,len_min,len_max,shrt_len_rato,
//shortest,shrt_stove,long_len_rato,longest,
//sigl_len,avg_len_min,difrnc_len_max
if (ultraGrid2.ActiveRow == null)
return;
try
{
cmbLenUnit.Value = ultraGrid2.ActiveRow.Cells["len_unit"].Value.ToString();
txtLenMin.Value = ultraGrid2.ActiveRow.Cells["len_min"].Text.ToString();
txtLenMax.Value = ultraGrid2.ActiveRow.Cells["len_max"].Text.ToString();
txtShrtLenRato.Value = ultraGrid2.ActiveRow.Cells["shrt_len_rato"].Text.ToString();
txtShortest.Value = ultraGrid2.ActiveRow.Cells["shortest"].Text.ToString();
cmbShrtStove.Value = ultraGrid2.ActiveRow.Cells["shrt_stove"].Value.ToString();
txtLongLenRato.Value = ultraGrid2.ActiveRow.Cells["long_len_rato"].Text.ToString();
txtLongest.Value = ultraGrid2.ActiveRow.Cells["longest"].Text.ToString();
txtSiglLen.Value = ultraGrid2.ActiveRow.Cells["sigl_len"].Text.ToString();
txtAvgLenMin.Value = ultraGrid2.ActiveRow.Cells["avg_len_min"].Text.ToString();
txtAvgLenMax.Value = ultraGrid2.ActiveRow.Cells["avg_len_max"].Text.ToString();
txtDifrncLenMax.Value = ultraGrid2.ActiveRow.Cells["ENDLEN_SPECSTD"].Text.ToString();
ultraNumericEditor1.Value = ultraGrid2.ActiveRow.Cells["DIFRNC_LEN_MAX"].Text.ToString();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
private void ultraGrid2_DoubleClickCell(object sender, DoubleClickCellEventArgs e)
{
Infragistics.Win.UltraWinGrid.UltraGridRow row = ultraGrid2.ActiveRow;
if (row != null)
{
this.doAdd();
this.Close();
}
}
private void ultraButton1_Click(object sender, EventArgs e)
{
txtSiglLen.Text = "";
txtDifrncLenMax.Text = "";
txtShrtLenRato.Text = "";
txtLongLenRato.Text = "";
txtLenMin.Text = "";
txtShortest.Text = "";
txtLongest.Text = "";
txtLenMax.Text = "";
cmbShrtStove.SelectedIndex = -1;
txtAvgLenMin.Text = "";
txtAvgLenMax.Text = "";
ultraNumericEditor1.Text = "";
this.txtLenMin.Focus();
}
private void txtShrtLenRato_ValueChanged(object sender, EventArgs e)
{
if (txtShrtLenRato.Text.Trim() == "")
{
txtShortest.Text = "";
//cmbShrtStove.SelectedIndex = -1;
}
}
private void txtLongLenRato_ValueChanged(object sender, EventArgs e)
{
if (txtLongLenRato.Text.Trim() == "")
{
txtLongest.Text = "";
}
}
private void txtSiglLen_KeyDown(object sender, KeyEventArgs e)//单倍尺长
{
if (e.KeyCode != Keys.Enter) return;
this.txtShrtLenRato.Focus();
}
private void txtDifrncLenMax_KeyDown(object sender, KeyEventArgs e)//成品公差
{
if (e.KeyCode != Keys.Enter) return;
this.txtLongLenRato.Focus();
this.txtLongLenRato.SelectAll();
}
private void txtLenMin_KeyDown(object sender, KeyEventArgs e)//长度下限
{
if (e.KeyCode != Keys.Enter) return;
this.txtLenMax.Focus();
}
private void txtShrtLenRato_KeyDown(object sender, KeyEventArgs e)//短尺率
{
if (e.KeyCode != Keys.Enter) return;
this.txtShortest.Focus();
}
private void txtLongLenRato_KeyDown(object sender, KeyEventArgs e)//长尺率
{
if (e.KeyCode != Keys.Enter) return;
this.txtLongest.Focus();
}
private void txtLenMax_KeyDown(object sender, KeyEventArgs e)//长度上限
{
if (e.KeyCode != Keys.Enter) return;
this.ultraNumericEditor1.Focus();
}
private void txtShortest_KeyDown(object sender, KeyEventArgs e)//短尺最短
{
if (e.KeyCode != Keys.Enter) return;
this.cmbShrtStove.Focus();
}
private void txtLongest_KeyDown(object sender, KeyEventArgs e)//长尺最长
{
if (e.KeyCode != Keys.Enter) return;
this.txtAvgLenMin.Focus();
}
private void ultraNumericEditor1_KeyDown(object sender, KeyEventArgs e)//最大最长差小于
{
if (e.KeyCode != Keys.Enter) return;
this.txtSiglLen.Focus();
}
private void cmbShrtStove_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Enter) return;
this.txtDifrncLenMax.Focus();
}
private void txtAvgLenMin_KeyDown(object sender, KeyEventArgs e)//平均长度大于
{
if (e.KeyCode != Keys.Enter) return;
this.doAdd();
}
}
}