Selaa lähdekoodia

添加支持FastReport打印外箱

章政 7 vuotta sitten
vanhempi
commit
9f3fc2ee4a

+ 2 - 0
UAS-出货标签管理(泽天)/UAS_出货标签管理.Designer.cs

@@ -246,6 +246,8 @@
             // GetGridOnly
             // 
             this.GetGridOnly.AutoSize = true;
+            this.GetGridOnly.Checked = true;
+            this.GetGridOnly.CheckState = System.Windows.Forms.CheckState.Checked;
             this.GetGridOnly.Font = new System.Drawing.Font("微软雅黑", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.GetGridOnly.Location = new System.Drawing.Point(230, 38);
             this.GetGridOnly.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);

+ 84 - 47
UAS-出货标签管理(泽天)/UAS_出货标签管理.cs

@@ -13,6 +13,7 @@ using UAS_LabelMachine.PublicForm;
 using System.Threading;
 using System.IO;
 using System.Globalization;
+using FastReport;
 
 namespace UAS_LabelMachine
 {
@@ -42,6 +43,10 @@ namespace UAS_LabelMachine
         /// 外箱打印文件
         /// </summary>
         Document OutBoxDoc;
+
+        string OutLabelType = "";
+
+        Report OutReport = new Report();
         /// <summary>
         /// 唛头文件
         /// </summary>
@@ -625,37 +630,46 @@ namespace UAS_LabelMachine
                 }
             if (OutBoxCombox.Text != "")
             {
-                OutBoxDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + OutBoxCombox.Text);
-                string ParamCondition = "";
-                for (int i = 0; i < OutBoxDoc.Variables.FreeVariables.Count; i++)
+                if (OutBoxCombox.Text.Substring(OutBoxCombox.Text.LastIndexOf(".") + 1).ToLower() == "frx")
+                {
+                    OutLabelType = "FastReport";
+                    OutReport.Load(ftpOperater.DownLoadTo + OutBoxCombox.Text);
+                }
+                else
                 {
-                    if (i != OutBoxDoc.Variables.FreeVariables.Count - 1)
+                    OutLabelType = "CodeSoft";
+                    OutBoxDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + OutBoxCombox.Text);
+                    string ParamCondition = "";
+                    for (int i = 0; i < OutBoxDoc.Variables.FreeVariables.Count; i++)
                     {
-                        ParamCondition += "'" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name + "',";
+                        if (i != OutBoxDoc.Variables.FreeVariables.Count - 1)
+                        {
+                            ParamCondition += "'" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name + "',";
+                        }
+                        else
+                        {
+                            ParamCondition += "'" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name + "'";
+                        }
                     }
-                    else
+                    OutLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + OutBoxCombox.SelectedValue.ToString().Split('#')[0] + " and lp_name in(" + ParamCondition + ")  order by lp_detno", "select");
+                    DataTable Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LABELATTACHPARAMETER where lap_custcode='" + pi_cardcode.Text + "' and lap_param in(" + ParamCondition + ")", "select");
+                    OutSQL = "select * from ";
+                    for (int i = 0; i < OutLabelParam.Rows.Count; i++)
                     {
-                        ParamCondition += "'" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name + "'";
+                        if (i != OutLabelParam.Rows.Count - 1 || Attach.Rows.Count > 0)
+                            OutSQL += "(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + "),";
+                        else
+                            OutSQL += "(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + ")";
                     }
+                    for (int i = 0; i < Attach.Rows.Count; i++)
+                    {
+                        if (i != Attach.Rows.Count - 1)
+                            OutSQL += "(select '" + Attach.Rows[i]["lp_sql"].ToString() + "' from dual),";
+                        else
+                            OutSQL += "(select '" + Attach.Rows[i]["lp_sql"].ToString() + "' from dual)";
+                    }
+                    OutLabelParam.Merge(Attach);
                 }
-                OutLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + OutBoxCombox.SelectedValue.ToString().Split('#')[0] + " and lp_name in(" + ParamCondition + ")  order by lp_detno", "select");
-                DataTable Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LABELATTACHPARAMETER where lap_custcode='" + pi_cardcode.Text + "' and lap_param in(" + ParamCondition + ")", "select");
-                OutSQL = "select * from ";
-                for (int i = 0; i < OutLabelParam.Rows.Count; i++)
-                {
-                    if (i != OutLabelParam.Rows.Count - 1 || Attach.Rows.Count > 0)
-                        OutSQL += "(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + "),";
-                    else
-                        OutSQL += "(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + ")";
-                }
-                for (int i = 0; i < Attach.Rows.Count; i++)
-                {
-                    if (i != Attach.Rows.Count - 1)
-                        OutSQL += "(select '" + Attach.Rows[i]["lp_sql"].ToString() + "' from dual),";
-                    else
-                        OutSQL += "(select '" + Attach.Rows[i]["lp_sql"].ToString() + "' from dual)";
-                }
-                OutLabelParam.Merge(Attach);
             }
             if (!File.Exists(ftpOperater.DownLoadTo + "唛头.lab"))
             {
@@ -973,14 +987,11 @@ namespace UAS_LabelMachine
             {
                 for (int i = 0; i < LabelInf.RowCount; i++)
                 {
-                    if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString().ToLower() == "true")
-                    {
-                        string outboxcode2 = LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString();
-                        //富为使用包装单的逻辑
-                        //如果不包含该箱号则进行添加
-                        if (!Outboxcode.Contains(outboxcode2))
-                            Outboxcode.Add(outboxcode2);
-                    }
+                    string outboxcode2 = LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString();
+                    //富为使用包装单的逻辑
+                    //如果不包含该箱号则进行添加
+                    if (!Outboxcode.Contains(outboxcode2))
+                        Outboxcode.Add(outboxcode2);
                 }
                 //按获取到的箱号列表进行打印
                 if (Outboxcode.ToArray().Length > 0)
@@ -1094,24 +1105,50 @@ namespace UAS_LabelMachine
             {
                 try
                 {
-                    //将维护的模板参数和模板本身的参数名称进行比对
                     string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
                     string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
-                    DataTable dt = (DataTable)dh.ExecuteSql(OutSQL.ToLower().Replace("{pib_id}", "'" + pib_id + "'").Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'"), "select");
-                    for (int k = 0; k < OutLabelParam.Rows.Count; k++)
+                    if (OutLabelType == "CodeSoft")
+                    {
+                        //将维护的模板参数和模板本身的参数名称进行比对
+                        DataTable dt = (DataTable)dh.ExecuteSql(OutSQL.ToLower().Replace("{pib_id}", "'" + pib_id + "'").Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'"), "select");
+                        for (int k = 0; k < OutLabelParam.Rows.Count; k++)
+                        {
+                            //获取对应行的pib_id
+                            string ParamName = OutLabelParam.Rows[k]["lp_name"].ToString();
+                            OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
+                            LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值" + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value);
+                        }
+                        //保存参数打印
+                        OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
+                        OutBoxDoc.PrintDocument();
+                        Properties.Settings.Default.OPrinter = OutBoxPrinter.Text;
+                        Properties.Settings.Default.Save();
+                        LogManager.DoLog("执行打印外箱,pib_id:" + LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString());
+                        LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "手动打印外箱箱标", "打印成功");
+                    }
+                    else if (OutLabelType == "FastReport")
                     {
-                        //获取对应行的pib_id
-                        string ParamName = OutLabelParam.Rows[k]["lp_name"].ToString();
-                        OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
-                        LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值" + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value);
+                        DataTable dt = (DataTable)dh.ExecuteSql("select * from prodioinfo_view where 出货单号='" + pi_inoutno.Text + "' and 外箱号='" + pib_outboxcode2 + "'", "select");
+                        DataTable dt1 = dt.Clone();
+                        for (int i = 0; i < dt.Rows.Count; i++)
+                        {
+                            DataRow dr = dt1.NewRow();
+                            for (int j = 0; j < dt.Columns.Count; j++)
+                            {
+                                dr[j] = dt.Rows[i][j].ToString();
+                            }
+                            dt1.Rows.Add(dr);
+                            if ((i + 1) % 5 == 0 || (i + 1) == dt.Rows.Count)
+                            {
+                                OutReport.RegisterData(dt1, "prodioinfo_view");
+                                OutReport.GetDataSource("prodioinfo_view").Enabled = true;
+                                OutReport.PrintSettings.ShowDialog = false;
+                                OutReport.PrintSettings.Printer = OutBoxPrinter.Text;
+                                OutReport.Print();
+                                BaseUtil.CleanDataTableData(dt1);
+                            }
+                        }
                     }
-                    //保存参数打印
-                    OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
-                    OutBoxDoc.PrintDocument();
-                    Properties.Settings.Default.OPrinter = OutBoxPrinter.Text;
-                    Properties.Settings.Default.Save();
-                    LogManager.DoLog("执行打印外箱,pib_id:" + LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString());
-                    LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "手动打印外箱箱标", "打印成功");
                 }
                 catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); }
             }

+ 1 - 1
UAS-出货标签管理(泽天)/客户标签维护.cs

@@ -225,7 +225,7 @@ namespace UAS_LabelMachine
             //根据勾选的不同设置不同的文件后缀过滤
             if (CodeSoft.Checked)
             {
-                openFileDialog1.Filter = "(*.lab)|*.lab";
+                openFileDialog1.Filter = "(*.lab)|*.lab|(*.frx)|*.frx";
             }
             DialogResult result = openFileDialog1.ShowDialog();
             if (result == DialogResult.OK)