Ejemplo n.º 1
0
        private void DownloadTemplates()
        {
            string strError            = string.Empty;
            List <WarehouseInfo> lstWH = new List <WarehouseInfo>();

            if (!Basic_Func.GetWarehouseList(ref lstWH, new WarehouseInfo(), ref strError))
            {
                MessageBox.Show(strError);
                return;
            }
            if (lstWH == null || lstWH.Count <= 0)
            {
                MessageBox.Show("未获取到任何仓库");
                return;
            }

            DataSet dsWH = ConvertList2DataSet(lstWH);

            string path = "货位导入格式";

            if (!Common_Func.ShowSaveDialog(ref path, "xlsx"))
            {
                return;
            }

            byte[] bArea;
            bool   isXSSF = Path.GetExtension(path).ToLower() == (".xlsx");

            bArea = isXSSF ? Properties.Resources.AreaTemplateXLSX : Properties.Resources.AreaTemplateXLS;
            if (Common_Func.SaveBytesToFile(path, bArea))
            {
                ExcelLibrary_Func.AddDataSetToExcelByNPOI(path, dsWH);

                if (MessageBox.Show(string.Format("文件已成功保存到【{0}】!{1}是否直接打开?", path, Environment.NewLine), "保存成功", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(path);
                }
            }
        }