Пример #1
0
        private void tsbtnDownload_Click(object sender, EventArgs e)
        {
            DataTable output = new DataTable();

            string[] headers = { "Serial No.", "Type of Creation", "Asset Class",       "Company Code",         "Number of similar assets",
                                 "x01",        "x02",              "x03",               "x04",                  "x05",                     "x06",                  "Description",          "Additional asset description", "x07", "x08",
                                 "x09",        "x10",              "x11",               "Managed historically", "x12",                     "Inventory indicator",  "Inventory note",       "x13",
                                 "x14",        "Cost center",      "Resp. cost center", "x15",                  "Location",                "x16",                  "License plate number", "x17",
                                 "x18",        "x19",              "x20",               "x21",                  "Evalutation group 5",     "x22",                  "x23",                  "x24",                          "x25", "Asset purchased new",
                                 "x26",        "x27",              "x28",               "Type name",            "x29",                     "x30",                  "x31",                  "x32",                          "x33", "Depreciation key(01)","Useful life(01)",
                                 "x34",        "x35",              "x36",               "x37",                  "Depreciation key(02)",    "Useful life(02)" };
            foreach (string header in headers)
            {
                output.Columns.Add(header);
            }

            foreach (DataGridViewRow row in dgvInput.Rows)
            {
                string approval   = row.Cells[0].Value.ToString();
                string assetClass = row.Cells[1].Value.ToString();

                if (approval != "Approve")
                {
                    continue;
                }
                if (assetClass == "Please select")
                {
                    continue;
                }

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

                string query = string.Format("update TB_FA_APPROVAL set f_status = 'CM 1st Approval 2', f_downloaded = 'Yes' where f_chaseno = '{0}'", chaseNo);
                DataService.GetInstance().ExecuteNonQuery(query);

                string text = string.Format("select f_assetclass, f_desc, f_assetdesc, f_costcenter, f_resp, f_location, f_vendor, f_ringi from TB_FA_APPROVAL where f_status = 'CM 1st Approval 2' and f_chaseno = '{0}'", chaseNo);

                using (IDataReader reader = DataService.GetInstance().ExecuteReader(text))
                {
                    while (reader.Read())
                    {
                        string ac         = reader.GetString(0);
                        string desc       = reader.GetString(1);
                        string ad         = reader.GetString(2);
                        string costcenter = reader.GetString(3);
                        string resp       = reader.GetString(4);
                        string location   = reader.GetString(5);
                        string vendor     = reader.GetString(6);
                        string ringi      = reader.GetString(7);
                        string itemcode   = desc.Substring(1);
                        itemcode = itemcode.Substring(0, 10);

                        output.Rows.Add("1", "10", ac, "1404", "1", "", "", "", "", "", "", desc, ad, "", "", "", "", "", "X", "", "X", itemcode, "", "", costcenter, resp, "", location, "", vendor, "", "", "", "", "", "00000", "", "", "", "", "X", "", "", "", ringi, "", "", "", "", "", "HE06", "6", "", "", "", "", "ME06", "6");
                    }
                }
            }

            if (output.Rows.Count > 0)
            {
                ExportTextUtil.ExportText(output, "Fa Upload");
                this.LoadData();
            }
            else
            {
                MessageBox.Show("No record can be downloaded.");
            }
        }
 private void tsbtnDownload_Click(object sender, EventArgs e)
 {
     ExportTextUtil.ExportText(outputTable, "FA Record - Asset Class");
 }
 private void tsbtnDownload_Click(object sender, EventArgs e)
 {
     ExportTextUtil.ExportText(table, "FA Application");
 }