コード例 #1
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            string filename = "";

            OpenFileDialog ofd = new OpenFileDialog()
            {
                Filter = "Excel Files |*.xls"
            };

            uploadtable = new DataTable();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                filename = ofd.FileName;

                uploadtable = ImportXlsUtil.TranslateToTable(filename);

                frmUploadConfirm form = new frmUploadConfirm(uploadtable);
                form.ShowDialog();

                if (form.DialogResult == DialogResult.OK)
                {
                    if (!worker.IsBusy)
                    {
                        this.Cursor = Cursors.WaitCursor;
                        worker.RunWorkerAsync();
                    }
                    else
                    {
                        MessageBox.Show("File is using by other process");
                    }
                }
            }
        }
コード例 #2
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog()
            {
                Filter = "Excel Files |*.xls"
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                filename = ofd.FileName;

                uploadTable = new DataTable();

                uploadTable = ImportXlsUtil.TranslateToTable(filename);

                for (int i = 0; i < uploadTable.Rows.Count; i++)
                {
                    string issued    = uploadTable.Rows[i][14].ToString();
                    string instock50 = uploadTable.Rows[i][15].ToString();
                    string instock   = uploadTable.Rows[i][16].ToString();

                    issued = ImportXlsUtil.ParseDateTime(issued).ToString("yyyy/MM/dd");

                    if (instock50 != "-----" && instock50 != "" && instock50 != "一回合格入庫" && instock50 != "Received" && instock50 != "已拆單、以合格同時入庫")
                    {
                        instock50 = ImportXlsUtil.ParseDateTime(instock50).ToString("yyyy/MM/dd");
                    }

                    if (instock != "" && instock != "Received" && instock != "#N/A")
                    {
                        instock = ImportXlsUtil.ParseDateTime(instock).ToString("yyyy/MM/dd");
                    }

                    uploadTable.Rows[i][14] = issued;
                    uploadTable.Rows[i][15] = instock50;
                    uploadTable.Rows[i][16] = instock;
                }

                frmUploadConfirm form = new frmUploadConfirm(uploadTable);
                form.ShowDialog();

                if (form.DialogResult == DialogResult.OK)
                {
                    if (!worker.IsBusy)
                    {
                        this.Cursor       = Cursors.WaitCursor;
                        dgvPreview.Cursor = Cursors.WaitCursor;
                        dgvResult.Cursor  = Cursors.WaitCursor;
                        worker.RunWorkerAsync();
                    }
                    else
                    {
                        MessageBox.Show("Using by other process");
                    }
                }
            }
        }
コード例 #3
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            string filename = "";

            potable = new DataTable();

            OpenFileDialog ofd = new OpenFileDialog()
            {
                Filter = "Excel Files |*.xls"
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                filename = ofd.FileName;

                try
                {
                    potable = ImportXlsUtil.TranslateToTable(filename);

                    frmUploadConfirm form = new frmUploadConfirm(potable);
                    form.ShowDialog();

                    if (form.DialogResult == DialogResult.OK)
                    {
                        if (!worker.IsBusy)
                        {
                            this.Cursor       = Cursors.WaitCursor;
                            dgvIssuePo.Cursor = Cursors.WaitCursor;
                            worker.RunWorkerAsync();
                        }
                        else
                        {
                            MessageBox.Show("File is using by other process");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message + ex.StackTrace);
                    validData = false;
                }
            }
        }
コード例 #4
0
        private void btnUploadTM_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog()
            {
                Filter = "Excel Files |*.xls;*.xlsx"
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                filename = ofd.FileName;

                uploadTable = new DataTable();

                uploadTable = ofd.FileName.EndsWith(".xls") ? ImportXlsUtil.TranslateToTable(ofd.FileName) : ImportXls2007Util.TranslateToTable(ofd.FileName);

                DataTable tmptable = new DataTable();

                tmptable.Columns.Add("Chase No.");
                tmptable.Columns.Add("Check Date");
                tmptable.Columns.Add("In Stock Remarks");
                tmptable.Columns.Add("In Stock Date");

                foreach (DataRow row in uploadTable.Rows)
                {
                    string chaseno = row.ItemArray[0].ToString();

                    if (chaseno.StartsWith("CM"))
                    {
                        string instockdate = ImportXls2007Util.ParseDateTime(row.ItemArray[3].ToString()).ToString("yyyy/MM/dd");

                        tmptable.Rows.Add(new object[] { chaseno, "", "", instockdate });
                    }
                    else
                    {
                        string checkdate = ImportXlsUtil.ParseDateTime(row.ItemArray[1].ToString()).ToString("yyyy/MM/dd");
                        if (checkdate == "0001/01/01")
                        {
                            checkdate = "";
                        }

                        string instockremarks = row.ItemArray[2].ToString();

                        string instockdate = ImportXlsUtil.ParseDateTime(row.ItemArray[3].ToString()).ToString("yyyy/MM/dd");

                        tmptable.Rows.Add(new object[] { chaseno, checkdate, instockremarks, instockdate });
                    }
                }

                frmUploadConfirm form = new frmUploadConfirm(tmptable);
                form.ShowDialog();

                if (form.DialogResult == DialogResult.OK)
                {
                    if (!workerTM.IsBusy)
                    {
                        this.Cursor       = Cursors.WaitCursor;
                        dgvPreview.Cursor = Cursors.WaitCursor;
                        dgvResult.Cursor  = Cursors.WaitCursor;
                        workerTM.RunWorkerAsync();
                    }
                    else
                    {
                        MessageBox.Show("Using by other process");
                    }
                }
            }
        }
コード例 #5
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog()
            {
                Filter = "Excel Files |*.xls"
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                filename = ofd.FileName;

                ulTable = new DataTable();

                ulTable = ImportXlsUtil.TranslateToTable(filename);

                for (int i = 0; i < ulTable.Rows.Count; i++)
                {
                    string date    = ulTable.Rows[i][0].ToString();
                    string issued  = ulTable.Rows[i][15].ToString();
                    string instock = ulTable.Rows[i][16].ToString();
                    string debit   = ulTable.Rows[i][17].ToString();
                    string sales   = ulTable.Rows[i][18].ToString();

                    date = ImportXlsUtil.ParseDateTime(date).ToString("yyyy/MM/dd");
                    if (issued != "")
                    {
                        issued = ImportXlsUtil.ParseDateTime(issued).ToString("yyyy/MM/dd");
                    }
                    if (instock != "")
                    {
                        instock = ImportXlsUtil.ParseDateTime(instock).ToString("yyyy/MM/dd");
                    }
                    if (debit != "no need" && debit != "")
                    {
                        debit = ImportXlsUtil.ParseDateTime(debit).ToString("yyyy/MM/dd");
                    }
                    if (sales != "no need" && sales != "")
                    {
                        sales = ImportXlsUtil.ParseDateTime(sales).ToString("yyyy/MM/dd");
                    }

                    ulTable.Rows[i][0]  = date;
                    ulTable.Rows[i][15] = issued;
                    ulTable.Rows[i][16] = instock;
                    ulTable.Rows[i][17] = debit;
                    ulTable.Rows[i][18] = sales;
                }

                frmUploadConfirm form = new frmUploadConfirm(ulTable);
                form.ShowDialog();

                if (form.DialogResult == DialogResult.OK)
                {
                    if (!worker.IsBusy)
                    {
                        this.Cursor = Cursors.WaitCursor;
                        dgvExpenseTransfer.Cursor = Cursors.WaitCursor;
                        worker.RunWorkerAsync();
                    }
                    else
                    {
                        MessageBox.Show("File is using by other process");
                    }
                }
            }
        }