📄 stocklist.cs
字号:
this.menuItem5.Text = "-";
//
// menuItem7
//
this.menuItem7.Index = 5;
this.menuItem7.Text = "-";
//
// menuItem8
//
this.menuItem8.Index = 6;
this.menuItem8.Text = "刷新全部信息";
this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
//
// button5
//
this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button5.Location = new System.Drawing.Point(496, 336);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(64, 23);
this.button5.TabIndex = 13;
this.button5.Text = "刷 新";
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button6
//
this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button6.Location = new System.Drawing.Point(432, 336);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(64, 23);
this.button6.TabIndex = 14;
this.button6.Text = "新 建";
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// StockList
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(624, 365);
this.Controls.Add(this.button6);
this.Controls.Add(this.button5);
this.Controls.Add(this.label2);
this.Controls.Add(this.button3);
this.Controls.Add(this.button4);
this.Controls.Add(this.list);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Controls.Add(this.button2);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "StockList";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "采购单资料";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
((System.ComponentModel.ISupportInitialize)(this.list)).EndInit();
this.ResumeLayout(false);
}
#endregion
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 = "签约日期,供货商名称,对方联系人,电话,手机,经办人,总金额";
this.rd.GridTotalFields = "总金额";
this.rd.GridSumFields = "总金额";
this.rd.PageSubTitle = "采购单";
this.rd.GridSelectStyle = "合同编号.Align=居中,签约日期.Align=居中,对方联系人.Align=居中,经办人.Align=居中,电话.Align=居中,手机.Align=居中";
}else{
this.rd.GridPrintFields = "订购日期,"+ _tjCorp +"规格,品名,数量,单位,单价,总额,备注";
this.rd.GridTotalFields = "总额";
this.rd.GridSumFields = "总额";
this.rd.PageSubTitle = "采购明细表";
this.rd.GridSelectStyle = "订购日期.Align=居中,品名.Align=居中,规格.Align=居中,单位.Align=居中,单价.Width=20,数量.Width=100";
}
//每页小计
//this.rd.GridIsPageTotal = true;
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){
StockList sl = null;
EditOrder eo = new EditOrder(sl);
eo.SetAutoID(this.autoID);
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 StockOrder 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 StockList where stockSign = '"+ _sign +"'";
OleDbCommand cmd = new OleDbCommand(sql,Public.conn);
Public.CloseConn();
Public.conn.Open();
cmd.ExecuteNonQuery();
Public.conn.Close();
sql = "delete from StockOrder where autoID=" + this.autoID;
cmd = new OleDbCommand(sql,Public.conn);
Public.CloseConn();
Public.conn.Open();
cmd.ExecuteNonQuery();
Public.conn.Close();
this.LoadList();
}
}catch(Exception ex){
MessageBox.Show(ex.Message.ToString());
return;
}
}
/// <summary>
/// 查看供货商信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem4_Click(object sender, System.EventArgs e) {
if(this.autoID != null && this.ds != null){
for(int i=0;i<ds.Tables[0].Rows.Count;i++){
DataRow row = ds.Tables[0].Rows[i];
if(row["系统编号"].ToString().Equals(this.autoID)){
string _corSign = row["供货商编号"].ToString();
try{
string sql = "select * from CorpColl where comType='STOCK' and sign='"+ _corSign +"'";
OleDbDataAdapter adp = new OleDbDataAdapter(sql,Public.conn);
DataSet _cor = new DataSet();
adp.Fill(_cor,"cor");
if(_cor != null && _cor.Tables[0].Rows.Count > 0){
DataRow _row = _cor.Tables[0].Rows[0];
string _autoID = _row["autoID"].ToString();
Eboer.MIS.MF.WinForm.EditCustomer ec = new EditCustomer(null);
ec.SetAutoID(_autoID);
ec.ShowDialog();
}else{
MessageBox.Show("数据库中找不到相应的供货商资料,可能已被删除或更改了手工编号!");
}
}catch(Exception ex){
MessageBox.Show(ex.Message.ToString());
return;
}
}
}
}
}
/// <summary>
/// 打印选中
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem6_Click(object sender, System.EventArgs e) {
if(this.autoID != null){
StockList sl = null;
EditOrder eo = new EditOrder(sl);
eo.SetAutoID(this.autoID);
eo.button4_Click(null,null);
}else{
MessageBox.Show("没有选中的数据,不能继续!");
return;
}
}
/// <summary>
/// 刷新全部
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem8_Click(object sender, System.EventArgs e) {
this.LoadList();
}
/// <summary>
/// 事件一
/// </summary>
private void ClickInDG(object sender,MouseEventArgs e){
try{
if(this.currentIndex != -1) this.list.UnSelect(this.currentIndex);
Point p = new Point(e.X,e.Y);
DataGrid.HitTestInfo hti = this.list.HitTest(p);
if(hti.Type == DataGrid.HitTestType.Cell){
this.list.CurrentCell = new DataGridCell(hti.Row,hti.Column);
this.list.Select(hti.Row);
this.currentIndex = hti.Row;
if(this.list.CurrentCell.RowNumber < this.ds.Tables[0].Rows.Count + 1){
string xuhao = this.list[this.list.CurrentCell.RowNumber,0].ToString();
if(xuhao != null && xuhao != "" && xuhao != "null"){
try{
this.autoID = xuhao;
}catch{
this.autoID = null;
}
}
}else{
if(this.currentIndex != -1){
this.list.UnSelect(this.currentIndex);
this.currentIndex = -1;
}
this.autoID = null;
}
}else this.autoID = null;
//如果相等,则表示选中的是空行
if(this.currentIndex == ((DataTable)this.list.DataSource).Rows.Count){
this.autoID = null;
this.currentIndex = -1;
}
if(this.autoID != null){
this.menuItem1.Enabled = true;
this.menuItem2.Enabled = true;
this.menuItem4.Enabled = true;
//this.menuItem6.Enabled = true;
}else{
this.menuItem1.Enabled = false;
this.menuItem2.Enabled = false;
this.menuItem4.Enabled = false;
//this.menuItem6.Enabled = false;
}
//MessageBox.Show("当前选中:" + this.currentIndex.ToString() + ",当前autoID="+ this.autoID +",共有"+ ((DataTable)this.list.DataSource).Rows.Count.ToString() +"条记录。");
}catch{}
}
/// <summary>
/// 事件二
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void UPInDG(object sender,MouseEventArgs e){
if(this.autoID != null){
this.menuItem1.Enabled = true;
this.menuItem2.Enabled = true;
this.menuItem4.Enabled = true;
//this.menuItem6.Enabled = true;
}else{
this.menuItem1.Enabled = false;
this.menuItem2.Enabled = false;
this.menuItem4.Enabled = false;
//this.menuItem6.Enabled = false;
}
}
private void button5_Click(object sender, System.EventArgs e) {
this.LoadList();
}
public void button6_Click(object sender, System.EventArgs e) {
EditOrder eo = new EditOrder(this);
eo.sign.Enabled = true;
eo.LoadItemCol();
eo.sign.Text = Public.GetNewInfoID("StockOrder","soSign");
eo.SetPackSign();
eo._sl = this;
eo.Show();
}
/// <summary>
/// 设置网格的一些样式,使在双击第一列的时候可以弹出修改或二级查询窗口
/// </summary>
private void GridStyle(){
for(int i=0;i<this.list.TableStyles[0].GridColumnStyles.Count;i++){
((DataGridTextBoxColumn)this.list.TableStyles[0].GridColumnStyles[i]).TextBox.DoubleClick += new EventHandler(this.DoubleClickForGridFirstCol);
((DataGridTextBoxColumn)this.list.TableStyles[0].GridColumnStyles[i]).TextBox.MouseMove += new MouseEventHandler(this.IsHand);
((DataGridTextBoxColumn)this.list.TableStyles[0].GridColumnStyles[i]).TextBox.MouseLeave += new EventHandler(this.NoHand);
}
}
//双击网络第一列时发生
private void DoubleClickForGridFirstCol(object sender,EventArgs e){
if(((DataTable)this.list.DataSource).Rows.Count > 0 && this.viewType == "ITEM"){
if(this.list.CurrentCell.ColumnNumber == 0){ //查看相同条件某同一日期的数据
StockList list = new StockList();
//条件相等
list.corpSign = this.corpSign; //客户编号
list.corpName = this.corpName; //客户名称
list.startDate = this.list[this.list.CurrentRowIndex,0].ToString().Replace(" 0:00:00",""); //起始时间
list.endDate = this.list[this.list.CurrentRowIndex,0].ToString().Replace(" 0:00:00",""); //结束时间
list.timeType = this.timeType; //时间类型,默认为签约
list.proSign = this.proSign; //产品编号
list.proName = this.proName; //产品名称
list.executeEr = this.executeEr; //经办人
list.djhm = this.djhm; //单据号码
list.viewType = this.viewType; //显示方式,默认列表,否则为明细
list.ListInit();
list.Show();
}
}else{
//修改当前信息
this.menuItem1_Click(sender,e);
}
}
private void IsHand(object sender,MouseEventArgs e){
this.ChangeCursor(true);
}
private void NoHand(object sender,EventArgs e){
this.ChangeCursor(false);
}
private void ChangeCursor(bool IS){
if(IS){
this.Cursor = Cursors.Hand;
}else{
this.Cursor = Cursors.Arrow;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -