private void populateClients(ExcelH excel, string path) { //creates new excel applciation app = new Excel.Application(); string ifcClientDirectory = path; string[] temp = Directory.GetDirectories(ifcClientDirectory); foreach (string str in temp) { Customer tempCust = new Customer(); tempCust.percentage = new string[26]; tempCust.category = new string[26]; tempCust.Path = path; tempCust.filename = Path.GetFileName(str); string[] chunks = tempCust.filename.Split(new char[] { '-' }); if (chunks.Length < 2) { tempCust.CustomerID = "null"; tempCust.CustomerName = "null"; continue; } else { string tempID = chunks[1].Trim(); string tempname = chunks[0].Trim(); tempCust.CustomerID = tempID; tempCust.CustomerName = tempname; } tempCust.Path += "\\" + tempCust.filename; excel.OpenSourceWorkbook(this.getworkbook(tempCust)); transfer(excel, tempCust, tempCust.Path); excel.addClient(tempCust); } closesourcebk(); app.Quit(); }
private void RunButton_Click(object sender, EventArgs e) { ExcelH excelhelper = new ExcelH(); DBAccess db = new DBAccess(); ArrayList clients = excelhelper.getclients(excelhelper,folderpath); foreach (Customer Cust in clients) { string maininfo = Cust.CustomerID + "','" + Cust.CustomerName; db.InsertData_into_maininfo(maininfo); for(int cat=0; cat<Cust.category.Count();cat++){ string custallo = Cust.CustomerID + "','" +Cust.category[cat] + "','"+Cust.percentage[cat]; db.InsertData_into_custallo(custallo); } } dataGridView1.DataSource = db.SelectData_from_maininfo(); dataGridView2.DataSource = db.SelectData_from_custallo(); }
private void RunButton_Click(object sender, EventArgs e) { ExcelH excelhelper = new ExcelH(); DBAccess db = new DBAccess(); ArrayList clients = excelhelper.getclients(excelhelper, folderpath); foreach (Customer Cust in clients) { string maininfo = Cust.CustomerID + "','" + Cust.CustomerName; db.InsertData_into_maininfo(maininfo); for (int cat = 0; cat < Cust.category.Count(); cat++) { string custallo = Cust.CustomerID + "','" + Cust.category[cat] + "','" + Cust.percentage[cat]; db.InsertData_into_custallo(custallo); } } dataGridView1.DataSource = db.SelectData_from_maininfo(); dataGridView2.DataSource = db.SelectData_from_custallo(); }
private void transfer(ExcelH excel, Customer tempcust, string p) { int i = 0; Excel.Worksheet ws = excel.getSourceWorkSheet("OBJECTIVES & ASSET ALLOCATION"); while (i < 26) { if (ws.Cells[13 + i, 4].Value2 != null) { tempcust.percentage[i] = ws.Cells[13 + i, 4].Value2.ToString(); } else { tempcust.percentage[i] = "0"; } tempcust.category[i] = ws.Cells[13 + i, 3].Value2.ToString(); i++; } excel.closesourcebk(); }
public ArrayList getclients(ExcelH excel, string path) { populateClients(excel, path); return(Clients); }
public ArrayList getclients(ExcelH excel, string path) { populateClients( excel, path); return Clients; }