Exemple #1
0
        public async Task<bool> UpdateDDPalReportAsync(string FilePath, int AccountNo, bool bSuccess)
        {
            bool bRet = await Task.Run(() =>
            {
                try
                {
                    Application excel = new Application();
                    excel.Visible = false;
                    Workbook wb = excel.Workbooks.Open(FilePath);
                    Worksheet ws = wb.ActiveSheet as Worksheet;

                    int nRow = AccountNo + 1;
                    int nAccountIndex = AccountNo - 1;

                    for (int i = 1; i < 8; i++)
                    {
                        ((Range)(ws.Cells[nRow, i])).HorizontalAlignment = XlHAlign.xlHAlignLeft;
                    }

                    ws.Cells[nRow, 1] = aJDAccount[nAccountIndex].UserName;
                    ws.Cells[nRow, 2] = aJDAccount[nAccountIndex].Password;
                    if (bSuccess)
                    {
                        ws.Cells[nRow, 3] = OrderNo;
                        ws.Cells[nRow, 4] = SinglePalCount;
                        ws.Cells[nRow, 5] = OrderMoney;
                        ws.Cells[nRow, 6] = Settings.Default.Remark;
                        ws.Cells[nRow, 7] = "否";
                    }
                    else
                    {
                        ((Range)(ws.Cells[nRow, 1])).Interior.ColorIndex = 3;
                        ((Range)(ws.Cells[nRow, 2])).Interior.ColorIndex = 3;
                    }
                    
                    wb.Save();

                    if (wb != null)
                        wb.Close();
                    if (excel != null)
                    {
                        excel.Quit();
                        App.KillExcel(excel);
                        excel = null;
                    }
                }
                catch (Exception e)
                {
                    System.Windows.MessageBox.Show(e.Message, Globals.JD_CAPTION);
                    Trace.TraceInformation("Rudy Exception=> UpdateDDPalReportAsync: " + e.Source + ";" + e.Message);
                    return false;
                }

                return true;
            }).ConfigureAwait(false);
            return bRet;
        }
Exemple #2
0
        public async Task<bool> SetAddressAccoutInfoAsync(string FilePath)
        {
            bool bRet = await Task.Run(() =>
            {
                if (aAccountInfo != null)
                    aAccountInfo.Clear();
                try
                {
                    Application excel = new Application();
                    excel.Visible = false;
                    Workbook wb = excel.Workbooks.Open(FilePath);
                    Worksheet ws = wb.ActiveSheet as Worksheet;
                    int nRowCount = ws.UsedRange.Cells.Rows.Count;//get the used rows count.

                    AccountInfo infoTemp;
                    for (int i = 2; i <= nRowCount; i++)
                    {
                        infoTemp.Account = ((Range)ws.Cells[i, 1]).Text;
                        infoTemp.Password = ((Range)ws.Cells[i, 2]).Text;
                        infoTemp.FullName = ((Range)ws.Cells[i, 3]).Text;
                        infoTemp.Mobile = ((Range)ws.Cells[i, 4]).Text;
                        infoTemp.Province = ((Range)ws.Cells[i, 5]).Text;
                        infoTemp.City = ((Range)ws.Cells[i, 6]).Text;
                        infoTemp.County = ((Range)ws.Cells[i, 7]).Text;
                        infoTemp.Town = ((Range)ws.Cells[i, 8]).Text;
                        infoTemp.DetailAddress = ((Range)ws.Cells[i, 9]).Text;
                        aAccountInfo.Add(infoTemp);
                    }
                    if (wb != null)
                        wb.Close();
                    if (excel != null)
                    {
                        excel.Quit();
                        App.KillExcel(excel);
                        excel = null;
                    }
                }
                catch (Exception e)
                {
                    System.Windows.MessageBox.Show(e.Message, Globals.JD_CAPTION);
                    Trace.TraceInformation("Rudy Exception=> SetAddressAccoutInfoAsync: " + e.Source + ";" + e.Message);
                    return false;
                }

                return true;
            }).ConfigureAwait(false);
            return bRet;
        }
Exemple #3
0
        public async Task<bool> CreateDDPalReportAsync(string FilePath)
        {
            Trace.TraceInformation("Rudy Trace =>CreateDDPalReportAsync: Report Path = " + FilePath);
            bool bRet = await Task.Run(() =>
            {
                try
                {
                    Application excel = new Application();
                    excel.Visible = false;
                    Workbook wb = excel.Workbooks.Add();
                    Worksheet ws = wb.Sheets[1] as Worksheet;

                    ws.Cells[1, 1] = "账户";
                    ws.Cells[1, 2] = "密码";
                    ws.Cells[1, 3] = "订单编号";
                    ws.Cells[1, 4] = "数量";
                    ws.Cells[1, 5] = "金额(元)";
                    ws.Cells[1, 6] = "备注";
                    ws.Cells[1, 7] = "已评论";
                    for (int i = 1; i < 8; i++)
                    {
                        ((Range)(ws.Cells[1, i])).HorizontalAlignment = XlHAlign.xlHAlignLeft;
                        ((Range)(ws.Cells[1, i])).ColumnWidth = 12;
                    }

                    wb.SaveAs(FilePath);

                    if (wb != null)
                        wb.Close();
                    if (excel != null)
                    {
                        excel.Quit();
                        App.KillExcel(excel);
                        excel = null;
                    }
                }
                catch (Exception e)
                {
                    System.Windows.MessageBox.Show(e.Message, Globals.JD_CAPTION);
                    Trace.TraceInformation("Rudy Exception=> CreateDDPalReportAsync: " + e.Source + ";" + e.Message);
                    return false;
                }

                return true;
            }).ConfigureAwait(false);
            return bRet;
        }