Пример #1
0
        private void bkgWorkForExportingRecords_DoWork(object sender, DoWorkEventArgs e)
        {
            var bkgWorker = sender as BackgroundWorker;

            var counter    = 0;
            var lstOrderNo = new OrderManage().GetAllOrderNoAndPurchaser();


            foreach (var orderInfo in lstOrderNo)
            {
                var objItems     = new ItemManage().GetItemListByOrderNo(orderInfo.Key);
                var objUserInfo  = new UserInfoManage().GetUserByOrderNo(orderInfo.Key);
                var orderContent = ExportFile.GenerateOrderContent(objItems, objUserInfo, true);
                var path         = string.Format((string)e.Argument + @"\{0}{1}.txt", orderInfo.Key, orderInfo.Value);
                ExportFile.CreateOrderFile(path, orderContent);

                try
                {
                    bkgWorker.ReportProgress(counter++);
                }
                catch (NullReferenceException exception)
                {
                    Console.WriteLine(exception);
                    throw;
                }
            }


            MessageBox.Show("Exporting all .txt files sucessfully!");
        }
Пример #2
0
        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
        }
Пример #3
0
        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!");
            }
        }