📄 orderlist.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.Sell
{
/// <summary>
/// OrderList 的摘要说明。
/// </summary>
public class OrderList : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.DataGrid list;
private System.Windows.Forms.ContextMenu contextMenu;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem8;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
/// <summary>
/// 数据源
/// </summary>
private DataSet ds = null;
/// <summary>
/// 当前选中的行中相应的编号
/// </summary>
private string autoID = null;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private int currentIndex = -1;
//查询条件 ===================================
public string corpSign = null; //客户编号
public string corpName = null; //客户名称
public string startDate = null; //起始时间
public string endDate = null; //结束时间
public string timeType = "JY"; //时间类型,默认为签约
public string proSign = null; //产品编号
public string proName = null; //产品名称
public string executeEr = null; //经办人
public string djhm = null; //单据号码
public string viewType = "LIST"; //显示方式,默认列表,否则为明细
public string areaName = null;
public string tjStr = "NULL";
private ReportLibrary.ReportDocument rd = null;
public OrderList()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//两个事件
this.list.MouseDown += new MouseEventHandler(this.ClickInDG);
this.list.MouseUp += new MouseEventHandler(this.UPInDG);
}
public void ListInit(){
this.tjStr = null;
this.LoadList();
Public.SizeColumnsToContent(this.list,-1,this.ds.Tables[0],new string[]{"系统编号","信息编号","订货商编号"});
this.GridStyle();
}
public void LoadList(){
if(this.viewType == "LIST"){
this.GetListForList();
}else{
this.Text = "销售明细";
this.list.ContextMenu = null;
this.GetListForItem();
}
//去掉空行
((DataTable)this.list.DataSource).DefaultView.AllowNew = false;
//隐藏编号列
//DataGridTableStyle dataGridTableTargetStyle = new DataGridTableStyle();
//DataGridTextBoxColumn dataGridTextBoxColumn = null;
//dataGridTextBoxColumn = new DataGridTextBoxColumn();
//dataGridTextBoxColumn.MappingName = "订货商编号";
//dataGridTextBoxColumn.HeaderText = "订货商编号";
//dataGridTextBoxColumn.Width = 0;
//dataGridTableTargetStyle.GridColumnStyles.Add(dataGridTextBoxColumn);
//this.list.TableStyles[this.ds.Tables[0].TableName].GridColumnStyles.Add(dataGridTextBoxColumn);
//this.list.TableStyles.Add(dataGridTableTargetStyle);
}
/// <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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(OrderList));
this.label2 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.list = new System.Windows.Forms.DataGrid();
this.contextMenu = new System.Windows.Forms.ContextMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.list)).BeginInit();
this.SuspendLayout();
//
// label2
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label2.Location = new System.Drawing.Point(0, 353);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(176, 16);
this.label2.TabIndex = 16;
this.label2.Text = "共有数据:";
//
// button3
//
this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button3.Location = new System.Drawing.Point(328, 352);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(88, 23);
this.button3.TabIndex = 15;
this.button3.Text = "综合查询";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button4.Location = new System.Drawing.Point(544, 352);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(64, 23);
this.button4.TabIndex = 14;
this.button4.Text = "打 印";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// list
//
this.list.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.list.CaptionVisible = false;
this.list.ContextMenu = this.contextMenu;
this.list.DataMember = "";
this.list.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.list.Location = new System.Drawing.Point(0, 11);
this.list.Name = "list";
this.list.ParentRowsVisible = false;
this.list.PreferredRowHeight = 22;
this.list.Size = new System.Drawing.Size(616, 328);
this.list.TabIndex = 13;
this.list.DoubleClick += new System.EventHandler(this.list_DoubleClick);
this.list.Navigate += new System.Windows.Forms.NavigateEventHandler(this.list_Navigate);
this.list.CurrentCellChanged += new System.EventHandler(this.list_CurrentCellChanged);
//
// contextMenu
//
this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem2,
this.menuItem3,
this.menuItem4,
this.menuItem8});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.Text = "修改选中信息";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuItem2.Text = "删除选中信息";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuItem3
//
this.menuItem3.Index = 2;
this.menuItem3.Text = "-";
//
// menuItem4
//
this.menuItem4.Index = 3;
this.menuItem4.Text = "查看订货商信息";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// menuItem8
//
this.menuItem8.Index = 4;
this.menuItem8.Text = "刷新全部信息";
this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(480, 352);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(64, 23);
this.button1.TabIndex = 17;
this.button1.Text = "刷 新";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button2.Location = new System.Drawing.Point(416, 352);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(64, 23);
this.button2.TabIndex = 18;
this.button2.Text = "新 建";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// OrderList
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(616, 381);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label2);
this.Controls.Add(this.button3);
this.Controls.Add(this.button4);
this.Controls.Add(this.list);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "OrderList";
this.Text = "销售单资料";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
((System.ComponentModel.ISupportInitialize)(this.list)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 综合查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, System.EventArgs e) {
SearchForm sf = new SearchForm();
sf.ShowDialog();
}
/// <summary>
/// 打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button4_Click(object sender, System.EventArgs e) {
this.rd = new ReportLibrary.ReportDocument(((DataTable)this.list.DataSource));
this.rd.RestoreProperty("SystemID=0SystemName=ReportID=0ReportCode=ReportName=ReportType=ReportMemo=PageTitle=PageSubTitle=PageHeader=PageFooter=GridPrintWhere=GridSelectStyle=GridPrintFields=GridTotalFields=GridChineseField=GridSortFields=GridPaginationFields=GridStatisticsFields=GridSumFields=GridRowToColFields=PdPropertys=PrinterName=EPSON LQ-1600KIIIPaperName=A4PaperWidth=827PaperHeight=1169PaperIsLandscape=falsePaperMargin.Left=30PaperMargin.Right=51PaperMargin.Top=51PaperMargin.Bottom=31");
this.rd.GridIsFillblank = false;
this.rd.PaperFooterIsNearGrid = true;
this.rd.PaperCols = 1;
this.rd.FontHeader = new Font("宋体",10F);
this.rd.FontGrid = new Font("宋体",10F);
this.rd.FontFooter = new Font("宋体",10F);
//增加打印序号
this.rd.GridIsRowAutoNumber = true;
//页头
this.rd.PageHeader = "{ }" + Public.PrintHeader(this.tjStr);;
//页脚
this.rd.PageFooter = "{制表时间:"+ DateTime.Now.ToString() +"}";
string _tjCorp = null;
if(this.corpSign == null || this.corpSign.Trim() == ""){
_tjCorp="客户名称,";
}
//string _tjDJ = null;
//if(this.djhm == null || this.djhm.Trim() == "") _tjDJ = "单据编号,";
if(this.viewType == "LIST"){
this.rd.GridPrintFields = "签约日期,"+ _tjCorp +"对方联系人,电话,手机,经办人,总金额";
this.rd.GridTotalFields = "总金额";
this.rd.PageSubTitle = "销售单";
this.rd.GridSelectStyle = "合同编号.Align=居中,签约日期.Align=居中,对方联系人.Align=居中,经办人.Align=居中,电话.Align=居中,手机.Align=居中";
}else{
this.rd.GridPrintFields = "订购日期,"+ _tjCorp +"规格,品名,数量,单位,单价,总额,备注";
this.rd.GridTotalFields = "总额";
this.rd.PageSubTitle = "销售明细表";
this.rd.GridSelectStyle = "订购日期.Align=居中,品名.Align=居中,规格.Align=居中,单位.Align=居中";
}
this.rd.PageTitle = Public.publicCorp;
this.rd.PageImage = Public.lyLogo;
this.rd.FontTitle = new Font("黑体",20F,FontStyle.Bold);
this.rd.FontSubTitle = new Font("黑体",20F);
this.rd.SetPageFooterFont = new Font("宋体",10F);
this.rd.SetPageFooterString = Public.GetPrintFooter();
rd.PrintPreview();
}
/// <summary>
/// 删除选中
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem1_Click(object sender, System.EventArgs e) {
if(this.autoID != null){
OrderList ol = null;
EditOrder eo = new EditOrder(ol);
eo.SetAutoID(this.autoID);
eo._ol = this;
eo.ShowDialog();
this.LoadList();
}else{
MessageBox.Show("没有选中的数据,不能继续!");
return;
}
}
/// <summary>
/// 删除选中
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem2_Click(object sender, System.EventArgs e) {
//try{
if(this.autoID != null && MessageBox.Show("删除后不可恢复,确定删除吗?","删除确认",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) == DialogResult.OK){
string _sign = "";
string sql = "select * from SellOrder where autoID = " + this.autoID;
OleDbDataAdapter ad = new OleDbDataAdapter(sql,Public.conn);
DataSet ds = new DataSet();
ad.Fill(ds,"list");
if(ds != null && ds.Tables[0].Rows.Count > 0){
_sign = ds.Tables[0].Rows[0]["soSign"].ToString();
}else{
MessageBox.Show("找不到需要删除的信息!");
return;
}
//先删除明细
sql = "delete from SellList where sellSign = '"+ _sign +"'";
OleDbCommand cmd = new OleDbCommand(sql,Public.conn);
Public.CloseConn();
Public.conn.Open();
cmd.ExecuteNonQuery();
Public.conn.Close();
//
sql = "delete from SellOrder where autoID=" + this.autoID;
cmd = new OleDbCommand(sql,Public.conn);
Public.CloseConn();
Public.conn.Open();
cmd.ExecuteNonQuery();
Public.conn.Close();
this.LoadList();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -