Esempio n. 1
0
        /// <summary>
        /// OEM销售成绩表
        /// </summary>
        private void ExportOEMSales()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("No");
            dt.Columns.Add("ORDER_SLIP_DATE");
            dt.Columns.Add("RECEIPT_SLIP_DATE");
            dt.Columns.Add("MACHINE_CODE");
            dt.Columns.Add("MACHINE_NAME");
            dt.Columns.Add("CHECK_NUMBER");
            dt.Columns.Add("CHECK_DATE");
            dt.Columns.Add("CUSTOMER_NAME");
            dt.Columns.Add("ENDER_CUSTOMER_NAME");
            dt.Columns.Add("ADDRESS");
            dt.Columns.Add("ADDRESS2");
            string where = GetOEMSalesConduction();

            DataTable salesTable = bInvoice.GetSalesProductInfo(where).Tables[0];
            DataRow   dr         = null;
            int       i          = 0;

            foreach (DataRow row in salesTable.Rows)
            {
                dr       = dt.NewRow();
                dr["No"] = i.ToString();
                dr["ORDER_SLIP_DATE"]     = row["SLIP_DATE"];
                dr["RECEIPT_SLIP_DATE"]   = row["CREATE_DATE_TIME"];
                dr["MACHINE_CODE"]        = row["SERIAL_NUMBER"];
                dr["MACHINE_NAME"]        = row["MACHINE_NAME"];
                dr["CHECK_NUMBER"]        = row["CHECK_NUMBER"];
                dr["CHECK_DATE"]          = row["CHECK_DATE"];
                dr["CUSTOMER_NAME"]       = row["CUSTOMER_NAME"];
                dr["ENDER_CUSTOMER_NAME"] = row["END_CUSTOMER_NAME"];
                dr["ADDRESS"]             = row["ADDRESS"];
                dr["ADDRESS2"]            = row["ADDRESS"];
                i++;
                dt.Rows.Add(dr);
            }

            Hashtable      ht = new Hashtable();
            SaveFileDialog sf = new SaveFileDialog();

            sf.FileName = "LZ_OEM_SALES_PERFORMANCE_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
            sf.Filter   = "(文件)|*.xls;*.xlsx";
            if (sf.ShowDialog(this) == DialogResult.OK)
            {
                if (dt.Rows.Count > 0)
                {
                    int ret = CExport.ExportOEMSales(@"rpt\OEM_SALES_PERFORMANCE.frx", sf.FileName, dt, ht);
                    if (CConstant.EXPORT_FAILURE.Equals(ret))
                    {
                        MessageBox.Show("导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else if (CConstant.EXPORT_SUCCESS.Equals(ret))
                    {
                        MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (CConstant.EXPORT_RUNNING.Equals(ret))
                    {
                        MessageBox.Show("文件正在运行,重新生成文件失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else if (CConstant.EXPORT_TEMPLETE_FILE_NOT_EXIST.Equals(ret))
                    {
                        MessageBox.Show("模版文件不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    this.Close();
                }
                else
                {
                    MessageBox.Show("明细信息不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }