Просмотр исходного кода

绑定条码时,改为不控制条码位数

Administrator 5 лет назад
Родитель
Сommit
77c80b4b89
1 измененных файлов с 31 добавлено и 20 удалено
  1. 31 20
      DK.Client/PMModule/F_PM_0103.cs

+ 31 - 20
DK.Client/PMModule/F_PM_0103.cs

@@ -279,34 +279,45 @@ namespace Dongke.IBOSS.PRD.Client.PMModule
 
                 System.Text.RegularExpressions.Match mc =
                     System.Text.RegularExpressions.Regex.Match(barcodeBegin, @"^([a-zA-Z]*|[a-zA-Z0-9]*[a-zA-Z]+)([0-9]{10,})$");
-                if (!mc.Success)
-                {
-                    DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_005, barcodeBegin);
-                    this.txtBarCodeStart.Focus();
-                    return;
-                }
+
+                // 中陶改为不控制条码位数
+                //if (!mc.Success)
+                //{
+                //    DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_005, barcodeBegin);
+                //    this.txtBarCodeStart.Focus();
+                //    return;
+                //}
 
                 string strLetter = mc.Groups[1].Value;
                 string strDigit = mc.Groups[2].Value;
 
-                decimal digit = Convert.ToDecimal(strDigit);
-                int len = strDigit.Length;
-                foreach (DataGridViewRow row in this.dgvDetail.Rows)
-                {
-                    object sf = row.Cells["ScrapFlag"].Value;
-                    if (row.Cells["BarCode"].ReadOnly || sf == null || "1" == sf.ToString())
+                decimal digit = 0;
+                // 如果能转换为数字,则按之前的逻辑绑定条码
+				if (decimal.TryParse(strDigit, out digit))
+				{
+                    int len = strDigit.Length;
+                    foreach (DataGridViewRow row in this.dgvDetail.Rows)
                     {
-                        continue;
-                    }
+                        object sf = row.Cells["ScrapFlag"].Value;
+                        if (row.Cells["BarCode"].ReadOnly || sf == null || "1" == sf.ToString())
+                        {
+                            continue;
+                        }
 
-                    string barcode = strLetter + (digit++).ToString().PadLeft(len, '0');
-                    row.Cells["BarCode"].Value = barcode;
-                    DataRowView dataRow = row.DataBoundItem as DataRowView;
-                    if (dataRow != null)
-                    {
-                        dataRow.EndEdit();
+                        string barcode = strLetter + (digit++).ToString().PadLeft(len, '0');
+                        row.Cells["BarCode"].Value = barcode;
+                        DataRowView dataRow = row.DataBoundItem as DataRowView;
+                        if (dataRow != null)
+                        {
+                            dataRow.EndEdit();
+                        }
                     }
                 }
+                // 否则把条码赋给第一个注浆明细
+				else
+				{
+                    dgvDetail.Rows[0].Cells["BarCode"].Value = barcodeBegin;
+                }
             }
             catch (Exception ex)
             {