| | |
| | | using System.ComponentModel; |
| | | using System.Data; |
| | | using System.Drawing; |
| | | using System.IO; |
| | | using System.Text; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace SCM.åæ®èµæ |
| | | namespace SCM |
| | | { |
| | | public partial class Gy_BarCodeMain : Form |
| | | { |
| | |
| | | } |
| | | public frmBillQueryCondition_Base frmCondition; |
| | | public string ViewName = "h_c_barcodemain"; |
| | | public string ModCaption = "æåååæ£éªæç»è¡¨"; |
| | | public string ModCaption = "æåååæ£éªæ±æ¥è¡¨"; |
| | | public const string ModName = "1250"; |
| | | public string sDlgWhere = ""; //å¤çªä½éå
¥ |
| | | public int selectRow = 0; |
| | |
| | | MessageBox.Show("å¼å§æ¶é´ä¸è½å¤§äºæªè³æ¶é´"); |
| | | return; |
| | | } |
| | | whereBuilder.Append($" and a.HMakeDate>''{dateTimePicker1.Text}'' and a.HMakeDate<''{dateTimePicker2.Text}''"); |
| | | whereBuilder.Append(" and a.FDATE>''" + dateTimePicker1.Text+ "'' and a.FDATE<''" + dateTimePicker2.Text+" 23:59:59''"); |
| | | if (!string.IsNullOrEmpty(txtHBillNo.Text)) |
| | | whereBuilder.Append($" and a.HSourceBillNo like ''%{txtHBillNo.Text}%''"); |
| | | whereBuilder.Append(" and a.FBILLNO like ''%" + txtHBillNo.Text+"%''"); |
| | | if (!string.IsNullOrEmpty(textBox1.Text)) |
| | | whereBuilder.Append($" and a.b.FNUMBER like ''%{textBox1.Text}%''"); |
| | | whereBuilder.Append(" and e.FNUMBER like ''%"+textBox1.Text+"%''"); |
| | | if (!string.IsNullOrEmpty(textBox2.Text)) |
| | | whereBuilder.Append($" and a.HMaterName like ''%{textBox2.Text}%''"); |
| | | var execSql = $"exec {ViewName} '{whereBuilder}'"; |
| | | whereBuilder.Append(" and c.HMaterName like ''%"+textBox2.Text+"%''"); |
| | | var execSql = "exec "+ViewName+" '"+whereBuilder+"'"; |
| | | DataSet DSet = oWeb.getDataSetBySQL(execSql, ViewName, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | //çæé¦è¡æ é¢ |
| | | if (DSet == null) |
| | |
| | | // |
| | | grdMain.DataSource = DSet.Tables[0].DefaultView; |
| | | } |
| | | /// <summary> |
| | | /// ç½æ ¼ 导åºEXCEL ç½æ ¼ï¼æä»¶åï¼æ é¢å |
| | | /// </summary> |
| | | public static void DataGridViewToExcel2(DataGridView grdMain, string sText, string sBTText) |
| | | { |
| | | SaveFileDialog saveFileDialog = new SaveFileDialog(); |
| | | saveFileDialog.Filter = "Execlæä»¶(*.xls)|*.xls"; |
| | | saveFileDialog.FilterIndex = 0; |
| | | saveFileDialog.RestoreDirectory = true; |
| | | saveFileDialog.CreatePrompt = true; |
| | | saveFileDialog.Title = "æ°æ®è§å¾å¯¼åºEXCELæä»¶"; |
| | | saveFileDialog.FileName = sText; |
| | | //saveFileDialog.ShowDialog(); |
| | | if (saveFileDialog.ShowDialog() == DialogResult.OK) |
| | | { |
| | | Stream myStream; |
| | | myStream = saveFileDialog.OpenFile(); |
| | | StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding("gb2312")); |
| | | string str = ""; |
| | | DateTime start = DateTime.Now; |
| | | try |
| | | { |
| | | if (sBTText != "") |
| | | { |
| | | sw.WriteLine(sBTText); |
| | | } |
| | | //åæ é¢ |
| | | bool sFirstCol = true; |
| | | for (int i = 0; i < grdMain.ColumnCount; i++) |
| | | { |
| | | if (i > 0 && grdMain.Columns[i].HeaderText.Substring(0, 1) != "h" && grdMain.Columns[i].HeaderText.Substring(0, 1) != "H" && sFirstCol != true) |
| | | { |
| | | str += "\t"; |
| | | } |
| | | if (grdMain.Columns[i].HeaderText.Substring(0, 1) != "h" && grdMain.Columns[i].HeaderText.Substring(0, 1) != "H") |
| | | { |
| | | sFirstCol = false; |
| | | str += grdMain.Columns[i].HeaderText; |
| | | } |
| | | } |
| | | str = str.Replace("\n", ""); |
| | | sw.WriteLine(str); |
| | | |
| | | //åå
容 |
| | | for (int j = 0; j < grdMain.Rows.Count; j++) |
| | | { |
| | | string tempStr = ""; |
| | | sFirstCol = true; |
| | | for (int k = 0; k < grdMain.Columns.Count; k++) |
| | | { |
| | | if (k > 0 && grdMain.Columns[k].HeaderText.Substring(0, 1) != "h" && grdMain.Columns[k].HeaderText.Substring(0, 1) != "H" && sFirstCol != true) |
| | | { |
| | | tempStr += "\t"; |
| | | } |
| | | if (grdMain.Columns[k].HeaderText.Substring(0, 1) != "h" && grdMain.Columns[k].HeaderText.Substring(0, 1) != "H") |
| | | { |
| | | sFirstCol = false; |
| | | if (grdMain.Rows[j].Cells[k].Value == null) |
| | | { |
| | | tempStr += string.Empty; |
| | | } |
| | | else |
| | | { |
| | | tempStr += grdMain.Rows[j].Cells[k].Value.ToString(); |
| | | } |
| | | } |
| | | } |
| | | tempStr = tempStr.Replace("\n", ""); |
| | | sw.WriteLine(tempStr); |
| | | } |
| | | sw.Close(); |
| | | myStream.Close(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | sw.Close(); |
| | | myStream.Close(); |
| | | } |
| | | MessageBox.Show("å°æ¤å·¥ä½è¡¨å¯¼åºä¸ºexcelå
±èæ¶ï¼" + DateTime.Now.Subtract(start).TotalMilliseconds.ToString() + "毫ç§"); |
| | | } |
| | | } |
| | | private void tc_Click(object sender, EventArgs e) |
| | | { |
| | | this.Close(); |
| | | } |
| | | |
| | | private void yl_Click(object sender, EventArgs e) |
| | | { |
| | | DataGridViewToExcel2(grdMain, this.Text, this.Text); |
| | | } |
| | | } |
| | | } |