Exemplo n.º 1
0
        public static void Print(DataSet DS, int v, Context Context, IBillView View, string XH, string INNOType = "")
        {
            string formid = View.BillBusinessInfo.GetForm().Id.ToString();

            Logger.Debug("打印---", "------------BEGIN------------------");

            Logger.Debug("---", $"------------打印条码或生产订单号为:{XH}------------------");
            List <dynamic> listData = new List <dynamic>();

            listData.Clear();

            if (DS != null && DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow Row in DS.Tables[0].Rows)
                {
                    string FListSQL = Convert.ToString(Row["F_SZXY_ListSQL"]);
                    if (Convert.ToString(Row[1]).IsNullOrEmptyOrWhiteSpace())
                    {
                        View.ShowMessage("当前用户没有设置grf打印模板,请检查!");
                    }
                    if (Convert.ToString(Row[2]).IsNullOrEmptyOrWhiteSpace())
                    {
                        View.ShowMessage("当前用户没有设置grf打印地址,请检查!");
                    }
                    string QSQL = "";
                    if (INNOType == "BillNo")
                    {
                        QSQL = $"{Convert.ToString(Row[6])} DYBQDD in ({XH}) {FListSQL}";

                        Logger.Debug("订单号拼接sql:", QSQL);
                    }
                    else
                    {
                        QSQL = $"{Convert.ToString(Row[6])} DYBQ in ({XH})  {FListSQL}";
                        Logger.Debug("条码号拼接sql:", QSQL);
                    }

                    var ReportModel = new
                    {
                        FID          = Convert.ToString(Row[0]),
                        report       = Convert.ToString(Row[1]),
                        PrintAddress = Convert.ToString(Row[2]),
                        PrintQty     = Convert.ToString(Row[3]),
                        ConnString   = Convert.ToString(Row[5]),
                        QuerySQL     = QSQL
                    };

                    if (QSQL != "")
                    {
                        DataSet SelNullDS = DBServiceHelper.ExecuteDataSet(Context, $"/*dialect*/{QSQL}");

                        if (SelNullDS != null && SelNullDS.Tables.Count > 0 && SelNullDS.Tables[0].Rows.Count > 0)
                        {
                            listData.Add(ReportModel);
                        }
                    }
                    Logger.Debug("最终打印查询SQL:", QSQL);
                }
            }
            string strJson = "";

            if (listData.Count > 0 && listData != null)
            {
                strJson = Newtonsoft.Json.JsonConvert.SerializeObject(listData);
            }

            if (strJson != "")
            {
                //调用打印
                string  SQL = "/*dialect*/select F_SZXY_EXTERNALCONADS from SZXY_t_ClientExtern ";
                DataSet ids = DBServiceHelper.ExecuteDataSet(Context, SQL);

                if (ids != null && ids.Tables.Count > 0 && ids.Tables[0].Rows.Count > 0)
                {
                    string linkUrl = Convert.ToString(ids.Tables[0].Rows[0][0]).Replace("\\", "\\\\");// @"C:\Users\Administrator\Desktop\Grid++Report 6old\Grid++Report 6\Samples\CSharp\8.PrintInForm\bin\Debug\PrintReport.exe";
                    if (v == 0)
                    {
                        if (!strJson.IsNullOrEmptyOrWhiteSpace())
                        {
                            View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Print " + strJson);

                            //打印记录表
                            // Utils.GenPrintReCord(View, Context, formid, XH);
                        }
                        else
                        {
                            View.ShowMessage("当前用户没有设置Grid++Report打印外接程序地址,请检查!");
                        }
                    }
                    else
                    {
                        if (!linkUrl.IsNullOrEmptyOrWhiteSpace())
                        {
                            View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Preview " + strJson);
                        }
                        // if (!linkUrl.IsNullOrEmptyOrWhiteSpace()) View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Print " + strJson);

                        else
                        {
                            View.ShowMessage("当前用户没有设置Grid++Report打印外接程序地址,请检查!");
                        }
                    }
                }
                else
                {
                    Logger.Debug("客户端外接配置查询返回为空", "不调打印");
                }
                View.SendDynamicFormAction(View);
            }

            Logger.Debug("打印---", "---------------END------------------");
        }
        public static void Print(DataSet ds, int v, Context Context, IBillView View, string XH)
        {
            #region
            if (v == 0)
            {
                List <dynamic> listData = new List <dynamic>();
                listData.Clear();
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    string FListSQL = Convert.ToString(ds.Tables[0].Rows[0]["F_SZXY_ListSQL"]);
                    foreach (DataRow Row in ds.Tables[0].Rows)
                    {
                        // Kingdee.BOS.Log.Logger.Debug("QuerySQL", $"/*Dialect*/{Convert.ToString(Row[6])} {View.Model.GetPKValue()}");
                        if (Convert.ToString(Row[1]).IsNullOrEmptyOrWhiteSpace())
                        {
                            View.ShowMessage("当前用户没有设置grf打印模板,请检查!");
                        }
                        if (Convert.ToString(Row[2]).IsNullOrEmptyOrWhiteSpace())
                        {
                            View.ShowMessage("当前用户没有设置grf打印地址,请检查!");
                        }
                        var ReportModel = new
                        {
                            FID          = Convert.ToString(Row[0]),
                            report       = Convert.ToString(Row[1]),
                            PrintAddress = Convert.ToString(Row[2]),
                            PrintQty     = Convert.ToString(Row[3]),
                            //Label = Convert.ToString(Row[4]),
                            ConnString = Convert.ToString(Row[5]),
                            QuerySQL   = $"{Convert.ToString(Row[6])}F_SZXY_CBNO1='{XH}' {FListSQL}"
                        };
                        listData.Add(ReportModel);
                    }
                }
                string strJson = Newtonsoft.Json.JsonConvert.SerializeObject(listData);
                //调用打印
                string  SQL = "/*dialect*/select F_SZXY_EXTERNALCONADS from SZXY_t_ClientExtern ";
                DataSet ids = DBServiceHelper.ExecuteDataSet(Context, SQL);
                if (ids != null && ids.Tables.Count > 0 && ids.Tables[0].Rows.Count > 0)
                {
                    string linkUrl = Convert.ToString(ids.Tables[0].Rows[0][0]).Replace("\\", "\\\\");// @"C:\Users\Administrator\Desktop\Grid++Report 6old\Grid++Report 6\Samples\CSharp\8.PrintInForm\bin\Debug\PrintReport.exe";

                    if (!strJson.IsNullOrEmptyOrWhiteSpace())
                    {
                        View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Print " + strJson);
                    }

                    else
                    {
                        View.ShowMessage("当前用户没有设置Grid++Report打印外接程序地址,请检查!");
                    }
                }
                View.SendDynamicFormAction(View);
            }
            else
            {
                List <dynamic> listData = new List <dynamic>();
                listData.Clear();
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    string FListSQL = Convert.ToString(ds.Tables[0].Rows[0]["F_SZXY_ListSQL"]);
                    foreach (DataRow Row in ds.Tables[0].Rows)
                    {
                        //Kingdee.BOS.Log.Logger.Debug("QuerySQL", $"/*Dialect*/{Convert.ToString(Row[6])} {View.Model.GetPKValue()}");
                        if (Convert.ToString(Row[1]).IsNullOrEmptyOrWhiteSpace())
                        {
                            View.ShowMessage("当前用户没有设置grf打印模板,请检查!");
                        }
                        if (Convert.ToString(Row[2]).IsNullOrEmptyOrWhiteSpace())
                        {
                            View.ShowMessage("当前用户没有设置grf打印地址,请检查!");
                        }
                        var ReportModel = new
                        {
                            FID          = Convert.ToString(Row[0]),
                            report       = Convert.ToString(Row[1]),
                            PrintAddress = Convert.ToString(Row[2]),
                            PrintQty     = Convert.ToString(Row[3]),
                            //Label = Convert.ToString(Row[4]),
                            ConnString = Convert.ToString(Row[5]),
                            QuerySQL   = $"{Convert.ToString(Row[6])}F_SZXY_CTNNO='{XH}' {FListSQL}"
                        };
                        listData.Add(ReportModel);
                    }
                }
                string strJson = Newtonsoft.Json.JsonConvert.SerializeObject(listData);
                //调用打印
                string  SQL = "/*dialect*/select F_SZXY_EXTERNALCONADS from SZXY_t_ClientExtern ";
                DataSet ids = DBServiceHelper.ExecuteDataSet(Context, SQL);
                if (ids != null && ids.Tables.Count > 0 && ids.Tables[0].Rows.Count > 0)
                {
                    string linkUrl = Convert.ToString(ids.Tables[0].Rows[0][0]).Replace("\\", "\\\\");// @"C:\Users\Administrator\Desktop\Grid++Report 6old\Grid++Report 6\Samples\CSharp\8.PrintInForm\bin\Debug\PrintReport.exe";
                    if (!linkUrl.IsNullOrEmptyOrWhiteSpace())
                    {
                        View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Preview " + strJson);
                    }
                    if (!strJson.IsNullOrEmptyOrWhiteSpace())
                    {
                        View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Print " + strJson);
                    }

                    else
                    {
                        View.ShowMessage("当前用户没有设置Grid++Report打印外接程序地址,请检查!");
                    }
                }
                View.SendDynamicFormAction(View);
            }
            #endregion
        }
Exemplo n.º 3
0
        /// <summary>
        /// 调用打印
        /// </summary>
        /// <param name="套打模板dataset"></param>
        /// <param name="0 OR 1 0代表打印,1代表预览打印"></param>
        /// <param name="Context"></param>
        /// <param name="View"></param>
        /// <param name="Mac地址"></param>
        /// <param name="Fid"></param>
        public static void Print(DataSet ds, int v, Context Context, IBillView View, string MacInfo = "", string Fid = "")
        {
            Logger.Debug("打印---", "------------BEGIN------------------");
            string PKFid = "";

            if (!Convert.ToString(View.Model.GetPKValue()).IsNullOrEmptyOrWhiteSpace())
            {
                PKFid = Convert.ToString(View.Model.GetPKValue());
            }
            else
            {
                PKFid = Fid;
            }
            Logger.Debug("打印Fid---", $"-------{PKFid}-----");
            #region
            if (PKFid != "")
            {
                List <dynamic> listData = new List <dynamic>();
                listData.Clear();
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    string FListSQL = Convert.ToString(ds.Tables[0].Rows[0]["F_SZXY_ListSQL"]);

                    foreach (DataRow Row in ds.Tables[0].Rows)
                    {
                        string QSQL = Convert.ToString(Row[6]);
                        //System.Text.RegularExpressions.Regex.Replace(Convert.ToString(Row[6]), @"[^0-9]+", "");
                        if (View.BusinessInfo.GetForm().Id == "SAL_OUTSTOCK")
                        {
                            QSQL = Convert.ToString(Row[6]).Replace("@Fid@", $" XYFID={PKFid} {FListSQL} ");
                        }
                        else
                        {
                            QSQL = $"{Convert.ToString(Row[6])}{PKFid} {FListSQL}";
                        }

                        // Kingdee.BOS.Log.Logger.Debug("QuerySQL", $"/*Dialect*/{Convert.ToString(Row[6])} {View.Model.GetPKValue()}");
                        if (Convert.ToString(Row[1]).IsNullOrEmptyOrWhiteSpace())
                        {
                            View.ShowMessage("当前用户没有设置grf打印模板,请检查!");
                        }
                        if (Convert.ToString(Row[2]).IsNullOrEmptyOrWhiteSpace())
                        {
                            View.ShowMessage("当前用户没有设置grf打印地址,请检查!");
                        }
                        var ReportModel = new
                        {
                            FID          = Convert.ToString(Row[0]),
                            report       = Convert.ToString(Row[1]),
                            PrintAddress = Convert.ToString(Row[2]),
                            PrintQty     = Convert.ToString(Row[3]),

                            ConnString = Convert.ToString(Row[5]),
                            // QuerySQL = $"/*dialect*/{Convert.ToString(Row[6])}{PKFid} {FListSQL}"
                            QuerySQL = QSQL
                        };
                        //string SelIsNull = $"/*dialect*/{Convert.ToString(Row[6])}{PKFid} {FListSQL}";
                        Logger.Debug("查询是否存在数据SQL:", QSQL);
                        DataSet SelNullDS = DBServiceHelper.ExecuteDataSet(Context, $"/*dialect*/{Convert.ToString(Row[6])}{PKFid} {FListSQL}");

                        if (SelNullDS != null && SelNullDS.Tables.Count > 0 && SelNullDS.Tables[0].Rows.Count > 0)
                        {
                            listData.Add(ReportModel);
                        }
                        Logger.Debug("最终打印查询SQL:", QSQL);
                    }
                }
                string strJson = "";
                if (listData.Count > 0 && listData != null)
                {
                    strJson = Newtonsoft.Json.JsonConvert.SerializeObject(listData);
                }

                if (strJson != "")
                {
                    //调用打印
                    string  SQL = "/*dialect*/select F_SZXY_EXTERNALCONADS from SZXY_t_ClientExtern ";
                    DataSet ids = DBServiceHelper.ExecuteDataSet(Context, SQL);
                    if (ids != null && ids.Tables.Count > 0 && ids.Tables[0].Rows.Count > 0)
                    {
                        string linkUrl = Convert.ToString(ids.Tables[0].Rows[0][0]).Replace("\\", "\\\\");// @"C:\Users\Administrator\Desktop\Grid++Report 6old\Grid++Report 6\Samples\CSharp\8.PrintInForm\bin\Debug\PrintReport.exe";
                        if (v == 0)
                        {
                            if (!strJson.IsNullOrEmptyOrWhiteSpace())
                            {
                                View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Print " + strJson);
                            }
                            else
                            {
                                View.ShowMessage("当前用户没有设置Grid++Report打印外接程序地址,请检查!");
                            }
                        }
                        else
                        {
                            if (!linkUrl.IsNullOrEmptyOrWhiteSpace())
                            {
                                View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Preview " + strJson);
                            }
                            //if (!linkUrl.IsNullOrEmptyOrWhiteSpace()) View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Print " + strJson);

                            else
                            {
                                View.ShowMessage("当前用户没有设置Grid++Report打印外接程序地址,请检查!");
                            }
                        }
                    }
                    else
                    {
                        Logger.Debug("客户端外接配置查询返回为空", "不调打印");
                    }
                    View.SendDynamicFormAction(View);
                }



                //else
                //{
                //    List<dynamic> listData = new List<dynamic>();
                //    listData.Clear();
                //    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                //    {
                //        string FListSQL = Convert.ToString(ds.Tables[0].Rows[0]["F_SZXY_ListSQL"]);
                //        foreach (DataRow Row in ds.Tables[0].Rows)
                //        {

                //            //Kingdee.BOS.Log.Logger.Debug("QuerySQL", $"/*Dialect*/{Convert.ToString(Row[6])} {View.Model.GetPKValue()}");
                //            if (Convert.ToString(Row[1]).IsNullOrEmptyOrWhiteSpace()) View.ShowMessage("当前用户没有设置grf打印模板,请检查!");
                //            if (Convert.ToString(Row[2]).IsNullOrEmptyOrWhiteSpace()) View.ShowMessage("当前用户没有设置grf打印地址,请检查!");
                //            var ReportModel = new
                //            {
                //                FID = Convert.ToString(Row[0]),
                //                report = Convert.ToString(Row[1]),
                //                PrintAddress = Convert.ToString(Row[2]),
                //                PrintQty = Convert.ToString(Row[3]),
                //                //Label = Convert.ToString(Row[4]),
                //                ConnString = Convert.ToString(Row[5]),
                //                QuerySQL = $"{Convert.ToString(Row[6])}{PKFid} {FListSQL}"
                //                //QuerySQL = $"{Convert.ToString(Row[6])}{View.Model.GetPKValue()} {FListSQL}"

                //            };
                //            string SelIsNull = $"{Convert.ToString(Row[6])}{PKFid} {FListSQL}";
                //            Logger.Debug("查询是否存在数据SQL:", $"{Convert.ToString(Row[6])} {PKFid} {FListSQL}");
                //            DataSet SelNullDS = DBServiceHelper.ExecuteDataSet(Context, SelIsNull);

                //            if (SelNullDS != null && SelNullDS.Tables.Count > 0 && SelNullDS.Tables[0].Rows.Count > 0)
                //            {
                //                listData.Add(ReportModel);
                //            }
                //            Logger.Debug("最终预览打印查询SQL:", $"{Convert.ToString(Row[6])} {PKFid} {FListSQL}");
                //        }
                //    }
                //    string strJson = Newtonsoft.Json.JsonConvert.SerializeObject(listData);

                //    Logger.Debug("配置JSON", strJson);
                //    if (!strJson.IsNullOrEmptyOrWhiteSpace())
                //    {
                //        //调用打印
                //        string SQL = "/*dialect*/select F_SZXY_EXTERNALCONADS from SZXY_t_ClientExtern ";
                //        DataSet ids = DBServiceHelper.ExecuteDataSet(Context, SQL);
                //        if (ids != null && ids.Tables.Count > 0 && ids.Tables[0].Rows.Count > 0)
                //        {
                //            string linkUrl = Convert.ToString(ids.Tables[0].Rows[0][0]).Replace("\\", "\\\\");// @"C:\Users\Administrator\Desktop\Grid++Report 6old\Grid++Report 6\Samples\CSharp\8.PrintInForm\bin\Debug\PrintReport.exe";
                //            if (!linkUrl.IsNullOrEmptyOrWhiteSpace()) View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Preview " + strJson);
                //            if (!linkUrl.IsNullOrEmptyOrWhiteSpace()) View.GetControl("F_SZXY_Link").InvokeControlMethod("SetClickFromServerOfParameter", linkUrl, "Print " + strJson);

                //            else View.ShowMessage("当前用户没有设置Grid++Report打印外接程序地址,请检查!");
                //        }
                //        else
                //        {
                //            Logger.Debug("客户端外接配置查询返回为空", "不调打印");
                //        }
                //        View.SendDynamicFormAction(View);
                //    }

                //}
            }

            #endregion
            Logger.Debug("打印---", "---------------END------------------");
        }