Esempio n. 1
0
 private void btnNullPrint_Click(object sender, EventArgs e)
 {
     FrmPrintSendList list = new FrmPrintSendList();
     Sql2KDataAccess access = new Sql2KDataAccess();
     DataSet set = access.Run_SqlText("select Code,CodeName from V_Depart");
     list.combPlanDepart.DataSource = set.Tables[0].DefaultView;
     list.combPlanDepart.DisplayMember = "CodeName";
     list.combPlanDepart.ValueMember = "CodeName";
     list.combPlanDepart.Refresh();
     set = access.Run_SqlText("select Code,CodeName from V_nptype");
     DataGridViewComboBoxColumn column = (DataGridViewComboBoxColumn) list.GridVwSendInfo.Columns[1];
     column.DataSource = set.Tables[0].DefaultView;
     column.DisplayMember = "codename";
     column.ValueMember = "codename";
     list.IsPreview = this.cbx_PrintSendView.Checked;
     list.ShowDialog();
 }
Esempio n. 2
0
 private void btn_RePrintSend_Click(object sender, EventArgs e)
 {
     if ((this.dgv_Send.SelectedCells.Count > 0) && (this.dgv_Send.SelectedCells[0].ColumnIndex == 0))
     {
         Sql2KDataAccess access = new Sql2KDataAccess();
         string queryStr = "select * from V_SendList Where SendId='" + this.dgv_Send.SelectedCells[0].Value.ToString().Trim() + "'";
         this.SendListds = access.Run_SqlText(queryStr);
         if ((this.SendListds != null) && (this.SendListds.Tables[0].Rows.Count != 0))
         {
             queryStr = "select t_np.npno,v_nptype.codename,taskid from T_NP,v_nptype Where t_np.nptype=v_nptype.code and  SendId='" + this.dgv_Send.SelectedCells[0].Value.ToString().Trim() + "' order by taskid";
             this.SendListDetailsds = access.Run_SqlText(queryStr);
             if ((this.SendListDetailsds != null) && (this.SendListDetailsds.Tables[0].Rows.Count != 0))
             {
                 PrintDocument document = new PrintDocument();
                 PrintPreviewDialog dialog = new PrintPreviewDialog();
                 document.PrintPage += new PrintPageEventHandler(this.Pd_PrintPageSendDetails);
                 dialog.Document = document;
                 this.DetailPrintPage = 0;
                 try
                 {
                     dialog.WindowState = FormWindowState.Maximized;
                     document.PrinterSettings.PrinterName = Invoice.GetSendListPrinter();
                     if (this.cbx_PrintSendView.Checked)
                     {
                         dialog.ShowDialog();
                     }
                     else
                     {
                         document.Print();
                     }
                 }
                 catch (Exception exception)
                 {
                     MessageBox.Show("打印时发生错误" + '\n' + exception.Message, "打印送货单明细", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
                 FrmPrintSendList list = new FrmPrintSendList {
                     IsPreview = this.cbx_PrintSendView.Checked,
                     labelMakeperson = { Text = "制表人 " + this.SendListds.Tables[0].Rows[0]["truename"].ToString() },
                     labelMakeTime = { Text = "制表时间 " + this.SendListds.Tables[0].Rows[0]["sendtime"].ToString() },
                     textPlanID = { Text = this.SendListds.Tables[0].Rows[0]["planid"].ToString() },
                     combPlanDepart = { Text = this.SendListds.Tables[0].Rows[0]["plandepart"].ToString() },
                     textSendID = { Text = this.SendListds.Tables[0].Rows[0]["sendid"].ToString() },
                     textSendPerson = { Text = "" },
                     textRemark = { Text = "" }
                 };
                 queryStr = "select * from V_List Where SendId='" + this.dgv_Send.SelectedCells[0].Value.ToString().Trim() + "'";
                 DataSet set = access.Run_SqlText(queryStr);
                 if ((set != null) && (set.Tables[0].Rows.Count != 0))
                 {
                     int num = 0;
                     for (int i = 0; i < set.Tables[0].Rows.Count; i++)
                     {
                         list.GridVwSendInfo.Rows.Add();
                         list.GridVwSendInfo.Rows[list.GridVwSendInfo.NewRowIndex - 1].Cells[0].Value = Convert.ToString((int) (i + 1));
                         DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell) list.GridVwSendInfo.Rows[list.GridVwSendInfo.NewRowIndex - 1].Cells[1];
                         cell.Value = set.Tables[0].Rows[i]["codename"].ToString();
                         list.GridVwSendInfo.Rows[list.GridVwSendInfo.NewRowIndex - 1].Cells[2].Value = set.Tables[0].Rows[i]["totalnum"].ToString();
                         num += int.Parse(set.Tables[0].Rows[i]["totalnum"].ToString());
                     }
                     list.labelTotal.Text = "总计" + num.ToString();
                     list.ShowDialog();
                 }
             }
         }
     }
 }
Esempio n. 3
0
 private void btn_Print_Click(object sender, EventArgs e)
 {
     if (this.Lvw_SendList.CheckedItems.Count == 0)
     {
         MessageBox.Show("请选择要打印的送货单", "出库管理", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else
     {
         foreach (ListViewItem item in this.Lvw_SendList.Items)
         {
             if (!item.Checked)
             {
                 continue;
             }
             this.LVICurPrint = item;
             Sql2KDataAccess access = new Sql2KDataAccess();
             string queryStr = "select * from V_SendList Where SendId='" + this.LVICurPrint.Text.Trim() + "'";
             this.SendListds = access.Run_SqlText(queryStr);
             if ((this.SendListds == null) || (this.SendListds.Tables[0].Rows.Count == 0))
             {
                 break;
             }
             queryStr = "select t_np.npno,v_nptype.codename,taskid from T_NP,v_nptype Where t_np.nptype=v_nptype.code and  SendId='" + this.LVICurPrint.Text.Trim() + "' order by taskid";
             this.SendListDetailsds = access.Run_SqlText(queryStr);
             if ((this.SendListDetailsds == null) || (this.SendListDetailsds.Tables[0].Rows.Count == 0))
             {
                 break;
             }
             PrintDocument document = new PrintDocument();
             PrintPreviewDialog dialog = new PrintPreviewDialog();
             this.DetailPrintPage = 0;
             document.PrintPage += new PrintPageEventHandler(this.Pd_PrintPageSendDetails);
             dialog.Document = document;
             this.DetailPrintPage = 0;
             try
             {
                 dialog.WindowState = FormWindowState.Maximized;
                 document.PrinterSettings.PrinterName = Invoice.GetSendListPrinter();
                 if (this.cbx_PrintSendView.Checked)
                 {
                     dialog.ShowDialog();
                 }
                 else
                 {
                     document.Print();
                 }
             }
             catch (Exception exception)
             {
                 MessageBox.Show("打印时发生错误" + '\n' + exception.Message, "打印送货单名细", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
             FrmPrintSendList list = new FrmPrintSendList {
                 IsPreview = this.cbx_PrintSendView.Checked
             };
             DataSet set = access.Run_SqlText("select Code,CodeName from V_Depart");
             list.combPlanDepart.DataSource = set.Tables[0].DefaultView;
             list.combPlanDepart.DisplayMember = "CodeName";
             list.combPlanDepart.ValueMember = "CodeName";
             list.combPlanDepart.Refresh();
             set = access.Run_SqlText("select Code,CodeName from V_nptype");
             DataGridViewComboBoxColumn column = (DataGridViewComboBoxColumn) list.GridVwSendInfo.Columns[1];
             column.DataSource = set.Tables[0].DefaultView;
             column.DisplayMember = "codename";
             column.ValueMember = "codename";
             list.labelMakeperson.Text = "制表人 " + this.SendListds.Tables[0].Rows[0]["truename"].ToString();
             list.labelMakeTime.Text = "制表时间 " + this.SendListds.Tables[0].Rows[0]["sendtime"].ToString();
             list.textPlanID.Text = this.SendListds.Tables[0].Rows[0]["planid"].ToString();
             list.combPlanDepart.Text = this.SendListds.Tables[0].Rows[0]["plandepart"].ToString();
             list.textSendID.Text = this.SendListds.Tables[0].Rows[0]["sendid"].ToString();
             queryStr = "select * from V_List Where SendId='" + this.LVICurPrint.Text.Trim() + "'";
             DataSet set2 = access.Run_SqlText(queryStr);
             if ((set2 == null) || (set2.Tables[0].Rows.Count == 0))
             {
                 break;
             }
             int num = 0;
             for (int i = 0; i < set2.Tables[0].Rows.Count; i++)
             {
                 list.GridVwSendInfo.Rows.Add();
                 list.GridVwSendInfo.Rows[list.GridVwSendInfo.NewRowIndex - 1].Cells[0].Value = Convert.ToString((int) (i + 1));
                 DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell) list.GridVwSendInfo.Rows[list.GridVwSendInfo.NewRowIndex - 1].Cells[1];
                 cell.Value = set2.Tables[0].Rows[i]["codename"].ToString();
                 list.GridVwSendInfo.Rows[list.GridVwSendInfo.NewRowIndex - 1].Cells[2].Value = set2.Tables[0].Rows[i]["totalnum"].ToString();
                 num += int.Parse(set2.Tables[0].Rows[i]["totalnum"].ToString());
             }
             list.labelTotal.Text = "总计" + num.ToString();
             list.ShowDialog();
         }
     }
 }