private void btnTxtFile_Click(object sender, EventArgs e) { #region Generate .txt file var fileSelector = new FolderBrowserDialog(); var defaultPath = ExportFile.GetDefaultPath("dircPath"); if (defaultPath != "") { fileSelector.SelectedPath = defaultPath; } if (fileSelector.ShowDialog() == DialogResult.OK) { ExportFile.SetFolderPath("dircPath", fileSelector.SelectedPath); var path = string.Format(fileSelector.SelectedPath + @"\{0}{1}.txt", crtOrderNo, purchaserName); var objItems = new ItemManage().GetItemListByOrderNo(crtOrderNo); var objUserInfo = new UserInfo { UserName = tbTo.Text.Trim(), PhoneNumber = tbToPhone.Text.Trim(), Address = tbAddress.Text.Trim(), CardNo = tbIdentityCard.Text.Trim() }; var orderContent = ExportFile.GenerateOrderContent(objItems, objUserInfo, true); ExportFile.CreateOrderFile(path, tbOrderContent.Text.Trim()); MessageBox.Show((zh?"生成 ":"Generating ") + crtOrderNo + purchaserName + (zh?".txt 成功! ":".txt Sucessfully!")); } #endregion }
/// <summary> /// Import Orders /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnImport_Click(object sender, EventArgs e) { var fileSelector = new FolderBrowserDialog(); var defaultPath = ExportFile.GetDefaultPath("dircPath"); if (defaultPath != "") { fileSelector.SelectedPath = defaultPath; } if (fileSelector.ShowDialog() == DialogResult.OK) { ExportFile.SetFolderPath("dircPath", fileSelector.SelectedPath); lbFolder.Text = string.Format(" Selected Directory: {0}", fileSelector.SelectedPath); var files = Directory.GetFiles(fileSelector.SelectedPath).Where(name => name.EndsWith(".txt")); prbImport.Maximum = files.ToList().Count; prbImport.Step = 1; prbImport.Value = 0; foreach (var file in files.ToList()) { var objOrder = FormatParsing.ParsePathToFileName(file); objOrder = FormatParsing.ParseContentIntoOrder(file, objOrder); objOrders.Add(objOrder); } objOrders.Sort(); if (bkgWorkForImporting.IsBusy != true) { bkgWorkForImporting.RunWorkerAsync(); } btnImportRecords.Enabled = false; } }
private void btnExportTransaction_Click(object sender, EventArgs e) { #region Generate .xls file var fileSelector = new FolderBrowserDialog(); var defaultPath = ExportFile.GetDefaultPath("dircPath"); if (defaultPath != "") { fileSelector.SelectedPath = defaultPath; } var timeStamp = DateTime.Now.Date.ToString("ddMMyyyy"); if (fileSelector.ShowDialog() == DialogResult.OK) { ExportFile.SetFolderPath("dircPath", fileSelector.SelectedPath); var path = string.Format(fileSelector.SelectedPath + @"\销售记录{0}.xls", timeStamp); lbFolder.Text = string.Format(" Selected Directory: {0}", path); var parameters = new string[2]; parameters[0] = timeStamp; parameters[1] = path; if (bkgWorkForExporting.IsBusy != true) { bkgWorkForExporting.RunWorkerAsync(parameters); } btnExportTransaction.Enabled = false; } #endregion }
private void btnExportRecords_Click(object sender, EventArgs e) { #region Batch generate .txt file var fileSelector = new FolderBrowserDialog(); var defaultPath = ExportFile.GetDefaultPath("dircPath"); if (defaultPath != "") { fileSelector.SelectedPath = defaultPath; } var timeStamp = DateTime.Now.Date.ToString("ddMMyyyy"); if (fileSelector.ShowDialog() == DialogResult.OK) { ExportFile.SetFolderPath("dircPath", fileSelector.SelectedPath); lbFolder.Text = string.Format(" Selected Directory: {0}", fileSelector.SelectedPath); prbImport.Maximum = new OrderManage().GetMaxOrderNo() - 1; prbImport.Step = 1; prbImport.Value = 0; if (bkgWorkForExportingRecords.IsBusy != true) { bkgWorkForExportingRecords.RunWorkerAsync(fileSelector.SelectedPath); } btnExportRecords.Enabled = false; } #endregion }
/// <summary> /// Import the transaction records /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnImportTransaction_Click(object sender, EventArgs e) { FileDialog fileSelector = new OpenFileDialog(); fileSelector.Filter = "Text files (*.xls)|*.xls"; var defaultPath = ExportFile.GetDefaultPath("dircPath"); if (defaultPath != "") { fileSelector.InitialDirectory = defaultPath; } if (fileSelector.ShowDialog() == DialogResult.OK) { var pos = fileSelector.FileName.LastIndexOf(@"\", StringComparison.Ordinal); var path = fileSelector.FileName.Substring(0, pos); ExportFile.SetFolderPath("dircPath", path); lbFolder.Text = string.Format(" Selected Directory: {0}", path); prbImport.Step = 1; prbImport.Value = 0; objTransactions = FormatParsing.ParseContentIntoTransaction(fileSelector.FileName, objTransactions); prbImport.Maximum = objTransactions.Count; if (bkgWorkForTransaction.IsBusy != true) { bkgWorkForTransaction.RunWorkerAsync(); } btnImportTransaction.Enabled = false; } }
private void btnRegenerate_Click(object sender, EventArgs e) { #region Generate the Order text var objItems = new ItemManage().GetItemListByOrderNo(_orderNo); var objUserInfo = new UserInfoManage().GetUserByOrderNo(_orderNo); tbOrderContent.Text = GenerateOrderContent(objItems, objUserInfo, false); #endregion #region Generate .txt file _purchaserName = new OrderManage().GetPurchaserName(_orderNo); var fileSelector = new FolderBrowserDialog(); var defaultPath = ExportFile.GetDefaultPath("dircPath"); if (defaultPath != "") { fileSelector.SelectedPath = defaultPath; } if (fileSelector.ShowDialog() == DialogResult.OK) { ExportFile.SetFolderPath("dircPath", fileSelector.SelectedPath); var path = string.Format(fileSelector.SelectedPath + @"\{0}{1}.txt", _orderNo, _purchaserName); ExportFile.CreateOrderFile(path, tbOrderContent.Text.Trim()); if (DialogResult.OK == MessageBox.Show((zh?"生成":"Generating ") + _orderNo + _purchaserName + (zh?".txt 成功!":".txt Sucessfully!"))) { //this.Close(); } } #endregion if (tbOrderContent.Text != "") { Clipboard.SetDataObject(tbOrderContent.Text); tbOrderContent.Focus(); MessageBox.Show(zh ? "复制到粘贴板" : "Copy to clipboard!"); } }