/// <summary> /// 连接打印服务 /// </summary> private void ConnectPrtServ() { IntPtr hwnd = FindWindow(null, "prtserv"); if (hwnd != IntPtr.Zero) { Envior.prtservHandle = hwnd; int prtConnId = int.Parse(SqlAssist.ExecuteScalar("select seq_prtserv.nextval from dual", null).ToString()); ////建立连接 PrtServAction.Connect(prtConnId, hwnd.ToInt32(), this.Handle.ToInt32()); Envior.prtConnId = prtConnId; ////给打印服务窗口发消息 建立连接 SendMessage(hwnd, 0x2710, 0, prtConnId); } else { XtraMessageBox.Show("没有找到打印服务进程,不能打印!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void MainForm_Load(object sender, EventArgs e) { OracleDataAdapter bo01Adapter = SqlAssist.getSingleTableAdapter("select * from bo01"); bo01Adapter.Fill(dt_bo01); List <Bo01> bo01_rows = ModelHelper.TableToEntity <Bo01>(dt_bo01); businessTab = bo01_rows.ToDictionary(key => key.bo001, value => value); Frm_login f_login = new Frm_login(); f_login.ShowDialog(); if (f_login.DialogResult == DialogResult.OK) //登录成功处理.......... { barStaticItem2.Caption = Envior.cur_userName; bs_version.Caption = AppInfo.AppVersion; f_login.Dispose(); //读取发票基础信息 this.ReadInvoiceBaseInfo(); } //连接打印进程 this.ConnectPrtServ(); //自动连接博思服务器 //string autoConnect = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath).AppSettings.Settings["ConnectFinInvoice"].Value.ToString(); //if (autoConnect == "1") FinInvoice.AutoConnectBosi(); //创建打印服务对象 //Envior.prtserv = new n_prtserv(); //读取 税务开票 APPID Envior.TAX_APPID = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath).AppSettings.Settings["APPID"].Value.ToString(); //读取 财政发票 开票点编码 Envior.FIN_BILL_SITE = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath).AppSettings.Settings["BILLSITE"].Value.ToString(); }
/// <summary> /// 检查版本号 /// </summary> /// <returns></returns> public static string getNewVersion() { return(SqlAssist.ExecuteScalar("select nvl(max(verId),'') from fv01", null).ToString()); }
static void Main() { try { bool bCreate; System.Threading.Mutex mutex = new System.Threading.Mutex(false, "SINGILE_INSTANCE_MUTEX", out bCreate); if (!bCreate) { MessageBox.Show("程序已经启动!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Application.Exit(); return; } //设置应用程序处理异常方式:ThreadException处理 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); //处理UI线程异常 Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); //处理非UI线程异常 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); #region 应用程序的主入口点 Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); BonusSkins.Register(); SkinManager.EnableFormSkins(); UserLookAndFeel.Default.SetSkinStyle("DevExpress Style"); ///// 连接数据库 ////// SqlAssist.ConnectDb(); ///// 检查版本 /////// //MessageBox.Show(AppInfo.AppVersion,"当前版本"); string curNewestVersion = Tools.getNewVersion(); //MessageBox.Show(curNewestVersion, "服务器版本"); if (string.Compare(curNewestVersion, AppInfo.AppVersion) > 0) { MessageBox.Show("服务器发现更新的版本!系统需要升级", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Tools.DownloadNew(curNewestVersion); SqlAssist.DisConnect(); //启动升级拷贝 ////// try { Process.Start("Upgrade.exe", curNewestVersion); } catch (Exception e) { Console.WriteLine(e.Message); } Application.Exit(); return; } /// 检查 工作站是否进行登记 Envior.WORKSTATIONID = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath).AppSettings.Settings["workstationID"].Value.ToString(); string hostname = string.Empty; string ipaddress = string.Empty; Tools.GetIpAddress(out hostname, out ipaddress); if (!string.IsNullOrEmpty(Envior.WORKSTATIONID)) { switch (AppAction.WorkStationIsRegistered(Envior.WORKSTATIONID, hostname, ipaddress)) { case 0: //未登记 MessageBox.Show("此工作站尚未登记!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; case 2: //主机名不符 MessageBox.Show("此工作站【计算机名称】与登记不符!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; case 3: //ip地址不符 MessageBox.Show("此工作站【IP地址】与登记不符!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; default: break; } } else { MessageBox.Show("未设置工作站ID!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop); Application.Exit(); return; } Application.Run(new MainForm()); #endregion } catch (Exception ex) { string str = GetExceptionMsg(ex, string.Empty); LogUtils.Error(str); MessageBox.Show(str, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 读取发票信息 /// </summary> private void ReadInvoiceBaseInfo() { OracleDataReader reader = SqlAssist.ExecuteReader("select * from sp01 where sp001 < '0000000100' "); if (reader.HasRows) { while (reader.Read()) { if (reader["SP002"].ToString() == "FIN_REGION_CODE") //财政发票-区划 { Envior.FIN_REGION_CODE = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "FIN_VERSION") //财政发票-接口版本 { Envior.FIN_VERSION = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "FIN_AGENCY_CODE") //财政发票-单位编码 { Envior.FIN_AGENCY_CODE = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "FIN_AGENCY_NAME") //财政发票-单位名称 { Envior.FIN_AGENCY_NAME = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "FIN_URL") //财政发票-服务url { Envior.FIN_URL = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "FIN_APPID") //财政发票-appid { Envior.FIN_APPID = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "FIN_APPKEY") //财政发票-appkey { Envior.FIN_APPKEY = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "FIN_BATCH_CODE") //财政发票-票据代码(以前的注册号) { Envior.FIN_BATCH_CODE = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "FIN_CODE") //财政发票-票据种类编码(以前的票据类型) { Envior.FIN_CODE = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "FIN_BILLNAME") //财政发票-票据名称 { Envior.FIN_BILLNAME = reader["SP005"].ToString(); } //税务发票信息 else if (reader["SP002"].ToString() == "tax_no") //纳税人识别号 { Envior.TAX_ID = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "tax_addrtele") //税票-销方地址电话 { Envior.TAX_ADDR_TELE = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "tax_bankaccount") //税票-销方银行账号 { Envior.TAX_BANK_ACCOUNT = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "tax_appid") //税票-应用账号 { Envior.TAX_APPID = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "tax_invoicetype") //税票-发票类型 { Envior.TAX_INVOICE_TYPE = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "tax_server_url") //税票-服务请求URL { Envior.TAX_SERVER_URL = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "tax_publickey") //税票-公钥 { Envior.TAX_PUBLIC_KEY = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "tax_privatekey") //税票-私钥 { Envior.TAX_PRIVATE_KEY = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "tax_cashier") //税票-收款人 { Envior.TAX_CASHIER = reader["SP005"].ToString(); } else if (reader["SP002"].ToString() == "tax_checker") //税票-复核人 { Envior.TAX_CHECKER = reader["SP005"].ToString(); } } } reader.Dispose(); }