版权声明:版权声明:本文为博主原创文章,转载请注明出处 https://blog.csdn.net/yehangyu0525/article/details/83994940
截取字符串(第一个字符串,最后一个,某个位置字符串)
string strGroupBatchCodeSub = strGroupBatchCode.Substring(0, strGroupBatchCode.IndexOf('_'));
判断是否含有某个字符串(“,”,“-”,“/”)
if (strTextBoxValue.Contains(strTextBoxSub1))
#region yehy 批量扫条码
DataSet dsAllWorkJob = null;
if (textBox1.Text.Trim().ToString() != "")
{
DataSet dsAll = m_PlanOverAndBackLogic.GetInformation(strCurrentWorkType, strCraftplanNo, strDeptAll);
if (dsAll.Tables[0].Rows.Count > 0)
{
string strGroupBatchCode = "";
foreach (DataRow dst in dsAll.Tables[0].Rows)
{
strGroupBatchCode = dst["Groupbatchcode"].ToString().Trim();
}
//组批次
string strGroupBatchCodeSub = strGroupBatchCode.Substring(0, strGroupBatchCode.IndexOf('_'));
//过程卡序号值
string strTextBoxValue = textBox1.Text.Trim().ToString();
//判断第一位和最后一位
//截取是否是 - /
string strTextBoxSub1 = "-";
string strTextBoxSub2 = "/";
//判断输入 是否含有 - 字符串
if (strTextBoxValue.Contains(strTextBoxSub1))
{
string[] strTextBoxValueSub = strTextBoxValue.Split('-');
string strGroupPin1 = "";
string strGroupPin2 = "";
int ij = 0;
for (int i = 0; i < strTextBoxValueSub.Length; i++)
{
if (i ==0)
{
strGroupPin1 = strTextBoxValueSub[0];
}
else
{
strGroupPin2 = strTextBoxValueSub[1];
}
ij++;
}
//判断是否为两位
if (ij == 2)
{
int intGroupPin1 = Convert.ToInt32(strGroupPin1);
int intGroupPin2 = Convert.ToInt32(strGroupPin2);
//判断第一个是否小于第二个
if (intGroupPin1 < intGroupPin2)
{
string strGroupPinhe1 = strGroupBatchCodeSub + "_" + strGroupPin1;
string strGroupPinhe2 = strGroupBatchCodeSub + "_" + strGroupPin2;
dsAllWorkJob = m_PlanOverAndBackLogic.GetInformation1(strCurrentWorkType, strCraftplanNo, strDeptAll, strGroupPinhe1, strGroupPinhe2);
}
else
{
UserMessages.ShowInfoBox("输入格式如下(6-8)!");
}
}
else
{
UserMessages.ShowInfoBox("输入格式如下(6-8)!");
}
}
//判断输入 是否含有 / 字符串
else if (strTextBoxValue.Contains(strTextBoxSub2))
{
string[] strTextBoxValueSub = strTextBoxValue.Split('/');
string strTextBoxValueZhuH = "";
for (int i = 0; i < strTextBoxValueSub.Length; i++)
{
strTextBoxValueZhuH += "'"+strGroupBatchCodeSub + "_" + strTextBoxValueSub[i] +"'"+ ",";
}
//将最后一个逗号去掉
string strTextBoxValueZhuHZ = strTextBoxValueZhuH.Substring(0, strTextBoxValueZhuH.Length - 1);
dsAllWorkJob = m_PlanOverAndBackLogic.GetInformation2(strCurrentWorkType, strCraftplanNo, strDeptAll, strTextBoxValueZhuHZ);
}
else
{
UserMessages.ShowInfoBox("输入格式不正确!");
}
}
else
{
Timer("该条码下没有您的生产任务!");
this.KWTextBox.Text = "";
this.textBox1.Text = "";
}
}
#endregion