コード例 #1
0
        private void dELETEToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <string> chasenolist = new List <string>();

            foreach (DataGridViewRow row in dgvQuotation.SelectedRows)
            {
                string chaseno = row.Cells[2].Value.ToString();
                chasenolist.Add(chaseno);
            }

            chasenolist = chasenolist.Distinct().ToList();

            switch (MessageBox.Show("Are you sure to delete selected items?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
            case DialogResult.Yes:
                foreach (string chaseno in chasenolist)
                {
                    string text = string.Format("update TB_FA_APPROVAL set f_remarks = N'已刪除' where f_chaseno = '{0}'", chaseno);
                    DataServiceNew.GetInstance().ExecuteNonQuery(text);

                    string query = string.Format("delete from tb_betamould where tm_chaseno = '{0}'", chaseno);
                    DataService.GetInstance().ExecuteNonQuery(query);
                }

                this.loadData();
                break;

            case DialogResult.No:
                break;
            }
        }
コード例 #2
0
        private void UpdateMouldData(string mould, string partno, string reportno, string status)
        {
            string code = status == "廢棄處理中" ? "W" : status == "廢棄完了" ? "L" : "";

            if (code != "")
            {
                string text = string.Format("update tb_betamould set tm_st_code = '{0}', tm_disposalno = '{1}' where tm_mouldno = '{2}'", code, reportno, mould);
                DataService.GetInstance().ExecuteNonQuery(text);

                List <string> list = new List <string>();

                string query2 = string.Format("select tm_chaseno from tb_betamould where tm_mouldno = '{0}' and tm_itemcode = '{1}'", mould, partno);
                using (IDataReader reader = DataService.GetInstance().ExecuteReader(query2))
                {
                    while (reader.Read())
                    {
                        list.Add(reader.GetString(0).Trim());
                    }
                }

                foreach (string chaseno in list)
                {
                    try
                    {
                        string query3 = string.Format("update TB_FA_APPROVAL set f_remarks = N'{0}' where f_mould = '{1}'", status, chaseno);
                        DataServiceNew.GetInstance().ExecuteNonQuery(query3);
                    }
                    catch
                    {
                        continue;
                    }
                }
            }
        }
コード例 #3
0
        private void LoadData(string source)
        {
            DataTable table = new DataTable();

            string query = string.Format("select f_status as st, f_apptype as apptype, f_chaseno as chaseno, f_request as request, f_desc as itemtext" +
                                         ", f_pdfid as pdfid, f_attachment as attachment from TB_FA_APPROVAL where f_status != 'Finished' and (f_pdfid like '%{0}%' or f_desc like '%{0}%') order by f_pdfid", source);
            SqlDataAdapter sda = new SqlDataAdapter(query, DataServiceNew.GetInstance().Connection);

            sda.Fill(table);

            dgvFa.DataSource = table;
        }
コード例 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            List <DisposalData> list = new List <DisposalData>();

            string query = "select dd_mould, dd_partno from tb_disposaldetail where dd_status = N'廢棄完了'";

            using (IDataReader reader = DataService.GetInstance().ExecuteReader(query))
            {
                while (reader.Read())
                {
                    list.Add(new DisposalData {
                        Mould = reader.GetString(0).Trim(), PartNo = reader.GetString(1).Trim()
                    });
                }
            }

            list = list.Distinct().ToList();

            List <string> chaseNoList = new List <string>();

            foreach (DisposalData item in list)
            {
                string text = string.Format("select tm_chaseno from tb_betamould where tm_mouldno = '{0}' and tm_itemcode = '{1}'", item.Mould, item.PartNo);
                using (IDataReader reader = DataService.GetInstance().ExecuteReader(text))
                {
                    while (reader.Read())
                    {
                        chaseNoList.Add(reader.GetString(0).Trim());
                    }
                }
            }

            foreach (string item in chaseNoList)
            {
                string text = string.Format("update tb_betamould set tm_st_code = 'L' where tm_chaseno = '{0}'", item);
                DataService.GetInstance().ExecuteNonQuery(text);

                string text2 = string.Format("update TB_FA_APPROVAL set f_remarks = N'已廢棄' where f_chaseno = '{0}'", item);
                DataServiceNew.GetInstance().ExecuteNonQuery(text2);
            }
        }
コード例 #5
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            DataTable tmptable = ImportXlsUtil.TranslateToTable(filename);

            int count = 0;

            foreach (DataRow row in tmptable.Rows)
            {
                string rowGroup = row.ItemArray[2].ToString();

                string rowChaseno = row.ItemArray[15].ToString();

                string rowPassremarks = row.ItemArray[20].ToString();

                string rowPassdate = row.ItemArray[21].ToString();

                string rowCollectdate = row.ItemArray[22].ToString();

                //if (rowPassdate.Contains("4"))
                //rowPassdate = ImportXlsUtil.ParseDateTime(rowPassdate).ToString("yyyy/MM/dd");

                rowPassremarks = rowPassremarks.Replace("'", "''");

                string query = string.Format("update tb_betamould set tm_passdate = '{0}', tm_collectdate = '{1}', tm_passremarks = '{2}', tm_checkdate2 = '{4}' where tm_chaseno = '{3}'",
                                             rowPassdate, rowCollectdate, rowPassremarks, rowChaseno, rowGroup);

                DataService.GetInstance().ExecuteNonQuery(query);

                string query2 = string.Format("update tb_betamould set tm_facremarks = tm_collectdate where tm_chaseno = '{0}' and tm_fixedAssetCode != ''", rowChaseno);

                DataService.GetInstance().ExecuteNonQuery(query2);

                if (rowCollectdate != "")
                {
                    string query3 = string.Format("update TB_FA_APPROVAL set f_remarks = N'{0}' where f_mould = '{1}'", rowCollectdate, rowChaseno);
                    DataServiceNew.GetInstance().ExecuteNonQuery(query3);
                }

                count += 1;
            }
        }
コード例 #6
0
        private void LoadData()
        {
            dgvApproval.Rows.Clear();

            string status = GlobalService.Owner == GlobalService.IPO1st ? "IPO 1st Approval" : GlobalService.Owner == GlobalService.IPO2nd ? "IPO 2nd Approval" : "";

            string query = string.Format("select f_request, f_applicant, f_pdfid, f_attachment from TB_FA_APPROVAL where f_status = '{0}' group by f_request, f_applicant, f_pdfid, f_attachment", status);

            using (IDataReader reader = DataServiceNew.GetInstance().ExecuteReader(query))
            {
                while (reader.Read())
                {
                    string request    = reader.GetString(0);
                    string applicant  = reader.GetString(1);
                    string pdfid      = reader.GetString(2);
                    string attachment = reader.GetString(3);

                    dgvApproval.Rows.Add("---", request, applicant, pdfid, attachment);
                }
            }
        }
コード例 #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            List <FaApplicationList> list = new List <FaApplicationList>();

            foreach (DataGridViewRow row in dgvMain.Rows)
            {
                string isChecked = row.Cells[15].FormattedValue.ToString();

                if (isChecked != "True")
                {
                    continue;
                }

                string chaseno    = row.Cells[0].Value.ToString().Trim();
                string vendor     = row.Cells[1].Value.ToString().Trim();
                string vendorname = row.Cells[2].Value.ToString().Trim();
                string partno     = row.Cells[3].Value.ToString().Trim();
                string itemtext   = row.Cells[11].Value.ToString().Trim();
                string ringi      = row.Cells[13].Value.ToString().Trim();
                string mouldJig   = row.Cells[14].Value.ToString().Trim();

                list.Add(new FaApplicationList {
                    Chaseno = chaseno, Itemcode = partno, Itemtext = itemtext, Ringi = ringi, Vendor = vendor + " " + vendorname, AppType = mouldJig
                });
            }

            if (list.Count > 0)
            {
                switch (MessageBox.Show("Are you sure to apply " + list.Count + " item for Fixed Asset?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                case DialogResult.Yes:
                    DataTable pdfTable = new DataTable();
                    string[]  headers  = { "ChaseNo", "Item Text", "Item Code", "Ringi", "Vendor" };
                    foreach (string header in headers)
                    {
                        pdfTable.Columns.Add(header);
                    }

                    string pdfFile = DataUtil.GetLatestPdfId();

                    string today = DateTime.Today.ToString("yyyy/MM/dd");

                    int mouldCount = 0;
                    int jigCount   = 0;

                    foreach (FaApplicationList item in list)
                    {
                        string query = string.Format("update tb_betamould set tm_st_code = 'A', tm_ringi_code = '{0}', tm_pdfid = '{1}' where tm_chaseno = '{2}'", item.Ringi, pdfFile, item.Chaseno);
                        DataService.GetInstance().ExecuteNonQuery(query);

                        pdfTable.Rows.Add(item.Chaseno, item.Itemtext, item.Itemcode, item.Ringi, item.Vendor);

                        string mpa      = DataUtil.GetMpa(item.Chaseno) == "True" ? "Yes" : "No";
                        string vendor   = DataUtil.GetVendor(item.Chaseno);
                        string path     = @"\\kdthk-dm1\moss$\cm\FixedAssets\" + pdfFile + ".pdf";
                        string model    = DataUtil.GetModel(item.Chaseno);
                        string currency = DataUtil.GetCurrency(item.Chaseno);
                        string amount   = DataUtil.GetAmount(item.Chaseno);

                        string approvalText = string.Format("insert into TB_FA_APPROVAL (f_request, f_applicant, f_type, f_chaseno, f_pdfid, f_status, f_desc, f_mpa, f_vendor, f_attachment" +
                                                            ", f_mould, f_ringi, f_model, f_currency, f_amount, f_assetdesc, f_ipo1st, f_ipo2nd, f_partno, f_apptype) values ('{0}', N'{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', N'{16}', N'{17}', '{18}', '{19}')"
                                                            , today, GlobalService.Owner, "Acquisition", item.Chaseno, pdfFile, "IPO 1st Approval", item.Itemtext, mpa, vendor, path, item.Chaseno, item.Ringi, model, currency, amount
                                                            , item.Vendor, GlobalService.IPO1st, GlobalService.IPO2nd, item.Itemcode, item.AppType);

                        DataServiceNew.GetInstance().ExecuteNonQuery(approvalText);

                        if (item.AppType == "Mould")
                        {
                            mouldCount += 1;
                        }
                        if (item.AppType == "Jigs")
                        {
                            jigCount += 1;
                        }
                    }

                    pdfTable.DefaultView.Sort = "ChaseNo ASC";

                    PdfUtil.ApplyFixedAssetPdf(pdfTable, pdfFile, mouldCount, jigCount);

                    string from = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.Owner, "kmhk.local"), "kmhk.local");
                    string to   = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.IPO1st, "kmhk.local"), "kmhk.local");

                    EmailUtil.SendEmail(from, to, "SpApp_Fixed Asset Application Approval Required");

                    DialogResult = DialogResult.OK;
                    break;

                case DialogResult.No:
                    break;
                }
            }
        }
コード例 #8
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                foreach (DataRow row in uploadTable.Rows)
                {
                    string chaseno   = row.ItemArray[0].ToString();
                    string ulInStock = row.ItemArray[16].ToString();

                    string ulInStock50 = row.ItemArray[15].ToString();

                    if (ulInStock50 != "" && !ulInStock50.Contains("---") && ulInStock50 != "Received" && ulInStock50 != "一回合格入庫" && ulInStock50 != "已拆單、以合格同時入庫")
                    {
                        string vendorcode = DataChecking.getVendorCodeByChaseNo(chaseno);

                        string payterm = DataChecking.getPayTerm(vendorcode);

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

                        string paymonth = "";

                        if (payterm == "HK01")
                        {
                            paymonth = ImportXlsUtil.ParseDateTime(ulInStock50).AddMonths(1).ToString("yyyy/MM/dd");
                        }
                        else if (payterm == "HK02")
                        {
                            paymonth = ImportXlsUtil.ParseDateTime(ulInStock50).AddMonths(2).ToString("yyyy/MM/dd");
                        }

                        string query = string.Format("update tb_betamould set tm_st_code = 'HS', tm_instockdate50 = '{0}', tm_moulditemviewer = 'Yes', tm_paydate = '{1}' where tm_chaseno = '{2}'", ulInStock50, paymonth, chaseno);

                        DataService.GetInstance().ExecuteNonQuery(query);
                    }

                    if (ulInStock != "" && ulInStock != "Received" && ulInStock != "#N/A")
                    {
                        string vendorcode = DataChecking.getVendorCodeByChaseNo(chaseno);

                        string payterm = DataChecking.getPayTerm(vendorcode);

                        string paymonth = "";

                        if (payterm == "HK01")
                        {
                            paymonth = ImportXlsUtil.ParseDateTime(ulInStock).AddMonths(1).ToString("yyyy/MM/dd");
                        }

                        else if (payterm == "HK02")
                        {
                            paymonth = ImportXlsUtil.ParseDateTime(ulInStock).AddMonths(2).ToString("yyyy/MM/dd");
                        }

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

                        if (ulInStock == "0001/03/02")
                        {
                            ulInStock = "";
                        }

                        string query = string.Format("update tb_betamould set tm_st_code = 'S', tm_instockdate = '{0}', tm_paydate = '{1}', tm_nofac = 'False', tm_moulditemviewer = 'Yes' where tm_chaseno = '{2}'", ulInStock, paymonth, chaseno);

                        DataService.GetInstance().ExecuteNonQuery(query);

                        string expenseText = string.Format("update tb_expensetransfer set et_poinstock = '{0}' where et_chaseno = '{1}'", ulInStock, chaseno);

                        DataService.GetInstance().ExecuteNonQuery(expenseText);

                        string query2 = string.Format("update TB_FA_APPROVAL set f_remarks = N'已入庫' where f_mould = '{0}'", chaseno);
                        DataServiceNew.GetInstance().ExecuteNonQuery(query2);
                    }
                }

                MessageBox.Show("Data uploaded");
            }
            catch
            {
                MessageBox.Show("Invalid Data Format");
            }
        }
コード例 #9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            dgvApproval.EndEdit();

            foreach (DataGridViewRow row in dgvApproval.Rows)
            {
                string approval = row.Cells[0].Value.ToString().Trim();

                if (approval == "---")
                {
                    continue;
                }

                string pdfid = row.Cells[3].Value.ToString().Trim();

                string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

                string query = "";

                string applicant = row.Cells[2].Value.ToString().Trim();

                string email = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(applicant, "kmhk.local"), "kmhk.local");

                if (GlobalService.Owner == GlobalService.IPO1st)
                {
                    if (approval == "Approve")
                    {
                        query = string.Format("update TB_FA_APPROVAL set f_status = '{0}', f_ipo1stapp = '{1}', f_ipo1stdate = '{2}'" +
                                              " where f_pdfid = '{3}'", "IPO 2nd Approval", "Approve", now, pdfid);

                        EmailUtil.SendEmail(email, "*****@*****.**", "SpApp_Fixed Asset Application Approval Required");
                    }
                    else
                    {
                        query = string.Format("delete from TB_FA_APPROVAL where f_pdfid = '{0}'", pdfid);

                        RejectStatus(pdfid);
                    }
                }
                else
                {
                    if (approval == "Approve")
                    {
                        query = string.Format("update TB_FA_APPROVAL set f_status = '{0}', f_ipo2ndapp = '{1}', f_ipo2nddate = '{2}', f_ringi1st = N'{3}', f_cm1st = N'{4}', f_cm2nd = N'{5}', f_cm3rd = N'{6}'" +
                                              " where f_pdfid = '{7}'", "Ringi Approval", "Approve", now, "Lai King Ho(黎景豪,Ken)", "Lee Suk Ha(李淑霞,Zoe)", "Li Yuen Yan(李婉茵,Sharon)", "Leung Wai Yip(梁偉業,Philip)", pdfid);

                        try
                        {
                            EmailUtil.NotificationEmail(email, "*****@*****.**", "Fixed Asset Application Approval Required");
                        }
                        catch
                        {
                            Debug.WriteLine("aaa");
                        }
                    }
                    else
                    {
                        query = string.Format("delete from TB_FA_APPROVAL where f_pdfid = '{0}'", pdfid);

                        RejectStatus(pdfid);
                    }
                }

                DataServiceNew.GetInstance().ExecuteNonQuery(query);
            }

            LoadData();
        }
コード例 #10
0
        private void loadData()
        {
            table = new DataTable();

            dgvFa.Rows.Clear();

            string _commandText = "select tm_chaseno as chaseno, tm_mouldno as mouldno, tm_itemcode as itemcode" +
                                  ", tm_currency as currency, tm_amount as amount, tm_pdfid as refid from tb_betamould where tm_st_code = 'A'";

            string commandText = "";

            if (cbSearch.SelectedIndex == 0)
            {
                commandText = _commandText;
            }

            if (cbSearch.SelectedIndex == 1)
            {
                commandText = _commandText + string.Format(" and tm_chaseno like '%{0}%'", txtSearch.Text);
            }

            if (cbSearch.SelectedIndex == 2)
            {
                commandText = _commandText + string.Format(" and tm_mouldno like '%{0}%'", txtSearch.Text);
            }

            if (cbSearch.SelectedIndex == 3)
            {
                commandText = _commandText + string.Format(" and tm_itemcode like '%{0}%'", txtSearch.Text);
            }

            List <FaList> list = new List <FaList>();

            using (IDataReader reader = DataService.GetInstance().ExecuteReader(commandText))
            {
                while (reader.Read())
                {
                    string chaseno  = reader.GetString(0);
                    string mouldno  = reader.GetString(1);
                    string itemcode = reader.GetString(2);
                    string currency = reader.GetString(3);
                    string amount   = reader.GetString(4);
                    string pdfid    = reader.GetString(5);

                    list.Add(new FaList {
                        ChaseNo = chaseno, MouldNo = mouldno, PartNo = itemcode, Currency = currency, Amount = amount, RefId = pdfid
                    });
                }
            }

            foreach (FaList item in list)
            {
                try
                {
                    string query = string.Format("select f_status from TB_FA_APPROVAL where f_chaseno = '{0}'", item.ChaseNo);
                    Debug.WriteLine(query);
                    string result = DataServiceNew.GetInstance().ExecuteScalar(query).ToString();

                    string status = result.StartsWith("IPO 1st") ? "採購1st承認中"
                        : result.StartsWith("IPO 2nd") ? "採購2nd承認中"
                        : result.StartsWith("Ringi") ? "稟議審批中"
                        : result.StartsWith("Review") ? "會計查核中"
                        : result.StartsWith("Final") ? "會計審批中"
                        : "會計輸入中";

                    dgvFa.Rows.Add(status, item.ChaseNo, item.MouldNo, item.PartNo, item.Currency, item.Amount, item.RefId);
                }
                catch
                {
                    continue;
                }
            }

            dgvFa.Sort(dgvFa.Columns[1], ListSortDirection.Ascending);

            lblTotal.Text = "ROWS COUNT: " + dgvFa.Rows.Count;
        }
コード例 #11
0
        private void download()
        {
            DataTable tmptable = new DataTable();

            string[] headers = { "リランフラグ", "伝票タイプ",    "勘定設定カテゴリ", "品目",   "品目テキスト", "数量",
                                 "納期",     "正味價格",     "価格単位",     "単位",   "品目グループ", "購買グループ","希望仕入先",
                                 "購買依頼者",  "保管場所",     "プラント",     "購買組織", "勘定コード",  "原価センタ", "固定資産番号",
                                 "稟議番号",   "納入先住所コード", "通貨コード",    "追跡番号", "項目テキスト", "WBS要素" };

            foreach (string header in headers)
            {
                tmptable.Columns.Add(header);
            }

            string flag = "", document = "", category = "", item = "", itemtext = "", qty = "";
            string deliverydate = "", amount = "", priceunit = "", level = "", itemgroup = "";
            string group = "", vendor = "", request = "", store = "", workspace = "", organization = "";
            string accountcode = "", costcentre = "", fixedassetcode = "", ringi = "", address = "";
            string currency = "", chaseno = "", projecttext = "", wbs = "", tmpfac = "", mpa = "", oemasset = "";

            string delivery = DateTime.Today.AddMonths(3).ToString("yyyy/MM/dd");

            string fixedValueText = "select fv_flag, fv_document, fv_item, fv_priceunit, fv_level, fv_store, fv_workspace, fv_organization, fv_address, fv_wbs from tb_betafixedvalue";

            GlobalService.reader = DataService.GetInstance().ExecuteReader(fixedValueText);

            while (GlobalService.reader.Read())
            {
                flag         = GlobalService.reader.GetString(0);
                document     = GlobalService.reader.GetString(1);
                item         = GlobalService.reader.GetString(2);
                priceunit    = GlobalService.reader.GetString(3);
                level        = GlobalService.reader.GetString(4);
                store        = GlobalService.reader.GetString(5);
                workspace    = GlobalService.reader.GetString(6);
                organization = GlobalService.reader.GetString(7);
                address      = GlobalService.reader.GetString(8);
                wbs          = GlobalService.reader.GetString(9);
            }
            GlobalService.reader.Close();
            //GlobalService.reader.Dispose();

            decimal finalAmount = 0;

            List <string> tmpList = new List <string>();

            foreach (DataGridViewRow row in dgvR3UL.Rows)
            {
                string rowChaseno  = row.Cells[0].Value.ToString();
                string rowCurrency = row.Cells[4].Value.ToString();
                string rowAmount   = row.Cells[5].Value.ToString();

                string q1     = string.Format("select f_fixedasset from TB_FA_APPROVAL where f_chaseno = '{0}' and f_mpa = 'Temp'", rowChaseno);
                string result = "";
                try
                {
                    result = DataServiceNew.GetInstance().ExecuteScalar(q1).ToString();
                }
                catch
                {
                    result = "";
                }

                string u1 = string.Format("update tb_betamould set tm_tmpfixedassetcode = '{0}' where tm_chaseno = '{1}' and tm_mpa = 'True'", result, rowChaseno);
                DataService.GetInstance().ExecuteNonQuery(u1);

                string updateText = string.Format("update tb_betamould set tm_deliverydate = '{0}' where tm_chaseno = '{1}'", delivery, rowChaseno);
                DataService.GetInstance().ExecuteNonQuery(updateText);

                string text = string.Format("select t.tm_category, t.tm_itemtext, t.tm_qty, t.tm_deliverydate, t.tm_amount" +
                                            ", m.mc_itemgroup, t.tm_group, t.tm_vendor_code, t.tm_request" +
                                            ", t.tm_accountcode, t.tm_costcentre, t.tm_fixedassetcode, t.tm_ringi_code, t.tm_currency, t.tm_chaseno, t.tm_projecttext, t.tm_tmpfixedassetcode, t.tm_mpa, t.tm_oemasset" +
                                            " from tb_betamould as t, tbm_mouldcode as m where t.tm_mouldcode_code = m.mc_mouldcode and t.tm_chaseno = '{0}'", rowChaseno);

                GlobalService.reader = DataService.GetInstance().ExecuteReader(text);

                //Debug.WriteLine(rowChaseno + rowCurrency + rowAmount);

                while (GlobalService.reader.Read())
                {
                    category       = GlobalService.reader.GetString(0);
                    itemtext       = GlobalService.reader.GetString(1);
                    qty            = GlobalService.reader.GetString(2);
                    deliverydate   = GlobalService.reader.GetString(3);
                    amount         = GlobalService.reader.GetString(4);
                    itemgroup      = GlobalService.reader.GetString(5);
                    group          = GlobalService.reader.GetString(6);
                    vendor         = GlobalService.reader.GetString(7);
                    request        = GlobalService.reader.GetString(8);
                    accountcode    = GlobalService.reader.GetString(9);
                    costcentre     = GlobalService.reader.GetString(10);
                    fixedassetcode = GlobalService.reader.GetString(11);
                    ringi          = GlobalService.reader.GetString(12);
                    currency       = GlobalService.reader.GetString(13);
                    chaseno        = GlobalService.reader.GetString(14);
                    projecttext    = GlobalService.reader.GetString(15);
                    tmpfac         = GlobalService.reader.GetString(16);
                    mpa            = GlobalService.reader.GetString(17);
                    oemasset       = GlobalService.reader.GetString(18);

                    if (vendor.Length == 9)
                    {
                        vendor = "0" + vendor;
                    }

                    if (mpa == "True" && tmpfac == "" && oemasset == "" && currency != "RMB")
                    {
                        MessageBox.Show("Temp Fixed Asset Code not saved yet. Please contact Account Division.");
                        return;
                    }

                    if (currency == "RMB")
                    {
                        double tmpAmount = Convert.ToDouble(amount);
                        if (mpa == "True")
                        {
                            tmpAmount = Convert.ToDouble(amount) / 2;

                            tmptable.Rows.Add(new object[] { flag, "Z008", category, item, itemtext, qty, deliverydate, tmpAmount,
                                                             priceunit, level, itemgroup, group, vendor, request, store, "2100", "2000", "", "", fixedassetcode,
                                                             ringi, "", currency, chaseno, projecttext, wbs });

                            tmptable.Rows.Add(new object[] { flag, "Z008", category, item, itemtext, qty, deliverydate, tmpAmount,
                                                             priceunit, level, itemgroup, group, vendor, request, store, "2100", "2000", "", "", fixedassetcode,
                                                             ringi, "", currency, chaseno, projecttext, wbs });
                        }
                        else
                        {
                            tmptable.Rows.Add(new object[] { flag, "Z008", category, item, itemtext, qty, deliverydate, tmpAmount,
                                                             priceunit, level, itemgroup, group, vendor, request, store, "2100", "2000", "", "", fixedassetcode,
                                                             ringi, "", currency, chaseno, projecttext, wbs });
                        }
                    }
                    else
                    {
                        if (mpa == "True")
                        {
                            decimal decamount = Convert.ToDecimal(amount) / 2;
                            amount = decamount.ToString();

                            tmptable.Rows.Add(new object[] { flag, document, category, item, itemtext, qty, deliverydate, amount,
                                                             priceunit, level, itemgroup, group, vendor, request, store, workspace, organization,
                                                             accountcode, costcentre, tmpfac, ringi, address, currency, chaseno, projecttext, wbs });
                        }
                        else
                        {
                            tmptable.Rows.Add(new object[] { flag, document, category, item, itemtext, qty, deliverydate, amount,
                                                             priceunit, level, itemgroup, group, vendor, request, store, workspace, organization,
                                                             accountcode, costcentre, fixedassetcode, ringi, address, currency, chaseno, projecttext, wbs });
                        }
                    }

                    tmpList.Add(rowChaseno);
                }
                GlobalService.reader.Close();
                GlobalService.reader.Dispose();
            }

            for (int i = 0; i < tmpList.Count; i++)
            {
                string tmpchaseno = tmpList[i].ToString();

                if (tmpchaseno.StartsWith("CM"))
                {
                    string commandText = string.Format("update tb_betamould set tm_st_code = 'D', tm_cndatetime = '{0}', tm_cndownload = 'Yes' where tm_chaseno = '{1}'", DateTime.Today.ToString("yyyy/MM/dd"), tmpchaseno);
                    DataService.GetInstance().ExecuteNonQuery(commandText);
                }
                else
                {
                    string commandText = string.Format("update tb_betamould set tm_st_code = 'D', tm_modify = 'Yes', tm_moulditemviewer = 'Yes' where tm_chaseno = '{0}'", tmpchaseno);
                    DataService.GetInstance().ExecuteNonQuery(commandText);
                }
            }

            if (tmptable.Rows.Count == 0)
            {
                MessageBox.Show("No Record can be downloaded");
            }
            else
            {
                //ExportTextUtil.ExportR3(tmptable, "R3 UL");
                DataView dv = tmptable.DefaultView;
                dv.Sort = "追跡番号 ASC";

                DataTable sorted = dv.ToTable();

                ExportXlsUtil.XlsUtil(sorted);
                GlobalService.fileUlList.Clear();
                this.Hide();
            }
        }