Ejemplo n.º 1
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            DataTable dlTable = (DataTable)dgvModifyCheck.DataSource;

            ExportXlsUtil.XlsUtil(dlTable);
            //ExportCsvUtil.ExportCsv(dlTable, "", "MODIFYCHECK");
        }
        private void btnDownload_Click(object sender, EventArgs e)
        {
            DataTable downloadTable = new DataTable();

            downloadTable.Columns.Add("Mould Code");
            downloadTable.Columns.Add("Type");
            downloadTable.Columns.Add("Content (Jp)");
            downloadTable.Columns.Add("Content (Eng)");
            downloadTable.Columns.Add("Content (Chin)");
            downloadTable.Columns.Add("Item Group");

            string query = "select mc_mouldcode, mc_type, mc_contentjp, mc_contenteng, mc_contentchin, mc_itemgroup from tbm_mouldcode";

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

            while (GlobalService.reader.Read())
            {
                string mouldcode   = GlobalService.reader.GetString(0);
                string type        = GlobalService.reader.GetString(1);
                string contentjp   = GlobalService.reader.GetString(2);
                string contenteng  = GlobalService.reader.GetString(3);
                string contentchin = GlobalService.reader.GetString(4);
                string itemgroup   = GlobalService.reader.GetString(5);

                downloadTable.Rows.Add(new object[] { mouldcode, type, contentjp, contenteng, contentchin, itemgroup });
            }
            GlobalService.reader.Close();
            GlobalService.reader.Dispose();

            ExportXlsUtil.XlsUtil(downloadTable);
        }
Ejemplo n.º 3
0
        private void tsbtnDownload_Click(object sender, EventArgs e)
        {
            DataTable table = new DataTable();

            string[] headers = { "ChaseNo.", "PartNo.", "Rev", "MouldNo.", "Model", "Currency", "Amount", "Amount(HKD)", "Remarks", "Vendor", "VendorName", "Ringi" };
            foreach (string header in headers)
            {
                table.Columns.Add(header);
            }

            foreach (DataGridViewRow row in dgvFa.Rows)
            {
                string chaseno    = row.Cells[0].Value.ToString();
                string partno     = row.Cells[1].Value.ToString();
                string rev        = row.Cells[14].Value.ToString();
                string mould      = row.Cells[13].Value.ToString();
                string model      = row.Cells[2].Value.ToString();
                string currency   = row.Cells[5].Value.ToString().Trim();
                string amount     = row.Cells[6].Value.ToString().Trim();
                string amounthkd  = row.Cells[7].Value.ToString().Trim();
                string vendor     = row.Cells[8].Value.ToString().Trim();
                string vendorname = row.Cells[9].Value.ToString().Trim();
                string ringi      = row.Cells[10].Value.ToString();
                string remarks    = row.Cells[17].Value.ToString();

                table.Rows.Add(chaseno, partno, rev, mould, model, currency, amount, amounthkd, remarks, vendor, vendorname, ringi);
            }

            ExportXlsUtil.XlsUtil(table);
        }
Ejemplo n.º 4
0
        private void btnDownloadCn_Click(object sender, EventArgs e)
        {
            DataTable tmptable = new DataTable();

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

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

            foreach (DataGridViewRow row in dgvIssuePo.Rows)
            {
                string chaseno = row.Cells[1].Value.ToString().Trim();
                if (chaseno.StartsWith("MS"))
                {
                    continue;
                }

                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_currency, t.tm_projecttext" +
                                            " from tb_betamould as t, tbm_mouldcode as m where t.tm_mouldcode_code = m.mc_mouldcode and t.tm_chaseno = '{0}'", chaseno);

                using (IDataReader reader = DataService.GetInstance().ExecuteReader(text))
                {
                    while (reader.Read())
                    {
                        string category    = reader.GetString(0).Trim();
                        string itemText    = reader.GetString(1).Trim();
                        string quantity    = reader.GetString(2).Trim();
                        string delivery    = reader.GetString(3).Trim();
                        string amount      = reader.GetString(4).Trim();
                        string itemGroup   = reader.GetString(5).Trim();
                        string group       = reader.GetString(6).Trim();
                        string vendor      = reader.GetString(7).Trim();
                        string request     = reader.GetString(8).Trim();
                        string currency    = reader.GetString(9).Trim();
                        string projectText = reader.GetString(10).Trim();

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

                        tmptable.Rows.Add(new object[] { "", "Z008", category, "", itemText, quantity, delivery, amount,
                                                         "1", "PC", itemGroup, group, vendor, request, "", "2100", "2000", "", "", "",
                                                         "", "", currency, chaseno, projectText, "", "", "", "" });
                    }
                }
            }

            ExportXlsUtil.XlsUtil(tmptable);
        }
        private void btnTemplate_Click(object sender, EventArgs e)
        {
            DataTable templatetable = new DataTable();

            string[] headers = { "Ringi No.", "Model Name", "Subject", "Model Code", "Part No.", "Currency", "Amount", "Vendor", "Remarks" };

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

            ExportXlsUtil.XlsUtil(templatetable);
        }
        private void btnTemplateTM_Click(object sender, EventArgs e)
        {
            DataTable templateTable = new DataTable();

            string[] headers = { "Chase No.", "Check Date", "In Stock Remarks", "In Stock Date" };

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

            ExportXlsUtil.XlsUtil(templateTable);
        }
Ejemplo n.º 7
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            DataTable dltable = (DataTable)dgvDisposalDetail.DataSource;

            if (dltable.Rows.Count > 50)
            {
                frmDownloadType downloadtype = new frmDownloadType(dltable);
                downloadtype.ShowDialog();
            }
            else
            {
                ExportXlsUtil.XlsUtil(dltable);
            }
        }
Ejemplo n.º 8
0
        private void btnTemplate_Click(object sender, EventArgs e)
        {
            DataTable tbTemplate = new DataTable();

            string[] headers = { "日期",     "管理番號",  "担當者",        "Vendor Code", "Vendor Name", "購買G", "部品番號", "REV", "CUR",
                                 "交涉前金型費", "最終金型費", "交涉前金型費 HKD", "最終金型費 HKD",   "CD 總金額",      "CD %" };

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

            ExportXlsUtil.XlsUtil(tbTemplate);
        }
Ejemplo n.º 9
0
        private void btnTemplate_Click(object sender, EventArgs e)
        {
            DataTable tbTemplate = new DataTable();

            string[] headers = { "Date",      "担當",      "資產",      "Parts no.",      "Rev",              "Mould no.",             "Type",                         "Mould Code", "Cur", "Amount", "Vendor Code", "Vendor",
                                 "追跡番号",      "Remarks", "P/O no.", "P/O Issue Date", "P/O Instock Date", "Debit Note Apply Date", "Fixed Asset Sales Apply Date",
                                 "Ringi no.", "Finish",  "Epson管理no." };

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

            ExportXlsUtil.XlsUtil(tbTemplate);
        }
        private void btnDownload_Click(object sender, EventArgs e)
        {
            list = new List <string>();

            foreach (DataGridViewRow row in dgvKdc.SelectedRows)
            {
                string chaseno = row.Cells[1].Value.ToString();

                list.Add(chaseno);
            }

            DataTable table = mergeTable(list);

            for (int i = 0; i < list.Count; i++)
            {
                string query = string.Format("update tb_betamould set tm_st_code = 'K', tm_modify = 'Yes', tm_moulditemviewer = 'Yes' where tm_chaseno = '{0}'", list[i]);
                DataService.GetInstance().ExecuteNonQuery(query);
            }

            ExportXlsUtil.XlsUtil(table);

            this.loadData();
        }
 private void Open(DataTable table)
 {
     ExportXlsUtil.XlsUtil(table);
 }
        private void btnDownload_Click(object sender, EventArgs e)
        {
            if (dgvRingi.SelectedRows == null)
            {
                return;
            }

            DataTable downloadtable = new DataTable();

            string[] headers = { "Ringi", "Model Name", "Subject", "Model Code", "Part No.", "Currency", "Amount", "Vendor", "Remarks" };

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

            string ringi = dgvRingi.SelectedRows[0].Cells[0].Value.ToString();

            string modelname = this.txtModelName.Text;

            string subject = this.txtSubject.Text;

            for (int i = 0; i < dgvPreRingi.Rows.Count - 1; i++)
            {
                string modelcode = "", partno = "", currency = "", amount = "", vendor = "", remarks = "";

                if (!Convert.IsDBNull(dgvPreRingi.Rows[i].Cells[0].Value))
                {
                    modelcode = dgvPreRingi.Rows[i].Cells[0].Value.ToString();
                }

                if (!Convert.IsDBNull(dgvPreRingi.Rows[i].Cells[1].Value))
                {
                    partno = (dgvPreRingi.Rows[i].Cells[1].Value).ToString();
                }

                if (!Convert.IsDBNull(dgvPreRingi.Rows[i].Cells[2].Value))
                {
                    currency = (dgvPreRingi.Rows[i].Cells[2].Value).ToString();
                }

                if (!Convert.IsDBNull(dgvPreRingi.Rows[i].Cells[3].Value))
                {
                    amount = (dgvPreRingi.Rows[i].Cells[3].Value).ToString();
                }

                if (!Convert.IsDBNull(dgvPreRingi.Rows[i].Cells[4].Value))
                {
                    vendor = (dgvPreRingi.Rows[i].Cells[4].Value).ToString();
                }

                if (!Convert.IsDBNull(dgvPreRingi.Rows[i].Cells[5].Value))
                {
                    remarks = (dgvPreRingi.Rows[i].Cells[5].Value).ToString();
                }

                downloadtable.Rows.Add(new object[] { ringi, modelname, subject, modelcode, partno, currency, amount, vendor, remarks });
            }

            /*foreach (DataGridViewRow row in dgvPreRingi.Rows)
             * {
             *  string modelcode = "", partno = "", currency = "", amount = "", vendor = "", remarks = "";
             *
             *  if (!Convert.IsDBNull(row.Cells[0].Value))
             *      modelcode = row.Cells[0].Value.ToString();
             *
             *  if (!Convert.IsDBNull(row.Cells[1].Value))
             *      partno = row.Cells[1].Value.ToString();
             *
             *  if (!Convert.IsDBNull(row.Cells[2].Value))
             *      currency = row.Cells[2].Value.ToString();
             *
             *  if (!Convert.IsDBNull(row.Cells[3].Value))
             *      amount = row.Cells[3].Value.ToString();
             *
             *  if (!Convert.IsDBNull(row.Cells[4].Value))
             *      vendor = row.Cells[4].Value.ToString();
             *
             *  if (!Convert.IsDBNull(row.Cells[5].Value))
             *      remarks = row.Cells[5].Value.ToString();
             *
             *  downloadtable.Rows.Add(new object[] { ringi, modelname, subject, modelcode, partno, currency, amount, vendor, remarks });
             * }*/

            ExportXlsUtil.XlsUtil(downloadtable);
        }
        private void btnTemplate_Click(object sender, EventArgs e)
        {
            DataTable table = new DataTable();

            string[] headers = { "chaseno",     "partno",     "rev",    "mould",        "div",         "type",        "currency",      "amount",     "amounthkd",   "mpa",        "fa",             "tmpfa",  "qty", "common",
                                 "itemtext",    "request",    "indate", "deliverydate", "projecttext", "model",       "po",            "porev",      "issued",      "category",   "ringi",          "vendor",
                                 "mouldcode",   "status",     "owner",  "oem",          "remarks",     "instockdate", "instockdate50", "pgroup",     "accountcode", "costcentre",
                                 "checkdate",   "checkdate2", "cav",    "weight",       "equipment",   "shot",        "vertical",      "horizontal", "height",      "ismodify",   "instockremarks",
                                 "collectdate", "pass",       "pcs",    "cnis50",       "cntax",       "cndate",      "cnsenddate" };

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

            foreach (DataGridViewRow row in dgvQuotation.Rows)
            {
                string _chaseno = row.Cells[2].Value.ToString().Trim();

                string query = string.Format("select tm_chaseno, tm_itemcode, tm_rev, tm_mouldno, tm_status, tm_type, tm_currency, tm_amount, tm_amounthkd, tm_mpa" +
                                             ", tm_fixedassetcode, tm_tmpfixedassetcode, tm_qty, tm_common, tm_itemtext, tm_request, tm_indate, tm_deliverydate, tm_projecttext, tm_model" +
                                             ", tm_po, tm_porev, tm_poissued, tm_category, tm_ringi_code, tm_vendor_code, tm_mouldcode_code, tm_st_code, tm_owner, tm_oemasset, tm_rm" +
                                             ", tm_instockdate, tm_instockdate50, tm_group, tm_accountcode, tm_costcentre, tm_checkdate, tm_checkdate2, tm_cav, tm_weight, tm_accessory" +
                                             ", tm_camera, tm_vertical, tm_horizontal, tm_height, tm_ismodify, tm_instockremarks, tm_collectdate, tm_passremarks, tm_pcs, tm_is50, tm_tax, tm_cndatetime" +
                                             ", tm_cnsendtime from tb_betamould where tm_chaseno = '{0}'", _chaseno);

                using (IDataReader reader = DataService.GetInstance().ExecuteReader(query))
                {
                    while (reader.Read())
                    {
                        string chaseno        = reader.GetString(0).Trim();
                        string partno         = reader.GetString(1).Trim();
                        string rev            = reader.GetString(2).Trim();
                        string mould          = reader.GetString(3).Trim();
                        string div            = reader.GetString(4).Trim();
                        string type           = reader.GetString(5).Trim();
                        string curr           = reader.GetString(6).Trim();
                        string amt            = reader.GetString(7).Trim();
                        string amthkd         = reader.GetString(8).Trim();
                        string mpa            = reader.GetString(9).Trim();
                        string fa             = reader.GetString(10).Trim();
                        string tmpfa          = reader.GetString(11).Trim();
                        string qty            = reader.GetString(12).Trim();
                        string common         = reader.GetString(13).Trim();
                        string itemtext       = reader.GetString(14).Trim();
                        string request        = reader.GetString(15).Trim();
                        string indate         = reader.GetString(16).Trim();
                        string deliverydate   = reader.GetString(17).Trim();
                        string projecttext    = reader.GetString(18).Trim();
                        string model          = reader.GetString(19).Trim();
                        string po             = reader.GetString(20).Trim();
                        string porev          = reader.GetString(21).Trim();
                        string issued         = reader.GetString(22).Trim();
                        string category       = reader.GetString(23).Trim();
                        string ringi          = reader.GetString(24).Trim();
                        string vendor         = reader.GetString(25).Trim();
                        string mouldcode      = reader.GetString(26).Trim();
                        string status         = reader.GetString(27).Trim();
                        string owner          = reader.GetString(28).Trim();
                        string oem            = reader.GetString(29).Trim();
                        string remarks        = reader.GetString(30).Trim();
                        string instock        = reader.GetString(31).Trim();
                        string instock50      = reader.GetString(32).Trim();
                        string group          = reader.GetString(33).Trim();
                        string ac             = reader.GetString(34).Trim();
                        string cc             = reader.GetString(35).Trim();
                        string checkdate      = reader.GetString(36).Trim();
                        string checkdate2     = reader.GetString(37).Trim();
                        string cav            = reader.GetString(38).Trim();
                        string weight         = reader.GetString(39).Trim();
                        string equipment      = reader.GetString(40).Trim();
                        string shot           = reader.GetString(41).Trim();
                        string vertical       = reader.GetString(42).Trim();
                        string horizontal     = reader.GetString(43).Trim();
                        string height         = reader.GetString(44).Trim();
                        string ismodify       = reader.GetString(45).Trim();
                        string instockremarks = reader.GetString(46).Trim();
                        string collectdate    = reader.GetString(47).Trim();
                        string pass           = reader.GetString(48).Trim();
                        string pcs            = reader.GetString(49).Trim();
                        string is50           = reader.GetString(50).Trim();
                        string tax            = reader.GetString(51).Trim();
                        string cndate         = reader.GetString(52).Trim();
                        string cnsenddate     = reader.GetString(53).Trim();

                        table.Rows.Add(chaseno, partno, rev, mould, div, type, curr, amt, amthkd, mpa, fa, tmpfa, qty, common, itemtext, request, indate, deliverydate,
                                       projecttext, model, po, porev, issued, category, ringi, vendor, mouldcode, status, owner, oem, remarks, instock, instock50, group,
                                       ac, cc, checkdate, checkdate2, cav, weight, equipment, shot, vertical, horizontal, height, ismodify, instockremarks, collectdate, pass,
                                       pcs, is50, tax, cndate, cnsenddate);
                    }
                }
            }
            ExportXlsUtil.XlsUtil(table);
        }
Ejemplo n.º 14
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            DataTable dlTable = (DataTable)dgvVnOnly.DataSource;

            ExportXlsUtil.XlsUtil(dlTable);
        }
Ejemplo n.º 15
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();
            }
        }
Ejemplo n.º 16
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            if (cbDisposalType.SelectedIndex == 0)
            {
                MessageBox.Show("Please select Disposal type first");
                return;
            }

            bool allInstock        = true;
            bool allCommonSelected = true;

            List <string> selectedMouldList = new List <string>();
            List <string> singleChasenoList = new List <string>();
            List <string> commonChasenoList = new List <string>();
            List <string> totalChasenoList  = new List <string>();

            foreach (DataGridViewRow row in dgvDisposal.Rows)
            {
                string selected = row.Cells[0].Value.ToString();

                string qstatus = row.Cells[1].Value.ToString();

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

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

                string commonmouldno = row.Cells[4].Value.ToString();

                string div = row.Cells[7].Value.ToString();

                if (selected == "True")
                {
                    if (qstatus != "入庫済" && qstatus != "-")
                    {
                        allInstock = false;
                    }
                    else
                    {
                        if (div != "Set" && div != "Common")
                        {
                            singleChasenoList.Add(chaseno);
                        }
                        else
                        {
                            if (chaseno != "-")
                            {
                                commonChasenoList.Add(chaseno);
                            }
                            selectedMouldList.Add(commonmouldno);
                        }
                    }
                }
                else
                {
                    if (div != "Single")
                    {
                        if (selectedMouldList.Contains(row.Cells[4].Value.ToString()))
                        {
                            allCommonSelected = false;
                        }
                    }
                }
            }

            if (!allInstock)
            {
                MessageBox.Show("Must be In-Stock before Disposal");
                return;
            }

            if (!allCommonSelected)
            {
                MessageBox.Show("Some parts of Common Mould are not selected. Please check your selection");
                return;
            }

            //MessageBox.Show("OK");

            switch (MessageBox.Show("Data checking finished. Are you sure to dispose selected items?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
            case System.Windows.Forms.DialogResult.Yes:

                //SINGLE
                singleChasenoList = singleChasenoList.Distinct().ToList();

                for (int k = 0; k < singleChasenoList.Count; k++)
                {
                    string selectedChaseno = singleChasenoList[k];

                    string qstatus = "";

                    string singleQuery = "";

                    if (cbDisposalType.SelectedIndex == 2)    //日本生產本部提出
                    {
                        qstatus = "D3";
                    }
                    else
                    {
                        qstatus = "D1";
                    }

                    singleQuery = string.Format("update tb_betamould set tm_st_code = '{0}' where tm_chaseno = '{1}'", qstatus, selectedChaseno);

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

                //COMMON
                commonChasenoList = commonChasenoList.Distinct().ToList();

                for (int i = 0; i < commonChasenoList.Count; i++)
                {
                    string selectedChaseno = commonChasenoList[i];

                    string qstatus = "";

                    string commonQuery = "";

                    if (cbDisposalType.SelectedIndex == 2)
                    {
                        qstatus = "D3";
                    }
                    else
                    {
                        qstatus = "D1";
                    }

                    commonQuery = string.Format("update tb_betamould set tm_st_code = '{0}' where tm_chaseno = '{1}'", qstatus, selectedChaseno);

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

                MessageBox.Show("Record has been saved");

                totalChasenoList = totalChasenoList.Concat(singleChasenoList).Concat(commonChasenoList).ToList();
                totalChasenoList = totalChasenoList.Distinct().ToList();

                DataTable outputtable = new DataTable();

                string[] headers = { "Disposal Type",          "Status",                   "Chase No.",     "Mould No.",        "Part No.",            "Rev",                "Div",        "Type", "Amount (HKD)", "FA", "Vendor", "Vendor Name",
                                     "P2003Ctrl No.",          "P2003Answers",             "P2003Result",   "P2003Updated",     "P2004Ctrl No.",       "P2004Answers",
                                     "P2004Result",            "P2004Updated",             "KDC Ctrl No.",  "KDC Issued",       "KDC RPS Answers",     "KDC Seisan Answers", "KDC Result",
                                     "KDC Updated",            "Asset Description",        "Cap.date",      "Acquis.val.HKD",   "Accum.dep.HKD",       "Closing Month",
                                     "Book val.HKD1",          "FinancialYear",            "Book val.HKD2", "Disposal Ringi",   "Disposal Report No.",
                                     "Disposal Report Issued", "Disposal Report Received", "Vendor Result", "FA Disposal Date", "Disposal Remarks" };

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

                string resultStatus = "", resultChaseno = "", resultMouldno = "", resultPartno = "", resultType = "", resultFa = "", resultVendor = "";
                string resultVendorname = "", resultRemarks = "", resultDiv = "", resultAmountHkd = "", resultRev = "";

                string resultKdcNo = DataChecking.getKdcReportNo();

                for (int c = 0; c < totalChasenoList.Count; c++)
                {
                    string chasenoFromList = totalChasenoList[c];

                    Debug.WriteLine(chasenoFromList);

                    string disposalType = cbDisposalType.SelectedItem.ToString();

                    string query = string.Format("select st.st_status, t.tm_chaseno, t.tm_mouldno, t.tm_itemcode, t.tm_rev, t.tm_status, t.tm_type, t.tm_amounthkd, t.tm_fixedassetcode" +
                                                 ", t.tm_vendor_code, v.v_name, t.tm_rm from tb_betamould as t, tb_vendor as v, tb_betaqstatus as st where t.tm_vendor_code = v.v_code" +
                                                 " and t.tm_st_code = st.st_code and t.tm_chaseno = '{0}'", chasenoFromList);

                    Debug.WriteLine("QUERY: " + query);

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

                    while (GlobalService.reader.Read())
                    {
                        resultStatus     = GlobalService.reader.GetString(0);
                        resultChaseno    = GlobalService.reader.GetString(1);
                        resultMouldno    = GlobalService.reader.GetString(2);
                        resultPartno     = GlobalService.reader.GetString(3);
                        resultRev        = GlobalService.reader.GetString(4);
                        resultDiv        = GlobalService.reader.GetString(5);
                        resultType       = GlobalService.reader.GetString(6);
                        resultAmountHkd  = GlobalService.reader.GetString(7);
                        resultFa         = GlobalService.reader.GetString(8);
                        resultVendor     = GlobalService.reader.GetString(9);
                        resultVendorname = GlobalService.reader.GetString(10);
                        resultRemarks    = GlobalService.reader.GetString(11);

                        Debug.WriteLine("RESULT: " + resultStatus + "   " + resultChaseno);

                        outputtable.Rows.Add(new object[] { disposalType, resultStatus, resultChaseno, resultMouldno, resultPartno, resultRev, resultDiv,
                                                            resultType, resultAmountHkd, resultFa, resultVendor, resultVendorname, "", "", "", "", "", "", "", "", resultKdcNo, "", "", "", "", "", "", "", "", ""
                                                            , "", "", "", "", "", "", "", "", "", "", "" });

                        /*outputtable.Rows.Add(new object[]{disposalType, resultStatus, resultChaseno, resultMouldno, resultPartno, resultType,
                         * resultFa, resultVendor, resultVendorname, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
                         * , "", "", "", "", "", "", "", ""});*/
                    }
                    GlobalService.reader.Close();
                    GlobalService.reader.Dispose();

                    string insertText = string.Format("insert into tb_disposaldetail (dd_type, dd_chaseno,dd_kdcno) values ('{0}', '{1}', '{2}')", disposalType, chasenoFromList, resultKdcNo);
                    DataService.GetInstance().ExecuteNonQuery(insertText);
                }

                ExportXlsUtil.XlsUtil(outputtable);

                GlobalService.ChaseNoList.Clear();
                this.Hide();

                break;

            case System.Windows.Forms.DialogResult.No:
                break;
            }
        }
Ejemplo n.º 17
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            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();

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

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                DataTable caltable = ImportExcel2003.TranslateToTable(ofd.FileName);

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

                foreach (DataRow row in caltable.Rows)
                {
                    string rowchaseno  = row.ItemArray[0].ToString();
                    string rowcurrency = row.ItemArray[8].ToString();
                    string rowamount   = row.ItemArray[9].ToString();

                    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);

                    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 == "")
                        {
                            MessageBox.Show("Temp Fixed Asset Code not saved yet. Please contact Account Division.");
                            return;
                        }

                        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();
                }

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

                    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
                {
                    DataView dv = tmptable.DefaultView;
                    dv.Sort = "追跡番号 ASC";

                    DataTable sorted = dv.ToTable();

                    ExportXlsUtil.XlsUtil(sorted);
                }
            }
        }