private void btnDownload_Click(object sender, EventArgs e)
        {
            DataTable sourceTable = new DataTable();

            string[] headers = { "Vendor Code", "Vendor Name", "Group", "Detail", "PayCurr", "PayTerms", "Request", "EDI", "Remarks" };

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

            string query = "select v_code, v_name, v_group, v_detail, v_paycurr, v_payterm, v_request, v_edi, v_remarks from tb_vendor";

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

            while (GlobalService.reader.Read())
            {
                string vcode    = GlobalService.reader.GetString(0);
                string vname    = GlobalService.reader.GetString(1);
                string vgroup   = GlobalService.reader.GetString(2);
                string vdetail  = GlobalService.reader.GetString(3);
                string vpaycurr = GlobalService.reader.GetString(4);
                string vpayterm = GlobalService.reader.GetString(5);
                string vrequest = GlobalService.reader.GetString(6);
                string vedi     = GlobalService.reader.GetString(7);
                string vremarks = GlobalService.reader.GetString(8);

                sourceTable.Rows.Add(new object[] { vcode, vname, vgroup, vdetail, vpaycurr, vpayterm, vrequest, vedi, vremarks });
            }
            GlobalService.reader.Close();
            GlobalService.reader.Dispose();

            ExportCsvUtil.ExportCsv(sourceTable, "", "VENDOR");
        }
        private void btnDownload_Click(object sender, EventArgs e)
        {
            DataTable table = (DataTable)dgvDisposalDetail.DataSource;

            table.Columns.RemoveAt(0);

            ExportCsvUtil.ExportCsv(table, "", "Disposal Record");
        }
Example #3
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            DataTable dlTable = new DataTable();

            string[] headers = { "日期",    "管理番號",      "担当者",      "Vendor Code",          "Vendor Name", "購買G", "部品番號",  "REV", "CUR", "交涉前金型費",
                                 "最終金型費", "交涉前金型費HKD", "最終金型費HKD", "最終金型費HKD (Quotation)", "CD總金額",       "入庫日", "CD計算月", "Remarks" };

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

            foreach (DataGridViewRow row in dgvCdReport.Rows)
            {
                string date         = row.Cells[1].Value.ToString();
                string reportno     = row.Cells[2].Value.ToString();
                string incharge     = row.Cells[3].Value.ToString();
                string vendorcode   = row.Cells[4].Value.ToString();
                string vendorname   = row.Cells[5].Value.ToString();
                string group        = row.Cells[6].Value.ToString();
                string partno       = row.Cells[7].Value.ToString();
                string rev          = row.Cells[8].Value.ToString();
                string currency     = row.Cells[9].Value.ToString();
                string amountbefore = row.Cells[10].Value.ToString();
                string amountafter  = row.Cells[11].Value.ToString();
                string amountsystem = row.Cells[0].Value.ToString();
                string remarks      = row.Cells[15].Value.ToString();

                string cdmonth = "";

                cdmonth = row.Cells[14].Value.ToString();

                if (cdmonth != "#N/A")
                {
                    cdmonth = Convert.ToDateTime(cdmonth).ToString("yyyy.MM");
                }

                string query           = string.Format("select cd_pricehkdbefore from tb_costdownreport where cd_itemcode = '{0}' and cd_rev = '{1}'", partno, rev);
                string amounthkdbefore = DataService.GetInstance().ExecuteScalar(query).ToString();

                string totalamount = DataChecking.getAmountByItemcodeRev(partno, rev);

                string totalamounthkd = DataChecking.getAmountHkdByItemcodeRev(partno, rev);

                string instockdate = DataChecking.getInstockdateByItemCodeRev(partno, rev);

                string cdtotal = (Convert.ToDecimal(amounthkdbefore) - Convert.ToDecimal(totalamounthkd)).ToString();

                dlTable.Rows.Add(new object[] { date, reportno, incharge, vendorcode, vendorname, group, partno, rev, currency, amountbefore, amountafter, amountsystem, amounthkdbefore,
                                                totalamounthkd, cdtotal, instockdate, cdmonth, remarks });
            }

            this.Cursor = Cursors.Default;

            ExportCsvUtil.ExportCsv(dlTable, "", "CD REPORT");
        }
Example #4
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            if (dgvCustomview.Visible == false)
            {
                MessageBox.Show("Please get the search result first");
                return;
            }

            try
            {
                DataTable dgvTable = (DataTable)(dgvCustomview.DataSource);

                this.Cursor = Cursors.WaitCursor;

                /*for (int i = 0; i < dgvTable.Columns.Count; i++)
                 *  Debug.WriteLine("AA: "+ dgvTable.Columns[i].ColumnName.ToString());
                 *
                 * if (cbCriteria.SelectedIndex != 0)
                 * {
                 *  foreach (string column in colList)
                 *  {
                 *      Debug.WriteLine("BB: " + column);
                 *      if (dgvTable.Columns.Contains(column))
                 *          dgvTable.Columns.Remove(column);
                 *  }
                 * }*/
                DataTable tmptable = new DataTable();

                if (cbCriteria.SelectedIndex != 0)
                {
                    tmptable = new DataView(dgvTable).ToTable(false, colList.ToArray());
                }
                else
                {
                    tmptable = dgvTable;
                }

                if (dgvTable.Rows.Count > 0)
                {
                    ExportCsvUtil.ExportCsv(tmptable, "", "CUSTOM" + DateTime.Today.ToString("yyyyMMdd"));
                }
                else
                {
                    MessageBox.Show("No Record can be downloaded");
                }

                this.Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message + ex.StackTrace);
                WriteText(ex.Message + ex.StackTrace);
                MessageBox.Show("Log file downloaded");
            }
        }
        private void btnTemplate_Click(object sender, EventArgs e)
        {
            DataTable templateTable = new DataTable();

            string[] headers = { "Chase No.", "Vendor",    "Vendor Name", "Part No.", "Rev",    "Mould No.",    "Status",        "Mould Code", "Currency", "Amount",
                                 "MPA",       "FA (Temp)", "FA",          "PO",       "Issued", "In Stock 50%", "In Stock Date", "OEM Asset",  "Remarks" };

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

            string query = "select t.tm_chaseno, t.tm_vendor_code, v.v_name, t.tm_itemcode, t.tm_rev, t.tm_mouldno, t.tm_status, t.tm_mouldcode_code, t.tm_currency, t.tm_amount" +
                           ", t.tm_mpa, t.tm_tmpfixedassetcode, t.tm_fixedassetcode, t.tm_po, t.tm_poissued, t.tm_instockdate50, t.tm_oemasset, t.tm_rm, t.tm_instockdate from" +
                           " tb_betamould as t, tb_vendor as v where t.tm_vendor_code = v.v_code and (t.tm_instockdate = 'Received' or t.tm_instockdate50 = 'Received') and tm_st_code != 'C'";

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

            while (GlobalService.reader.Read())
            {
                string chaseno    = GlobalService.reader.GetString(0);
                string vendor     = GlobalService.reader.GetString(1);
                string vendorname = GlobalService.reader.GetString(2);
                string itemcode   = GlobalService.reader.GetString(3);
                string rev        = GlobalService.reader.GetString(4);
                string mouldno    = GlobalService.reader.GetString(5);
                string status     = GlobalService.reader.GetString(6);
                string mouldcode  = GlobalService.reader.GetString(7);
                string currency   = GlobalService.reader.GetString(8);
                string amount     = GlobalService.reader.GetString(9);
                string mpa        = GlobalService.reader.GetString(10);
                string tmpfac     = GlobalService.reader.GetString(11);
                string fac        = GlobalService.reader.GetString(12);
                string po         = GlobalService.reader.GetString(13);
                string poissued   = GlobalService.reader.GetString(14);
                string is50       = GlobalService.reader.GetString(15);
                string oemasset   = GlobalService.reader.GetString(16);
                string remarks    = GlobalService.reader.GetString(17);
                string instock    = GlobalService.reader.GetString(18);

                templateTable.Rows.Add(new object[] { chaseno, vendor, vendorname, itemcode, rev, mouldno, status, mouldcode, currency,
                                                      amount, mpa, tmpfac, fac, po, poissued, is50, instock, oemasset, remarks });
            }
            GlobalService.reader.Close();
            GlobalService.reader.Dispose();

            if (templateTable.Rows.Count == 0)
            {
                MessageBox.Show("No record can be downloaded");
            }
            else
            {
                ExportCsvUtil.ExportCsv(templateTable, "", "TEMPLATE");
            }
        }
Example #6
0
        private void GetIdleData(int months)
        {
            List <string> tableList = new List <string>();

            string query = "select table_name from information_schema.tables where table_name like 'TB_hk%'";

            using (IDataReader reader = DataService.GetInstance().ExecuteReader(query))
            {
                while (reader.Read())
                {
                    tableList.Add(reader.GetString(0).Trim());
                }
            }

            tableList = tableList.Distinct().ToList();

            DataTable table = new DataTable();

            string[] headers = { "lastaccess", "filename", "owner", "path", "vpath" };
            foreach (string header in headers)
            {
                table.Columns.Add(header);
            }

            int range = 6 + months;

            int total = tableList.Count;
            int count = 0;

            foreach (string t in tableList)
            {
                string staffid = t.Substring(3);
                string staff   = AdUtil.getUsernameByUserId(staffid, "kmhk.local");
                string q1      = string.Format("select r_lastaccess, r_filename, r_owner, r_path, r_vpath from " + t + " where datediff(month, r_lastaccess, getdate()) >= {0} and r_owner = N'{1}'", range, staff);
                using (IDataReader reader = DataService.GetInstance().ExecuteReader(q1))
                {
                    while (reader.Read())
                    {
                        table.Rows.Add(new object[] { reader.GetString(0).Trim(), reader.GetString(1).Trim(), reader.GetString(2).Trim(), reader.GetString(3).Trim(), reader.GetString(4).Trim() });
                    }
                }

                SetCountText(count++ + " / " + total);
            }

            foreach (DataTable dt in CloneTableList(table, 500000))
            {
                Invoke((Action)(() => { ExportCsvUtil.ExportCsv(dt, "", ""); }));
            }
        }
Example #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                DataTable table = ImportExcel2007.TranslateToTable(ofd.FileName);

                DataTable errorTable = new DataTable();
                errorTable.Columns.Add("error");

                foreach (DataRow row in table.Rows)
                {
                    //string owner = row.ItemArray[0].ToString().Trim();
                    string path = row.ItemArray[0].ToString().Trim();

                    FileInfo info = new FileInfo(path);

                    try
                    {
                        using (var impersonation = new ImpersonatedUser("itadmin", "kmhk.local", "Cv%^yHfv"))
                        {
                            FileSecurity fs = info.GetAccessControl();
                            AuthorizationRuleCollection rules = fs.GetAccessRules(true, true, typeof(NTAccount));

                            fs.SetAccessRuleProtection(true, false);
                            //if (owner == "Ho Kin Hang(何健恒,Ken)")
                            //fs.AddAccessRule(new FileSystemAccessRule(@"kmas\as1600055", FileSystemRights.FullControl, AccessControlType.Allow));
                            //else
                            fs.AddAccessRule(new FileSystemAccessRule(@"kmas\as1600048", FileSystemRights.FullControl, AccessControlType.Allow));

                            File.SetAccessControl(path, fs);
                        }
                    }
                    catch
                    {
                        errorTable.Rows.Add(path);
                        continue;
                    }
                }

                if (errorTable.Rows.Count > 0)
                {
                    ExportCsvUtil.ExportCsv(errorTable, "", "");
                }
            }
        }
Example #8
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            DataTable errorTable = new DataTable();

            errorTable.Columns.Add("missed");

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                DataTable table = ImportExcel2007.TranslateToTable(ofd.FileName);

                using (var impersonation = new ImpersonatedUser("itadmin", "kmhk.local", "Ed@a*9kj"))
                {
                    foreach (DataRow row in table.Rows)
                    {
                        string file = row.ItemArray[0].ToString().Trim();
                        string user = row.ItemArray[1].ToString().Trim();
                        string path = row.ItemArray[2].ToString().Trim();

                        if (!File.Exists(path))
                        {
                            errorTable.Rows.Add(path);
                            continue;
                        }

                        string filename  = Path.GetFileName(path);
                        string newPath   = path.Replace(@"\\kdthk-dm1", "");
                        string directory = @"\\kdthk-dm1\dvdstorage$" + newPath.Substring(0, newPath.LastIndexOf(@"\") + 1);

                        if (!Directory.Exists(directory))
                        {
                            Directory.CreateDirectory(directory);
                        }

                        File.Copy(path, directory + filename, true);
                    }
                }

                if (errorTable.Rows.Count > 0)
                {
                    ExportCsvUtil.ExportCsv(errorTable, "", "missed");
                }
            }
        }
        private void btnDownload_Click(object sender, EventArgs e)
        {
            if (dgvRelationship.Rows.Count == 0)
            {
                return;
            }

            string mouldno = dgvRelationship.Rows[0].Cells[0].Value.ToString();

            DataTable dltable = (DataTable)dgvRelationship.DataSource;

            /*string[] headers = { "Mould No.", "Part No.", "Type", "Remarks" };
             *
             * foreach (string header in headers)
             *  dltable.Columns.Add(header);*/

            ExportCsvUtil.ExportCsv(dltable, "", mouldno);
        }
Example #10
0
        public static void DisplayGlobalAddressList()
        {
            DataTable table = new DataTable();

            table.Columns.Add("Name", typeof(string));
            table.Columns.Add("Company", typeof(string));
            table.Columns.Add("Address", typeof(string));

            Outlook.Application outlook = new Outlook.Application();

            Outlook.AddressList gal = outlook.Session.GetGlobalAddressList();

            if (gal != null)
            {
                for (int i = 1; i < gal.AddressEntries.Count - 1; i++)
                {
                    try
                    {
                        Outlook.AddressEntry addressEntry = gal.AddressEntries[i];

                        if (addressEntry.AddressEntryUserType == Outlook.OlAddressEntryUserType.olExchangeUserAddressEntry || addressEntry.AddressEntryUserType == Outlook.OlAddressEntryUserType.olExchangeRemoteUserAddressEntry)
                        {
                            Outlook.ExchangeUser exUser = addressEntry.GetExchangeUser();
                            Debug.WriteLine(exUser.Name + "    " + exUser.CompanyName);
                            table.Rows.Add(exUser.Name, exUser.CompanyName, exUser.PrimarySmtpAddress);
                        }

                        if (addressEntry.AddressEntryUserType == Outlook.OlAddressEntryUserType.olExchangeDistributionListAddressEntry)
                        {
                            Outlook.ExchangeDistributionList exList = addressEntry.GetExchangeDistributionList();
                            Debug.WriteLine(exList.Name + "   " + exList.PrimarySmtpAddress);
                            table.Rows.Add(exList.Name, "", "");
                        }
                    }
                    catch
                    {
                        continue;
                    }
                }
            }

            ExportCsvUtil.ExportCsv(table, "", "");
        }
Example #11
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            if (dgvExpenseTransfer.Rows.Count == 0)
            {
                MessageBox.Show("No record can be downloaded");
                return;
            }

            DataTable dlTable = table.Copy();

            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.", "Epson管理no." };

            dlTable.Columns.Remove("etid");
            dlTable.Columns["etdate"].ColumnName       = "Date";
            dlTable.Columns["etincharge"].ColumnName   = "担當";
            dlTable.Columns["etasset"].ColumnName      = "資產";
            dlTable.Columns["etitemcode"].ColumnName   = "Parts no.";
            dlTable.Columns["etrev"].ColumnName        = "Rev";
            dlTable.Columns["etmouldno"].ColumnName    = "Mould no.";
            dlTable.Columns["ettype"].ColumnName       = "Type";
            dlTable.Columns["etmouldcode"].ColumnName  = "Mould Code";
            dlTable.Columns["etcurrency"].ColumnName   = "Cur";
            dlTable.Columns["etamount"].ColumnName     = "Amount";
            dlTable.Columns["etvendor"].ColumnName     = "Vendor Code";
            dlTable.Columns["etvendorname"].ColumnName = "Vendor Name";
            dlTable.Columns["etchaseno"].ColumnName    = "追跡番号";
            dlTable.Columns["etremarks"].ColumnName    = "Remarks";
            dlTable.Columns["etpo"].ColumnName         = "P/O no.";
            dlTable.Columns["etissued"].ColumnName     = "P/O Issue Date";
            dlTable.Columns["etinstock"].ColumnName    = "P/O Instock Date";
            dlTable.Columns["etdebit"].ColumnName      = "Debit Note Apply Date";
            dlTable.Columns["etsales"].ColumnName      = "Fixed Asset Sales Apply Date";
            dlTable.Columns["etringi"].ColumnName      = "Ringi no.";
            dlTable.Columns["etfinish"].ColumnName     = "Finish";
            dlTable.Columns["etepsonno"].ColumnName    = "Epson管理no.";


            ExportCsvUtil.ExportCsv(dlTable, "", "經費轉移");
        }
Example #12
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            if (dgvR3UL.Rows.Count == 0)
            {
                MessageBox.Show("No record can be downloaded");
                return;
            }
            DataTable tmptable = new DataTable();

            string[] headers = { "Chase No.", "Vendor", "Part No.", "Rev", "Mould No.", "Mould Code", "Div.", "MPA", "Currency", "Amount",
                                 "Remarks",   "OEM Asset" };

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

            foreach (DataGridViewRow row in dgvR3UL.Rows)
            {
                string chaseno   = row.Cells[2].Value.ToString();
                string vendor    = row.Cells[3].Value.ToString();
                string itemcode  = row.Cells[4].Value.ToString();
                string rev       = row.Cells[5].Value.ToString();
                string mouldno   = row.Cells[6].Value.ToString();
                string mouldcode = row.Cells[7].Value.ToString();
                string status    = row.Cells[8].Value.ToString();
                string mpa       = row.Cells[9].FormattedValue.ToString();
                string currency  = row.Cells[10].Value.ToString();
                string amount    = row.Cells[11].Value.ToString();
                string remarks   = row.Cells[12].Value.ToString();
                string oemasset  = row.Cells[13].Value.ToString();

                tmptable.Rows.Add(new object[] { chaseno, vendor, itemcode, rev, mouldno, mouldcode, status, mpa, currency, amount, remarks, oemasset });
            }

            ExportCsvUtil.ExportCsv(tmptable, "", "R3UL ALL");
        }
 private void Download(DataTable table)
 {
     ExportCsvUtil.ExportCsv(table, "", "DISPOSAL");
 }
Example #14
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            if (dgvIssuePo.Rows.Count == 0)
            {
                MessageBox.Show("No Record can be downloaded");
                return;
            }
            else
            {
                this.Cursor = Cursors.WaitCursor;

                DataTable dlTable = new DataTable();
                string[]  headers = { "Chase No.", "Mould No.", "Item Code", "Rev", "Vendor", "Vendor Name", "購買依賴 No.", "PO", "PO Rev" };
                foreach (string header in headers)
                {
                    dlTable.Columns.Add(header);
                }

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

                    if (chaseno.StartsWith("CN"))
                    {
                        continue;
                    }

                    /*string query = string.Format("select t.tm_chaseno, t.tm_mouldno, t.tm_itemcode, t.tm_rev, t.tm_vendor_code, v.v_name, t.tm_po from tb_betamould as t" +
                     *  ", tb_vendor as v where t.tm_vendor_code = v.v_code and t.tm_chaseno = '{0}'", chaseno);
                     *
                     * GlobalService.reader = DataService.GetInstance().ExecuteReader(query);
                     *
                     * while (GlobalService.reader.Read())
                     * {
                     *  string rdrChaseno = GlobalService.reader.GetString(0);
                     *  string rdrMouldno = GlobalService.reader.GetString(1);
                     *  string rdrItemcode = GlobalService.reader.GetString(2);
                     *  string rdrRev = GlobalService.reader.GetString(3);
                     *  string rdrVendor = GlobalService.reader.GetString(4);
                     *  string rdrVendorname = GlobalService.reader.GetString(5);
                     *  string rdrpo = GlobalService.reader.GetString(6);
                     *
                     *  dlTable.Rows.Add(new object[] { rdrChaseno, rdrMouldno, rdrItemcode, rdrRev, rdrVendor, rdrVendorname, "", rdrpo, "" });
                     * }
                     * GlobalService.reader.Close();
                     * GlobalService.reader.Dispose();*/
                    string status = row.Cells[0].Value.ToString();

                    string mouldno    = row.Cells[2].Value.ToString();
                    string itemcode   = row.Cells[3].Value.ToString();
                    string rev        = row.Cells[4].Value.ToString();
                    string vendor     = row.Cells[5].Value.ToString();
                    string vendorname = DataChecking.getVendorName(vendor);
                    string po         = "";
                    string porev      = "";

                    if (status == "移管對象")
                    {
                        po = DataChecking.getTransferNo(chaseno);
                    }

                    dlTable.Rows.Add(new object[] { chaseno, mouldno, itemcode, rev, vendor, vendorname, "", po, porev });
                }

                //ExportXlsUtil.XlsUtil(dlTable);

                this.Cursor = Cursors.Default;
                ExportCsvUtil.ExportCsv(dlTable, "", "PO LIST");
            }
        }
        private void btnDownload_Click(object sender, EventArgs e)
        {
            DataTable sourcetable = (DataTable)dgvRingi.DataSource;

            ExportCsvUtil.ExportCsv(sourcetable, "", "Ringi list");
        }
Example #16
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            DataTable table = (DataTable)dgvHistory.DataSource;

            ExportCsvUtil.ExportCsv(table, "", "");
        }
Example #17
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog()
            {
                Filter = "Excel Files |*.xls"
            };

            DataTable resulttable = new DataTable();

            string[] headers = { "狀態",               "Chase No.",    "Part No.",     "Rev",        "Mould No.",      "Div.",              "Type",          "Pcs",
                                 "Currency",         "Amount",       "AmountHkd",    "Mpa",        "Fixedassetcode", "TmpFixedassetcode",
                                 "Quantity",         "Ringi",        "Model",        "PO",         "PO Issued",      "Category",          "ItemText",      "Project Text",
                                 "Vendor",           "Vendor Name",  "Group",        "Mould Code", "Remarks",        "In Stock 50",       "In Stock Date",
                                 "Check Date",       "Cav",          "Weight",       "Equipment",  "Shot",           "Vertical",          "Horizontal",    "Height",
                                 "In Stock Remarks", "Collect Date", "Pass Remarks", "OEM Asset",  "Account Code",
                                 "Cost Centre",      "Created By" };

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

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

                DataTable caltable = ImportXlsUtil.TranslateToTable(filename);

                Debug.WriteLine(caltable.Columns[0].ColumnName);

                if (caltable.Columns.Count != 1)
                {
                    MessageBox.Show("Error format");
                }
                else
                {
                    foreach (DataRow row in caltable.Rows)
                    {
                        string chaseno = row.ItemArray[0].ToString();

                        string query = string.Format("select st_status, tm_chaseno, tm_itemcode, tm_rev, tm_mouldno" +
                                                     ", tm_status, tm_type, tm_pcs, tm_currency, tm_amount, tm_amounthkd, tm_mpa" +
                                                     ", tm_fixedassetcode, tm_tmpfixedassetcode, tm_qty, tm_ringi_code, tm_model, tm_po" +
                                                     ", tm_poissued, tm_category, tm_itemtext, tm_projecttext, tm_vendor_code, v_name" +
                                                     ", v_group, tm_mouldcode_code, tm_rm, tm_instockdate50, tm_instockdate, tm_checkdate" +
                                                     ", tm_cav, tm_weight, tm_accessory, tm_camera, tm_vertical, tm_horizontal, tm_height" +
                                                     ", tm_instockremarks, tm_collectdate, tm_passremarks, tm_oemasset, tm_accountcode" +
                                                     ", tm_costcentre, tm_createdby from TB_BETAMOULD, TB_BETAQSTATUS, TB_VENDOR" +
                                                     " where tm_vendor_code = v_code and tm_st_code = st_code and tm_chaseno = '{0}'", chaseno);

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

                        while (GlobalService.reader.Read())
                        {
                            string status         = GlobalService.reader.GetString(0);
                            string chaseNo        = GlobalService.reader.GetString(1);
                            string itemcode       = GlobalService.reader.GetString(2);
                            string rev            = GlobalService.reader.GetString(3);
                            string mouldno        = GlobalService.reader.GetString(4);
                            string div            = GlobalService.reader.GetString(5);
                            string type           = GlobalService.reader.GetString(6);
                            string pcs            = GlobalService.reader.GetString(7);
                            string currency       = GlobalService.reader.GetString(8);
                            string amount         = GlobalService.reader.GetString(9);
                            string amounthkd      = GlobalService.reader.GetString(10);
                            string mpa            = GlobalService.reader.GetString(11);
                            string fa             = GlobalService.reader.GetString(12);
                            string tmpfa          = GlobalService.reader.GetString(13);
                            string qty            = GlobalService.reader.GetString(14);
                            string ringi          = GlobalService.reader.GetString(15);
                            string model          = GlobalService.reader.GetString(16);
                            string po             = GlobalService.reader.GetString(17);
                            string poissued       = GlobalService.reader.GetString(18);
                            string category       = GlobalService.reader.GetString(19);
                            string itemtext       = GlobalService.reader.GetString(20);
                            string projecttext    = GlobalService.reader.GetString(21);
                            string vendor         = GlobalService.reader.GetString(22);
                            string vendorname     = GlobalService.reader.GetString(23);
                            string vgroup         = GlobalService.reader.GetString(24);
                            string mouldcode      = GlobalService.reader.GetString(25);
                            string remarks        = GlobalService.reader.GetString(26);
                            string instock50      = GlobalService.reader.GetString(27);
                            string instock        = GlobalService.reader.GetString(28);
                            string checkdate      = GlobalService.reader.GetString(29);
                            string cav            = GlobalService.reader.GetString(30);
                            string weight         = GlobalService.reader.GetString(31);
                            string equipment      = GlobalService.reader.GetString(32);
                            string shot           = GlobalService.reader.GetString(33);
                            string vertical       = GlobalService.reader.GetString(34);
                            string horizontal     = GlobalService.reader.GetString(35);
                            string height         = GlobalService.reader.GetString(36);
                            string instockremarks = GlobalService.reader.GetString(37);
                            string collectdate    = GlobalService.reader.GetString(38);
                            string passremarks    = GlobalService.reader.GetString(39);
                            string oemasset       = GlobalService.reader.GetString(40);
                            string accountcode    = GlobalService.reader.GetString(41);
                            string costcentre     = GlobalService.reader.GetString(42);
                            string createdby      = GlobalService.reader.GetString(43);

                            resulttable.Rows.Add(new object[] { status, chaseNo, itemcode, rev, mouldno, div, type,
                                                                pcs, currency, amount, amounthkd, mpa, fa, tmpfa, qty, ringi, model, po, poissued,
                                                                category, itemtext, projecttext, vendor, vendorname, vgroup, mouldcode, remarks,
                                                                instock50, instock, checkdate, cav, weight, equipment, shot, vertical, horizontal,
                                                                height, instockremarks, collectdate, passremarks, oemasset, accountcode, costcentre,
                                                                createdby });
                        }
                        GlobalService.reader.Close();
                    }

                    ExportCsvUtil.ExportCsv(resulttable, "", "DLRECORD");
                }
            }
        }
Example #18
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            string[] headers = { "CHASE NO.", "PART NO.", "REV",         "COMMON MOULD NO.", "MOULD NO.",
                                 "DIV.",      "TYPE",     "FIXED ASSET", "TEMP FIXED ASSET", "ITEM TEXT","PROJECT TEXT",
                                 "MODEL",     "PO",       "VENDOR",      "MOULDCODE",        "REMARKS",  "IN STOCK" };

            DataTable table = new DataTable();

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

            string query = "select tm_chaseno, tm_itemcode, tm_rev, tm_mouldno, tm_status, tm_type" +
                           ", tm_fixedassetcode, tm_tmpfixedassetcode, tm_itemtext, tm_projecttext, tm_model, tm_po" +
                           ", tm_vendor_code, tm_mouldcode_code, tm_rm, tm_instockdate from tb_betamould" +
                           " where (tm_model = '2P7' or tm_model = '2R1' or tm_model = '2R2' or tm_model = '3PN' or tm_model = '3PP' or tm_model = '3PR')";

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

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

            while (GlobalService.reader.Read())
            {
                string chaseno     = GlobalService.reader.GetString(0);
                string itemcode    = GlobalService.reader.GetString(1);
                string rev         = GlobalService.reader.GetString(2);
                string mouldno     = GlobalService.reader.GetString(3);
                string div         = GlobalService.reader.GetString(4);
                string type        = GlobalService.reader.GetString(5);
                string fac         = GlobalService.reader.GetString(6);
                string tmpfac      = GlobalService.reader.GetString(7);
                string itemtext    = GlobalService.reader.GetString(8);
                string projecttext = GlobalService.reader.GetString(9);
                string model       = GlobalService.reader.GetString(10);
                string po          = GlobalService.reader.GetString(11);
                string vendor      = GlobalService.reader.GetString(12);
                string mouldcode   = GlobalService.reader.GetString(13);
                string remarks     = GlobalService.reader.GetString(14);
                string instockdate = GlobalService.reader.GetString(15);

                mlist.Add(mouldno);

                table.Rows.Add(new object[] { chaseno, itemcode, rev, "-", mouldno, div, type, fac, tmpfac, itemtext,
                                              projecttext, model, po, vendor, mouldcode, remarks, instockdate });
            }
            GlobalService.reader.Close();

            List <string> ml = new List <string>();
            List <string> il = new List <string>();

            foreach (string mould in mlist)
            {
                string query2 = string.Format("select sc_itemcode from tb_setcommon where sc_mouldno = '{0}' and sc_oldmouldno != ''", mould);

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

                if (!GlobalService.reader.HasRows)
                {
                    GlobalService.reader.Close();
                    continue;
                }
                else
                {
                    while (GlobalService.reader.Read())
                    {
                        string scitemcode = GlobalService.reader.GetString(0);
                        il.Add(scitemcode);
                    }
                    GlobalService.reader.Close();
                }
            }

            foreach (string mould in mlist)
            {
                string query2 = string.Format("select sc_itemcode, sc_mouldno, sc_type, sc_remarks from tb_setcommon where sc_mouldno = '{0}' and sc_oldmouldno = ''", mould);

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

                if (!GlobalService.reader.HasRows)
                {
                    GlobalService.reader.Close();
                    continue;
                }
                else
                {
                    while (GlobalService.reader.Read())
                    {
                        string scitemcode = GlobalService.reader.GetString(0);
                        string scmouldno  = GlobalService.reader.GetString(1);
                        string sctype     = GlobalService.reader.GetString(2);
                        string scremarks  = GlobalService.reader.GetString(3);

                        table.Rows.Add(new object[] { "-", scitemcode, "-", scmouldno, "", "-", sctype, "-", "-", "-",
                                                      "-", "-", "-", "-", "-", scremarks, "-" });
                    }
                    GlobalService.reader.Close();
                }
            }

            foreach (string item in il)
            {
                string query3 = string.Format("select tm_chaseno, tm_itemcode, tm_rev, sc_mouldno, tm_mouldno, tm_status, tm_type" +
                                              ", tm_fixedassetcode, tm_tmpfixedassetcode, tm_itemtext, tm_projecttext, tm_model, tm_po" +
                                              ", tm_vendor_code, tm_mouldcode_code, tm_rm, tm_instockdate from tb_betamould, tb_setcommon" +
                                              " where sc_itemcode = tm_itemcode and tm_mouldno = sc_oldmouldno and tm_itemcode = '{0}'", item);

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

                while (GlobalService.reader.Read())
                {
                    string chaseno     = GlobalService.reader.GetString(0);
                    string itemcode    = GlobalService.reader.GetString(1);
                    string rev         = GlobalService.reader.GetString(2);
                    string omouldno    = GlobalService.reader.GetString(3);
                    string mouldno     = GlobalService.reader.GetString(4);
                    string div         = GlobalService.reader.GetString(5);
                    string type        = GlobalService.reader.GetString(6);
                    string fac         = GlobalService.reader.GetString(7);
                    string tmpfac      = GlobalService.reader.GetString(8);
                    string itemtext    = GlobalService.reader.GetString(9);
                    string projecttext = GlobalService.reader.GetString(10);
                    string model       = GlobalService.reader.GetString(11);
                    string po          = GlobalService.reader.GetString(12);
                    string vendor      = GlobalService.reader.GetString(13);
                    string mouldcode   = GlobalService.reader.GetString(14);
                    string remarks     = GlobalService.reader.GetString(15);
                    string instockdate = GlobalService.reader.GetString(16);

                    table.Rows.Add(new object[] { chaseno, itemcode, rev, omouldno, mouldno, div, type, fac, tmpfac, itemtext,
                                                  projecttext, model, po, vendor, mouldcode, remarks, instockdate });
                }
                GlobalService.reader.Close();
            }

            ExportCsvUtil.ExportCsv(table, "", "SET COMMON");
        }
Example #19
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            DataTable table = (DataTable)dgvModelReport.DataSource;

            ExportCsvUtil.ExportCsv(table, "", "Model Report");
        }
Example #20
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            DataTable dlTable = new DataTable();

            string[] headers = { "Vendor Code", "Vendor Name", "I/C",    "Model",            "Part No.",            "Rev",    "Mould No.", "Type",    "Mould Code", "Curr", "Amount", "Amount (HKD)",
                                 "Remarks",     "品目テキスト",      "固定資産番号", "追跡番号",             "訂單號碼",                "Status", "發行日",       "50% MPA",
                                 "部品認定/仕様書状況",  "合格/承認日",      "予定回收日",  "I/C&Issued Month", "Not Yet Payment HKD", "Oem" };

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

            foreach (DataGridViewRow row in dgvPoCollection.Rows)
            {
                string passstatus  = row.Cells[0].Value.ToString();
                string passdate    = row.Cells[1].Value.ToString();
                string collectdate = row.Cells[2].Value.ToString();
                string vendorcode  = row.Cells[3].Value.ToString();
                string vendorname  = row.Cells[4].Value.ToString();
                string group       = row.Cells[5].Value.ToString();
                //string group = DataChecking.getVendorGroup(vendorcode);
                string model     = row.Cells[6].Value.ToString();
                string partno    = row.Cells[7].Value.ToString();
                string rev       = row.Cells[8].Value.ToString();
                string mouldno   = row.Cells[9].Value.ToString();
                string status    = row.Cells[10].Value.ToString();
                string mouldcode = row.Cells[11].Value.ToString();
                string currency  = row.Cells[12].Value.ToString();
                string amount    = row.Cells[13].Value.ToString();
                string amounthkd = row.Cells[14].Value.ToString();
                string remarks   = row.Cells[15].Value.ToString();
                string itemtext  = row.Cells[16].Value.ToString();
                string fac       = row.Cells[17].Value.ToString();
                string chaseno   = row.Cells[18].Value.ToString();
                string pono      = row.Cells[19].Value.ToString();
                string porev     = row.Cells[20].Value.ToString();
                string stname    = row.Cells[21].Value.ToString();
                string issued    = row.Cells[22].Value.ToString();
                string mpa       = row.Cells[23].Value.ToString();
                string oem       = row.Cells[24].Value.ToString();

                string icissued  = "";
                string mpaamount = "";

                if (issued != "")
                {
                    try
                    {
                        DateTime yymm = Convert.ToDateTime(issued);
                        icissued = group + yymm.ToString("yyyyMM");
                    }
                    catch
                    {
                        icissued = "";
                    }
                }
                if (stname == "已付50% MPA")
                {
                    mpaamount = amounthkd == "-" || amounthkd == "" ? "-" : (Convert.ToDecimal(amounthkd) / 2).ToString();
                }
                else
                {
                    mpaamount = amounthkd;
                }

                dlTable.Rows.Add(new object[] { vendorcode, vendorname, group, model, partno, rev, mouldno, status, mouldcode, currency, amount, amounthkd,
                                                remarks, itemtext, fac, chaseno, pono, stname, issued, mpa, passstatus, passdate, collectdate, icissued, mpaamount, oem });
            }

            ExportCsvUtil.ExportCsv(dlTable, "", "MOULD PO COLLECTION");
        }
Example #21
0
 private void btnExport_Click(object sender, EventArgs e)
 {
     ExportCsvUtil.ExportCsv(GlobalService.MasterTable, "", "DL_" + DateTime.Today.ToString("yyyyMMdd"));
 }
Example #22
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            DataTable sourceTable = new DataTable();

            string[] headers = { "Chase No.", "Vendor", "Vendor Name", "I/C", "MPA", "In Stock 50%", "In Stock Date", "Pay Terms", "Pay Curr", "PO", "PO Rev", "Issued", "Amount (HKD)" };

            sourceTable = (DataTable)dgvPaymentList.DataSource;

            ExportCsvUtil.ExportCsv(sourceTable, "", "PAYMENT LIST");

            /*if (cbOption.SelectedIndex == 0)
             * {
             *  sourceTable = (DataTable)dgvPaymentList.DataSource;
             *
             *  ExportCsvUtil.ExportCsv(sourceTable, "", "PAYMENT LIST");
             * }
             *
             * if (cbOption.SelectedIndex == 1)
             * {
             *  if (dgvPaymentList.Rows.Count == 0)
             *      return;
             *
             *  foreach (string header in headers)
             *      sourceTable.Columns.Add(header);
             *
             *  foreach (DataGridViewRow row in dgvPaymentList.Rows)
             *  {
             *      string vendor = row.Cells[0].Value.ToString();
             *      string vendorname = row.Cells[1].Value.ToString();
             *      string incharge = row.Cells[2].Value.ToString();
             *      string payterms = row.Cells[3].Value.ToString();
             *      string paycurr = row.Cells[4].Value.ToString();
             *
             *      string query = string.Format("select tm_po, tm_porev, tm_poissued, tm_amounthkd from tb_betamould where tm_vendor_code = '{0}'", vendor);
             *
             *      GlobalService.reader = DataService.GetInstance().ExecuteReader(query);
             *
             *      while (GlobalService.reader.Read())
             *      {
             *          string po = GlobalService.reader.GetString(0);
             *          string porev = GlobalService.reader.GetString(1);
             *          string poissued = GlobalService.reader.GetString(2);
             *          string amounthkd = GlobalService.reader.GetString(3);
             *
             *          sourceTable.Rows.Add(new object[] { vendor, vendorname, incharge, payterms, paycurr, po, porev, poissued, amounthkd });
             *      }
             *      GlobalService.reader.Close();
             *      GlobalService.reader.Dispose();
             *  }
             *  ExportCsvUtil.ExportCsv(sourceTable, "", "PAYMENT LIST WITH PO (ALL)");
             * }
             * if (cbOption.SelectedIndex == 2)
             * {
             *  if (dgvPaymentList.SelectedRows == null)
             *      return;
             *
             *  foreach (string header in headers)
             *      sourceTable.Columns.Add(header);
             *
             *  foreach (DataGridViewRow row in dgvPaymentList.SelectedRows)
             *  {
             *      string vendor = row.Cells[0].Value.ToString();
             *      string vendorname = row.Cells[1].Value.ToString();
             *      string incharge = row.Cells[2].Value.ToString();
             *      string payterms = row.Cells[3].Value.ToString();
             *      string paycurr = row.Cells[4].Value.ToString();
             *
             *
             *      string query = string.Format("select tm_po, tm_porev, tm_poissued, tm_amounthkd from tb_betamould where tm_vendor_code = '{0}'", vendor);
             *
             *      GlobalService.reader = DataService.GetInstance().ExecuteReader(query);
             *
             *      while (GlobalService.reader.Read())
             *      {
             *          string po = GlobalService.reader.GetString(0);
             *          string porev = GlobalService.reader.GetString(1);
             *          string poissued = GlobalService.reader.GetString(2);
             *          string amounthkd = GlobalService.reader.GetString(3);
             *
             *          sourceTable.Rows.Add(new object[] { vendor, vendorname, incharge, payterms, paycurr, po, porev, poissued, amounthkd });
             *      }
             *      GlobalService.reader.Close();
             *      GlobalService.reader.Dispose();
             *  }
             *  ExportCsvUtil.ExportCsv(sourceTable, "", "PAYMENT LIST WITH PO");
             * }*/
        }
        private void btnDownload_Click(object sender, EventArgs e)
        {
            DataTable tmptable = (DataTable)(dgvInStockHistory.DataSource);

            ExportCsvUtil.ExportCsv(tmptable, "", "INSTOCKRECORD");
        }