소스 검색

添加支持流水进制功能

章政 7 년 전
부모
커밋
ed2b91406c
3개의 변경된 파일63개의 추가작업 그리고 11개의 파일을 삭제
  1. 36 0
      UAS-出货标签管理/PublicMethod/BaseUtil.cs
  2. 20 6
      UAS-出货标签管理/UAS_出货标签管理.cs
  3. 7 5
      UAS-出货标签管理/生成条码.cs

+ 36 - 0
UAS-出货标签管理/PublicMethod/BaseUtil.cs

@@ -29,6 +29,42 @@ namespace UAS_LabelMachine
             }
         }
 
+        public static string DToAny(double DB, int Type)
+        {
+            string H = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+            long D;
+            double B;
+            string tempD = "", tempB = "";
+            D = (long)DB;
+            B = DB - D;
+            if (D == 0)
+            {
+                tempD = "0";
+            }
+            while (D != 0)
+            {
+                tempD = H[(((int)D % Type))] + tempD;
+                D = D / Type;
+            }
+            for (int i = 0; i < 7; i++)
+            {
+                if (B == 0)
+                {
+                    break;
+                }
+                tempB += H[((int)(B * Type))];
+                B = B * Type - (int)(B * Type);
+            }
+            if (tempB == "")
+            {
+                return tempD;
+            }
+            else
+            {
+                return tempD + "." + tempB;
+            }
+        }
+
         public static DataTable GetExportDataTable(DataGridView dgv)
         {
             DataTable dt = ((DataTable)dgv.DataSource).Copy();

+ 20 - 6
UAS-出货标签管理/UAS_出货标签管理.cs

@@ -526,7 +526,11 @@ namespace UAS_LabelMachine
                                 {
                                     if (la_id != "")
                                         AutoPrintSingleLabel(la_id, LabelUrl);
-                                    else MessageBox.Show("未维护单盘标签");
+                                    else
+                                    {
+                                        MessageBox.Show("未维护单盘标签");
+                                        return;
+                                    }
                                 }
                                 if (MidLabelAutoPrint.Checked)
                                     AutoPrintMidLabel();
@@ -565,10 +569,18 @@ namespace UAS_LabelMachine
                         //勾选了单盘自动打印
                         if (SingleLabelAutoPrint.Checked)
                         {
-                            string la_id = SingleLabelCombox.SelectedValue.ToString().Split('#')[0];
-                            string cl_labelname = SingleLabelCombox.Text;
-                            string LabelUrl = dh.getFieldDataByCondition("label left join customerlabel on la_code=cl_labelcode", "cl_labelurl", "la_id='" + la_id + "' and cl_labelname='" + cl_labelname + "'").ToString();
-                            AutoPrintSingleLabel(la_id, LabelUrl);
+                            if (SingleLabelCombox.SelectedValue != null)
+                            {
+                                string la_id = SingleLabelCombox.SelectedValue.ToString().Split('#')[0];
+                                string cl_labelname = SingleLabelCombox.Text;
+                                string LabelUrl = dh.getFieldDataByCondition("label left join customerlabel on la_code=cl_labelcode", "cl_labelurl", "la_id='" + la_id + "' and cl_labelname='" + cl_labelname + "'").ToString();
+                                AutoPrintSingleLabel(la_id, LabelUrl);
+                            }
+                            else
+                            {
+                                MessageBox.Show("未维护单盘标签");
+                                return;
+                            }
                         }
                         //勾选了中盒自动打印
                         if (MidLabelAutoPrint.Checked)
@@ -2511,7 +2523,9 @@ namespace UAS_LabelMachine
                     }
                 }
                 eh.ExportExcel(dt, ExportFileDialog.SelectedPath, pi_inoutno.Text);
-                MessageBox.Show("导出成功");
+                string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+                if (close.ToString() == "Yes")
+                    System.Diagnostics.Process.Start(ExportFileDialog.SelectedPath + "\\" + pi_inoutno.Text + ".xls");
             }
         }
     }

+ 7 - 5
UAS-出货标签管理/生成条码.cs

@@ -87,10 +87,10 @@ namespace UAS_LabelMachine
         private void GenerateBarCode_Click(object sender, EventArgs e)
         {
             //获取编码规则
-            DataTable Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_type,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode='" + CustCode + "' order by nrd_detno", "select");
+            DataTable Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_type,nrd_radix,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode='" + CustCode + "' order by nrd_detno", "select");
             //如果没有则取公共规则
             if (Nr.Rows.Count == 0)
-                Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_type,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode is null and nr_isdefault <> 0 order by nrd_detno", "select");
+                Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_radix,nrd_type,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode is null and nr_isdefault <> 0 order by nrd_detno", "select");
             //用于过滤参数的正则表达式
             Regex match = new Regex("{\\w+}");
             //用于存放每一项的明细的数据
@@ -100,6 +100,7 @@ namespace UAS_LabelMachine
             //流水长度
             int SerialNumLength = 0;
             //存放键值对
+            int Radix = 10;
             Dictionary<int, string> NrDic = new Dictionary<int, string>();
             for (int m = 0; m < Nr.Rows.Count; m++)
             {
@@ -146,6 +147,7 @@ namespace UAS_LabelMachine
                         custserialnum = int.Parse(NrData[m] == "" ? "0" : NrData[m]);
                         SerialNumIndex = m;
                         SerialNumLength = int.Parse(Nr.Rows[m]["nrd_length"].ToString());
+                        Radix = int.Parse(Nr.Rows[m]["nrd_radix"].ToString());
                         break;
                     default:
                         break;
@@ -240,7 +242,7 @@ namespace UAS_LabelMachine
                         {
                             //将箱号添加进List
                             barcode.Add(BarcodeMethod1(pd_id, pr_id, pib_barcode));
-                            custbarcode.Add(BarcodeMethod1(NrDic, SerialNumIndex, SerialNumLength));
+                            custbarcode.Add(BarcodeMethod1(NrDic, SerialNumIndex, SerialNumLength, Radix));
                             midcode.Add(mid_code);
                             if (mid_remain % pr_zxbzs != 0 && k + 1 == count && j + 1 == mid_num)
                                 AddNum = mid_remain % pr_zxbzs;
@@ -306,7 +308,7 @@ namespace UAS_LabelMachine
         }
 
         //生成客户条码
-        public string BarcodeMethod1(Dictionary<int, string> Dic, int Index, int Length)
+        public string BarcodeMethod1(Dictionary<int, string> Dic, int Index, int Length, int radix)
         {
             string str = "";
             for (int i = 0; i < Dic.Count; i++)
@@ -319,7 +321,7 @@ namespace UAS_LabelMachine
                 else
                 {
                     //如果是流水则需要在前面加0
-                    string serialcode = custserialnum.ToString();
+                    string serialcode = BaseUtil.DToAny(custserialnum, radix);
                     for (int j = serialcode.ToString().Length; j < Length; j++)
                     {
                         serialcode = "0" + serialcode;