📄 printset.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
namespace Eboer.MIS.MF.WinForm
{
/// <summary>
/// PrintSet 的摘要说明。
/// </summary>
public class PrintSet : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.ComboBox corp;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public PrintSet()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
this.LoadSelfCorp();
}
/// <summary>
/// 本单位
/// </summary>
private void LoadSelfCorp(){
try{
string sql = "select * from CorpColl where comType = 'SELF'";
OleDbDataAdapter ad = new OleDbDataAdapter(sql,Public.conn);
DataSet ds = new DataSet();
ad.Fill(ds,"corp");
for(int i=0;i<ds.Tables[0].Rows.Count;i++){
DataRow row = ds.Tables[0].Rows[i];
this.corp.Items.Add(row["corName"].ToString() + "("+ row["sign"].ToString() +")");
if(Public.currentSelfCorp.Equals(row["sign"].ToString())){
this.corp.Text = row["corName"].ToString() + "("+ row["sign"].ToString() +")";
}
}
}catch(Exception ex){
MessageBox.Show(ex.Message.ToString());
//
}
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.corp = new System.Windows.Forms.ComboBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.corp);
this.groupBox1.Location = new System.Drawing.Point(8, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(384, 56);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "联系方式采用";
//
// button1
//
this.button1.Location = new System.Drawing.Point(264, 72);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(64, 23);
this.button1.TabIndex = 1;
this.button1.Text = "确 定";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(328, 72);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(64, 23);
this.button2.TabIndex = 2;
this.button2.Text = "取 消";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// corp
//
this.corp.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.corp.Location = new System.Drawing.Point(16, 24);
this.corp.Name = "corp";
this.corp.Size = new System.Drawing.Size(352, 20);
this.corp.TabIndex = 1;
//
// PrintSet
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(402, 111);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "PrintSet";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "打印设置";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void button2_Click(object sender, System.EventArgs e) {
this.Close();
}
private void textBox3_TextChanged(object sender, System.EventArgs e) {
}
/// <summary>
/// 保存页脚打印信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, System.EventArgs e) {
//默认我单位
Public.currentSelfCorp = Public.CutCorString(this.corp.Text,1);
//设置页脚联系方式
try{
string sql = "select * from CorpColl where comType='SELF' and sign='" + Public.CutCorString(this.corp.Text,1) + "'";
OleDbDataAdapter adp = new OleDbDataAdapter(sql,Public.conn);
DataSet ds = new DataSet();
adp.Fill(ds,"info");
if(ds == null || ds.Tables[0].Rows.Count == 0){
MessageBox.Show("找不到相应的单位资料,检查是否被删除或更改了手工编号!");
return;
}else{
DataRow row = ds.Tables[0].Rows[0];
Public.publicCorp = Public.CutCorString(this.corp.Text,0);
Public.publicAddress = row["address"].ToString();
Public.publicFax = row["fax"].ToString();
Public.publicTel = row["tel"].ToString();
if(Public.publicCorp.Length <= 9){
Public.publicCorp = Public.SpaceForString(Public.publicCorp," ");
}
}
}catch(Exception ex){
MessageBox.Show("设置页脚联系方式时出错:" + ex.Message.ToString());
return;
}
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -