public void NewCardAndMerc(string[] merchantData, string DCPI, string DElavon, string status, string address, string simnr, string note, string terminalID, string physcialID, string[] CrD, string[] ClD) { UpdateInternalLists(); bool BDCPI = false; bool BDElavon = false; bool Bstatus = true; Date CrDate = ConvertToDate(CrD); Date ClDate = ConvertToDate(ClD); Merchant merchant = new Merchant(merchantData[0], merchantData[1], merchantData[2], merchantData[3], merchantData[4]); if (DCPI == "Forsinket") { BDCPI = true; } if (DElavon == "Forsinket") { BDElavon = true; } if (status != "Aktiv") { Bstatus = false; } Cardsystem card = new Cardsystem(merchant, CrDate, address, simnr, terminalID, physcialID, Bstatus, BDElavon, BDCPI, note, ClDate); cardsystems.Add(card); merchants.Add(merchant); repo.GetCardLists(cardsystems); repo.GetMercLists(merchants); }
public void ImportBackup() { string path = Path.Combine(Environment.CurrentDirectory, backup); int sheet = 0; Excel.Application xlApp = new Excel.Application(); xlApp.DisplayAlerts = false; Excel.Workbook xlWB; object misValue = Missing.Value; xlWB = xlApp.Workbooks.Open(path); foreach (Excel.Worksheet xlWS in xlWB.Worksheets) { if (sheet == 0) // if it is merchant sheet { for (int y = 2; y <= xlWS.UsedRange.Rows.Count; y++) { Merchant merc = new Merchant ( xlWS.Cells[y, 1].Text, xlWS.Cells[y, 2].Text, xlWS.Cells[y, 3].Text, xlWS.Cells[y, 4].Text, xlWS.Cells[y, 5].Text ); merchants.Add(merc); } sheet++; } else if (sheet == 1) // if it is cardsystem sheet { for (int y = 2; y <= xlWS.UsedRange.Rows.Count; y++) { Merchant merc = null; bool status = true; bool delayCPI = false; bool delayEvalon = false; Date crd = new Date(int.Parse(xlWS.Cells[y, 9].Text.Split('-')[0]), int.Parse(xlWS.Cells[y, 9].Text.Split('-')[1]), int.Parse(xlWS.Cells[y, 9].Text.Split('-')[2]), "Opretelses Dato"); Date cld = new Date(int.Parse(xlWS.Cells[y, 10].Text.Split('-')[0]), int.Parse(xlWS.Cells[y, 10].Text.Split('-')[1]), int.Parse(xlWS.Cells[y, 10].Text.Split('-')[2]), "Luknings Dato"); foreach (Merchant merchant in merchants) { if (merchant.ID == xlWS.Cells[y, 1].Text) { merc = merchant; break; } } if (xlWS.Cells[y, 2].Text != "Aktiv") { status = false; } if (xlWS.Cells[y, 3].Text == "Forsinket") { delayEvalon = true; } if (xlWS.Cells[y, 4].Text == "Forsinket") { delayCPI = true; } Cardsystem card = new Cardsystem ( merc, crd, xlWS.Cells[y, 5].Text, xlWS.Cells[y, 6].Text, xlWS.Cells[y, 7].Text, xlWS.Cells[y, 8].Text, status, delayEvalon, delayCPI, xlWS.Cells[y, 11].Text, cld ); cardsystems.Add(card); } sheet++; } else if (sheet == 2) // if it is mobilsystem sheet { for (int y = 2; y <= xlWS.UsedRange.Rows.Count; y++) { Merchant merc = null; bool status = true; bool delayNETS = false; bool delayEvalon = false; Date crd = new Date(int.Parse(xlWS.Cells[y, 9].Text.Split('-')[0]), int.Parse(xlWS.Cells[y, 9].Text.Split('-')[1]), int.Parse(xlWS.Cells[y, 9].Text.Split('-')[2]), "Opretelses Dato"); Date cld = new Date(int.Parse(xlWS.Cells[y, 10].Text.Split('-')[0]), int.Parse(xlWS.Cells[y, 10].Text.Split('-')[1]), int.Parse(xlWS.Cells[y, 10].Text.Split('-')[2]), "Luknings Dato"); foreach (Merchant merchant in merchants) { if (merchant.ID == xlWS.Cells[y, 1].Text) { merc = merchant; break; } } if (xlWS.Cells[y, 2].Text != "Aktiv") { status = false; } if (xlWS.Cells[y, 3].Text == "Forsinket") { delayEvalon = true; } if (xlWS.Cells[y, 4].Text == "Forsinket") { delayNETS = true; } Mobilesystem mobile = new Mobilesystem ( merc, crd, xlWS.Cells[y, 5].Text, xlWS.Cells[y, 6].Text, xlWS.Cells[y, 7].Text, xlWS.Cells[y, 8].Text, status, delayEvalon, delayNETS, xlWS.Cells[y, 11].Text, cld ); mobilesystems.Add(mobile); } sheet++; } } repo.GetCardLists(cardsystems); repo.GetMobileLists(mobilesystems); repo.GetMercLists(merchants); }