static void Main() { // Using a simple iterator. ListClass listClass1 = new ListClass(); foreach (int i in listClass1) { System.Console.Write(i + " "); } // Output: 0 1 2 3 4 5 6 7 8 9 System.Console.WriteLine(); // Using a named iterator. ListClass test = new ListClass(); foreach (int n in test.SampleIterator(1, 10)) { System.Console.Write(n + " "); } // Output: 1 2 3 4 5 6 7 8 9 10 System.Console.WriteLine(); // Using multiple yield statements. foreach (string element in new TestClass()) { System.Console.Write(element); } // Output: With an iterator, more than one value can be returned. System.Console.WriteLine(); }
public void TestIndexerPositive() { var jane = new Person { Name = "Jane" }; var mary = new Person { Name = "Mary" }; var jack = new Person { Name = "Jack" }; var nameList1 = new List<Person>() { jane, jack, mary }; var nameList2 = new List<Person>() { jane, jack, mary }; var class1 = new ListClass<Person>(nameList1); var class2 = new ListClass<Person>(nameList2); Assert.IsTrue(_compare.Compare(class1, class2).AreEqual); }
public void Compare_IndexerCompareAndPropertyComparePositive() { var jane = new Person {Name = "Jane"}; var mary = new Person {Name = "Mary"}; var jack = new Person {Name = "Jack"}; var nameList1 = new List<Person>() {jane, jack, mary}; var nameList2 = new List<Person>() {jane, jack, mary}; var class1 = new ListClass<Person>(nameList1); var class2 = new ListClass<Person>(nameList2); var compare = new CompareLogic(); Assert.IsTrue(compare.Compare(class1, class2).AreEqual); }
public void TestIndexerNegative() { // Arrange. var jane = new Person { Name = "Jane" }; var john = new Person { Name = "John" }; var mary = new Person { Name = "Mary" }; var jack = new Person { Name = "Jack" }; var nameList1 = new List <Person>() { jane, jack, mary }; var nameList2 = new List <Person>() { jane, john, jack }; var class1 = new ListClass <Person>(nameList1); var class2 = new ListClass <Person>(nameList2); var compare = new CompareLogic(); // Act. ComparisonResult comparisonResult = compare.Compare(class1, class2); // Assert. Assert.IsFalse(comparisonResult.AreEqual); }
public void TestIndexerLengthNegative() { var jane = new Person { Name = "Jane" }; var john = new Person { Name = "John" }; var mary = new Person { Name = "Mary" }; var jack = new Person { Name = "Jack" }; var nameList1 = new List<Person>() { jane, john, jack, mary }; var nameList2 = new List<Person>() { jane, john, jack }; var class1 = new ListClass<Person>(nameList1); var class2 = new ListClass<Person>(nameList2); Assert.IsFalse(_compare.Compare(class1, class2)); }
public void StartList(ListClass listClass) { _xmlWriter.WriteStartElement("list", Namespaces.Maml); switch (listClass) { case ListClass.Bullet: _xmlWriter.WriteAttributeString("class", "bullet"); break; case ListClass.NoBullet: _xmlWriter.WriteAttributeString("class", "nobullet"); break; case ListClass.Ordered: _xmlWriter.WriteAttributeString("class", "ordered"); break; default: throw ExceptionBuilder.UnhandledCaseLabel(listClass); } }
public void CreateGeneralLedger() { string genName = txtNameGeneral.Text; string genDes = txtDescribeGeneral.Text; if (genName == string.Empty || genDes == string.Empty) { Message.ShowMessage("Check field"); } else if (genName.Length > 50 || genDes.Length > 75) { Message.ShowMessage("Unexpected Length!"); } else { int mainCode = Convert.ToInt32(cboMainHead1.SelectedValue); int maxGenCode; List <GeneralHeads> listGen = MainWindow.listGeneral.Where(x => x.MainCode == mainCode).ToList(); if (listGen.Count != 0) { List <GeneralHeads> lst = listGen.Where(x => x.GeneralName == genName && x.MainCode == mainCode).ToList(); if (lst.Count != 0) { Message.ShowMessage("It exists!"); return; } else { maxGenCode = listGen.Max(x => x.GeneralCode); if (maxGenCode == mainCode * 100 + 99) { Message.ShowMessage("99 General Ledgers are there!"); return; } else { maxGenCode++; } } } else { maxGenCode = mainCode * 100 + 1; } string Query = "INSERT INTO GHeads VALUES(@GCODE, @MCODE, @GHOA, @DESCRIPTION)"; SqlParameter[] para = { new SqlParameter("@GCODE", maxGenCode), new SqlParameter("@MCODE", mainCode), new SqlParameter("@GHOA", genName), new SqlParameter("@DESCRIPTION", genDes) }; try { ListClass lc = new ListClass(); MainWindow.listGeneral = SqlClass.ExecuteNonQuery(Query, MainWindow.listGeneral, lc.GeneralList, para); Message.ShowMessage("General ledger has been added to List"); int cbo1Index = cboMainHead1.SelectedIndex; PopulateComboBox(); cboMainHead1.SelectedIndex = cboMainHead2.SelectedIndex = cbo1Index; cbo1Index = cboGeneralHead.Items.Count - 1; cboGeneralHead.SelectedIndex = cbo1Index; txtNameGeneral.Text = txtDescribeGeneral.Text = string.Empty; } catch (Exception ex) { Message.ShowMessage(ex.ToString()); } } }
private void PopulateViewList() { string[] Machu = { "Machu Picchu" }; string[] Panama = { "Panama Canal" }; string[] Rio = { "Rio de Janeiro" }; string[] Quito = { "Quito" }; string[] Bogota = { "Bogotá" }; string[] Santiago = { "Santiago" }; double[] Machu_lat = { -13.163068 }; double[] Panama_lat = { 9.38743 }; double[] Rio_lat = { -22.970722 }; double[] Quito_lat = { -0.180653 }; double[] Bogota_lat = { 4.624335 }; double[] Santiago_lat = { -33.459229 }; double[] Machu_long = { -72.545128 }; double[] Panama_long = { -79.91863 }; double[] Rio_long = { -43.182365 }; double[] Quito_long = { -78.467834 }; double[] Bogota_long = { -74.063644 }; double[] Santiago_long = { -70.645348 }; var List = new ObservableCollection <ListClass>(); var item = new ListClass { IconSource = "Machu.png", websiteName = "1. Machu Picchu, Peru", websiteDescription = "As Peru’s most popular tourist attraction and one of the world’s most famous archaeological wonders, " + "Machu Picchu is located 7,000 feet (2,100 meters) above sea level in the Andes Mountains. " + "Although this magnificent Inca site provokes more mysteries than facts, " + "it is believed that Machu Picchu was first built around the middle of the 15th century as a military " + "fortress then later used as an estate for Inca royalty. Visitors can explore Machu Picchu " + "and see well-preserved buildings that include houses, temples, fountains and baths in addition to " + "agricultural terraces and evidence of an irrigation system.", latitude = Machu_lat, longitude = Machu_long, places = Machu, wetherkey = "&q=Machu Picchu" }; List.Add(item); MyList[0] = item; var item1 = new ListClass { IconSource = "Panama.png", websiteName = "2. Panama Canal, Panama", websiteDescription = "Stretching across the Panama Isthmus and regarded as one of the modern-day wonders of the world, " + "the Panama Canal is a vast and complex canal system built to allow ships passage between the Atlantic " + "and Pacific Oceans, making it an important channel for international maritime trade. " + "The Panama Canal is a key source of Panama’s thriving economy and has become a major tourist attraction.", latitude = Panama_lat, longitude = Panama_long, places = Panama, wetherkey = "&q=Panama" }; List.Add(item1); MyList[1] = item1; var item2 = new ListClass { IconSource = "Rio.png", websiteName = "3. Rio de Janeiro, Brazil", websiteDescription = "Located in southeastern Brazil, Rio de Janeiro is the most visited city of South America due to its famous mountains, " + "landmarks, beaches and Carnival festival. Rio de Janeiro is situated on one of the world’s largest " + "harbors surrounded by natural attractions that include the Sugarloaf and Corcovado mountains and " + "famous beaches like Copacabana and Ipanema. The city’s iconic landmark is the enormous Christ the Redeemer statue " + "sitting atop Corcovado mountain. Carnival celebrations here are among the largest in the world, " + "with vibrant parades, costumes, dancing, music, fireworks and street parties.", latitude = Rio_lat, longitude = Rio_long, places = Rio, wetherkey = "&q=Rio" }; List.Add(item2); MyList[2] = item2; var item3 = new ListClass { IconSource = "Quito.png", websiteName = "4. Quito, Ecuador", websiteDescription = "At 2,800 meters (9,350 feet) above sea level, the Ecuadoran capital of Quito is the highest capital " + "city in the world. This cosmopolitan city of 2.2 million people is located in an active volcano section " + "of the Andes. Quito has one of the largest and best preserved historic districts in South America. " + "Founded in 1534, it contains no fewer than 20 Catholic churches from the colonial era and despite intensive restoration, " + "the old town retains the vibrant working class and indigenous character that has always defined it. " + "Carondolet Palace, the seat of Ecuador’s government, is located in the historic area.", latitude = Quito_lat, longitude = Quito_long, places = Quito, wetherkey = "&q=Quito" }; List.Add(item3); MyList[3] = item3; var item4 = new ListClass { IconSource = "Bogota.png", websiteName = "5. Bogotá, Colombia", websiteDescription = "Bogotá is Colombia’s sprawling, high-altitude capital. La Candelaria, its cobblestoned center," + "features colonial-era landmarks like the neoclassical performance hall Teatro Colón and the 17th-century" + "Iglesia de San Francisco. It's also home to popular museums including the Museo Botero, showcasing Fernando Botero's art, and the Museo del Oro, displaying pre-Columbian gold pieces." + "The Zona Rosa neighborhood is known for upmarket shopping and trendy nightlife." + "The neighborhoods of Parque de la 93 and La Zona G are lined with more nightclubs," + "plus gourmet restaurants and high - end hotels.Other notable neighborhoods are La Macarena," + "with many art galleries, and Usaquén, featuring modern cafes and shops tucked inside colonial relics." + "One of many green spaces in Bogotá, Simón Bolívar Park offers lakes and walking paths.Reachable via a funicular, the roughly 3, 200m - high Cerro de Monserrate provides panoramic views.It's topped by Santuario de Monserrate, a church famed for its 17th-century shrine.", latitude = Bogota_lat, longitude = Bogota_long, places = Bogota, wetherkey = "&q=Bogotá" }; List.Add(item4); MyList[4] = item4; var item5 = new ListClass { IconSource = "Santiago.png", websiteName = "6. Santiago, Chile", websiteDescription = "The capital city is the political and cultural heart of Chile. " + "From the high mountain views of the Cerro San Cristobal Park to the " + "secluded history of poet Pablo Neruda’s writing retreat, there is much to see in Santiago. " + "Top picks include skiing Valle Nevado or Portillo, wine tasting at Vina Aquitania, " + "or visits to one of several top museums like Museo Chile de Arte Precolumbio or Museo de la Moda. " + "For those who don’t want to spend all of their time in the city, there are amazing hiking opportunities " + "like the steep slopes of Cajon de Maipo.", latitude = Santiago_lat, longitude = Santiago_long, places = Santiago, wetherkey = "&q=Santiago" }; List.Add(item5); MyList[5] = item5; SA.ItemsSource = List; }
public void CreateControlLedgers() { string controlName = MainWindow.listControl.Where(x => x.ControlName == txtNameMainCategory.Text).Select(x => x.ControlName).FirstOrDefault(); if (controlName != null) { Message.ShowMessage("It exists!"); } else { string mainCatName = txtNameMainCategory.Text; string mainCatDes = txtDescribeMainCategory.Text; if (mainCatName == string.Empty) { Message.ShowMessage("Check field"); } else if (mainCatName.Length > 50) { Message.ShowMessage("More than 50 Character is not supported"); } else if (mainCatDes.Length > 75) { Message.ShowMessage("More than 75 Character is not supported"); } else { int maxInvCode, maxSalesCode, maxSalesReturnCode, maxPurchaseReturnCode, maxCOGSCode, maxSalesReturnAdjCode, maxWeightLossCode, maxWeightGainCode; int InvCode, SalesCode, SalesReturnCode, PurchaseReturnCode, COGSCode, SalesReturnAdjCode, WeightLossCode, WeightGainCode; InvCode = SalesCode = SalesReturnCode = PurchaseReturnCode = COGSCode = SalesReturnAdjCode = WeightLossCode = WeightGainCode = 0; maxInvCode = MainWindow.listControl.Where(x => x.GeneralCode == 201).Select(x => x.ControlCode).LastOrDefault(); if (maxInvCode != 0) { if (maxInvCode != 20199) { maxInvCode = MainWindow.listControl.Where(x => x.GeneralCode == 201).Max(x => x.ControlCode); maxSalesCode = MainWindow.listControl.Where(x => x.GeneralCode == 601).Max(x => x.ControlCode); maxSalesReturnCode = MainWindow.listControl.Where(x => x.GeneralCode == 602).Max(x => x.ControlCode); maxPurchaseReturnCode = MainWindow.listControl.Where(x => x.GeneralCode == 707).Max(x => x.ControlCode); maxCOGSCode = MainWindow.listControl.Where(x => x.GeneralCode == 701).Max(x => x.ControlCode); maxSalesReturnAdjCode = MainWindow.listControl.Where(x => x.GeneralCode == 706).Max(x => x.ControlCode); maxWeightLossCode = MainWindow.listControl.Where(x => x.GeneralCode == 705).Max(x => x.ControlCode); maxWeightGainCode = MainWindow.listControl.Where(x => x.GeneralCode == 708).Max(x => x.ControlCode); InvCode = maxInvCode + 1; SalesCode = maxSalesCode + 1; SalesReturnCode = maxSalesReturnCode + 1; PurchaseReturnCode = maxPurchaseReturnCode + 1; COGSCode = maxCOGSCode + 1; SalesReturnAdjCode = maxSalesReturnAdjCode + 1; WeightLossCode = maxWeightLossCode + 1; WeightGainCode = maxWeightGainCode + 1; } else { Message.ShowMessage("99 Product Sector has alreadey been added!"); return; } } else { InvCode = 20101; SalesCode = 60101; SalesReturnCode = 60201; PurchaseReturnCode = 70701; COGSCode = 70101; SalesReturnAdjCode = 70601; WeightLossCode = 70501; WeightGainCode = 70801; } string Query = "INSERT INTO CHeads VALUES(@CCODE, @GCODE, @MCODE, @CHOA, @DESCRIPTION)"; string CS = ConfigurationManager.ConnectionStrings["TestDB"].ConnectionString; using (SqlConnection con = new SqlConnection(CS)) { con.Open(); SqlTransaction Trans = con.BeginTransaction(); try { SqlClass.ExecuteTransaction(Query, Param(InvCode, 201, 2, mainCatName, "Inventories"), con, Trans).ExecuteNonQuery(); SqlClass.ExecuteTransaction(Query, Param(SalesCode, 601, 6, mainCatName, "Sales"), con, Trans).ExecuteNonQuery(); SqlClass.ExecuteTransaction(Query, Param(SalesReturnCode, 602, 6, mainCatName, "Sales return"), con, Trans).ExecuteNonQuery(); SqlClass.ExecuteTransaction(Query, Param(PurchaseReturnCode, 707, 7, mainCatName, "Purchase return"), con, Trans).ExecuteNonQuery(); SqlClass.ExecuteTransaction(Query, Param(COGSCode, 701, 7, mainCatName, "Cost of Goods Sold"), con, Trans).ExecuteNonQuery(); SqlClass.ExecuteTransaction(Query, Param(SalesReturnAdjCode, 706, 7, mainCatName, "Sales return adjustment"), con, Trans).ExecuteNonQuery(); SqlClass.ExecuteTransaction(Query, Param(WeightLossCode, 705, 7, mainCatName, "Weight Loss"), con, Trans).ExecuteNonQuery(); SqlClass.ExecuteTransaction(Query, Param(WeightGainCode, 708, 7, mainCatName, "Weight Gain"), con, Trans).ExecuteNonQuery(); Trans.Commit(); ListClass lc = new ListClass(); MainWindow.listControl.Clear(); MainWindow.listControl = lc.ControlList(con); Message.ShowMessage("Necessary Ledgers have been created"); PopulateComboBox(); int cboIndex = cboMainCategory1.Items.Count - 1; cboMainCategory1.SelectedIndex = cboIndex; cboMainCategory2.SelectedIndex = cboIndex; txtNameMainCategory.Text = txtDescribeMainCategory.Text = string.Empty; } catch (Exception ex) { Trans.Rollback(); Message.ShowMessage(ex.ToString()); } } } } }
private static ListClass? GetListClass(Block block, ListClass? defaultClass = null) { switch (block.ListData.ListType) { case ListType.Bullet: if (block.ListData.BulletChar == '*') return ListClass.Bullet; return ListClass.NoBullet; case ListType.Ordered: return ListClass.Ordered; default: return defaultClass; } }
private async Task WriteListClassAsync(ListClass? listClass) { if (listClass != null) await WriteAttributeStringAsync("class", listClass.ToString().ToLowerInvariant()); }
internal async Task WriteListClassAsync(Block block, ListClass? defaultClass = null) { var listClass = GetListClass(block, defaultClass); await WriteListClassAsync(listClass); }
public void LibStatus(string updateFile) { /* *Purpose: updates database *Pre: needs to be called and a database to manage *Post: an updated database, along with lists of returned, loaned * nonChanged and overdue books */ // variables StreamReader sr; // reader StreamWriter sw; // writer string info, let, fName, lName; // string variables int spcLoc,changes=0, pos = 0; // int variables byte errorLine = 1, ODs = 0, numDays; // byte variables decimal price; // decimal variable bool PraiseBe = true; // bool variable ItemRec BookRec = new ItemRec(); // creates new record to store //intialize lists plus one parallel array ListClass returnList = new ListClass(), loanedList = new ListClass(), nonLRList = new ListClass(), ODBook = new ListClass(); decimal[] ODPrice = new decimal[numBooks]; sr = new StreamReader(updateFile); // opens file info = sr.ReadLine(); // read next line of file // while not end of file and no errors while (info != EOF && PraiseBe == true) { if (ErrorChecker(info, errorLine) == !PraiseBe) // if not errors { spcLoc = info.IndexOf(SPACE); // finds space location BookRec.ISBN = info.Substring(pos, spcLoc); // sets ID this.Find(BookRec.ISBN); // gets record and sets currPos info = info.Remove(pos, spcLoc + ONE); // wittleing info spcLoc = info.IndexOf(SPACE); // finds space location if (spcLoc == -1) // if no more data let = info; // set whats left else let = info.Substring(ZERO, ONE); // grab needed let changes++; if (let == "L" || let == "l") // if loaned {// adds one to loaned if loaned out this.listArr[currPos].numOnLoan = (byte)(this.listArr[currPos].numOnLoan + OREO); // this.Insert(BookRec); // adds it back to main list // if not in list already add it if (loanedList.Find(this.listArr[currPos].ISBN)==false) loanedList.Insert(this.listArr[currPos]); } // end if else if (let == "R" || let == "r") // if returned {// subtracts one from loaned if returned this.listArr[currPos].numOnLoan = (byte)(this.listArr[currPos].numOnLoan - OREO); // this.Insert(BookRec); // adds it back to main list // if not in list already add it if (returnList.Find(this.listArr[currPos].ISBN)==false) returnList.Insert(this.listArr[currPos]); } // end else if spcLoc = info.IndexOf(SPACE);// finds space location if (spcLoc == -1) // if end numDays = ZERO; // add whats left else { // whittle info and grab days its been loaned info = info.Remove(pos, spcLoc + ONE); numDays = Convert.ToByte(info.Substring(pos)); if (numDays > WEEK) // if numdays is overdue { price = numDays * OD; // multiply price by days // if not on list already add it if (ODBook.Find(this.listArr[currPos].ISBN)==false) { ODBook.Insert(this.listArr[currPos]); ODPrice[ODs] = price; // adds price ODs++; // price postion to keep parallel } } // end } // end else } // end checker errorLine++; // count line info = sr.ReadLine(); // read next line of file } // end while sr.Close(); // closes reader sw = new StreamWriter(REPORTS); // open output file //~~~~~~~~~~~~~~~~~ // 1st report runs through returned list and prints each sw.WriteLine("1st Report: Returned"); sw.WriteLine(" ISBN: " + String.Format(" {0,-20}", "Lastname, Firstname") + SPACE + "# in Library"); returnList.FirstPos(); // sets first position for (int book = 0; book < returnList.GetLength(); book++) { BookRec = returnList.Retrieve(); // gets record spcLoc = BookRec.authorName.IndexOf(SPACE);// gets space loc // gets first name then last name and prints need information fName = BookRec.authorName.Substring(pos, spcLoc); lName = BookRec.authorName.Substring(spcLoc + ONE) + COMMA; sw.WriteLine(BookRec.ISBN + String.Format(" {0,-20}", (lName + SPACE + fName)) + SPACE + (BookRec.numOwned - BookRec.numOnLoan).ToString()); returnList.NextPos(); // next position } // end returned list sw.WriteLine(); // space //~~~~~~~~~~~~~~~~~ // 2nd report runs through loaned list and prints each sw.WriteLine("2nd Report: Loaned"); sw.WriteLine(" ISBN: " + String.Format(" {0,-20}", "Lastname, Firstname") + SPACE + "# in Library"); loanedList.FirstPos(); // sets first position for (int book = 0; book < loanedList.GetLength(); book++) { BookRec = loanedList.Retrieve();// gets record spcLoc = BookRec.authorName.IndexOf(SPACE);// gets space loc // gets first name then last name and prints need information fName = BookRec.authorName.Substring(pos, spcLoc); lName = BookRec.authorName.Substring(spcLoc + ONE) + COMMA; sw.WriteLine(BookRec.ISBN + String.Format(" {0,-20}", (lName + SPACE + fName)) + SPACE + (BookRec.numOwned - BookRec.numOnLoan).ToString()); loanedList.NextPos(); // goes to next position } // end loaned list sw.WriteLine(); // space //~~~~~~~~~~~~~~~~~ // 3rd report runs through unchanged list and prints each sw.WriteLine("3rd Report: Unchanged"); nonLRList = this - loanedList; // subtracts l list elements nonLRList = nonLRList - returnList; // subtracts r list elements sw.WriteLine(" ISBN: " + String.Format(" {0,-20}", "Lastname, Firstname") + SPACE + "# in Library"); nonLRList.FirstPos(); // sets first position for (int book = 0; book < nonLRList.GetLength(); book++) { BookRec = nonLRList.Retrieve();// gets record spcLoc = BookRec.authorName.IndexOf(SPACE);// gets space loc // gets first name then last name and prints need information fName = BookRec.authorName.Substring(pos, spcLoc); lName = BookRec.authorName.Substring(spcLoc + ONE) + COMMA; sw.WriteLine(BookRec.ISBN + String.Format(" {0,-20}", (lName + SPACE + fName)) + SPACE + (BookRec.numOwned - BookRec.numOnLoan).ToString()); nonLRList.NextPos(); // goes to next position } // ends unchanged list sw.WriteLine(); // space //~~~~~~~~~~~~~~~~~ // 4th report runs through OD list and array and prints each sw.WriteLine("4th Report: Overdue"); sw.WriteLine(" ISBN: " + String.Format(" {0,-20}", "Lastname, Firstname") + SPACE + "# in Library" + " Money Owed:"); ODBook.FirstPos(); // sets first position for (int book = 0; book < ODBook.GetLength(); book++) { BookRec = ODBook.Retrieve();// gets record spcLoc = BookRec.authorName.IndexOf(SPACE);// gets space loc // gets first name then last name and prints need information fName = BookRec.authorName.Substring(pos, spcLoc); lName = BookRec.authorName.Substring(spcLoc + ONE) + COMMA; sw.WriteLine(BookRec.ISBN + String.Format(" {0,-20}", (lName + SPACE + fName)) + SPACE + (BookRec.numOwned - BookRec.numOnLoan).ToString() + String.Format("{0,17}", (ODPrice[book].ToString("c")))); ODBook.NextPos(); // goes to next position } // end overdue list report sw.Close(); // close file writer PrintCurrentData(changes); // prints updated database } // end lib status
private void btnAddList_Click(object sender, EventArgs e) { CB_class book = cmbOrderBookName.SelectedItem as CB_class; string txtSurname = txtOrderCustomerSurname.Text.Trim(); string txtName = txtOrderCustomerName.Text.Trim(); string txtBookCount = txtOrderBookCount.Text.Trim(); string cmbBook = cmbOrderBookName.Text.Trim(); if (!this.CheckInput()) { MessageBox.Show("Fill all input", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!txtOrderBookCount.Text.IsNumber()) { MessageBox.Show("Please enter the number", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (int.Parse(txtOrderBookCount.Text) > 1) { MessageBox.Show("This is not correct", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (int.Parse(txtOrderBookBalances.Text) <= 0) { MessageBox.Show("This book not enough", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } foreach (ListClass item in listGiveBook.Items) { if (book.Id == item.Id) { MessageBox.Show("Dont allow", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } CB_class selectGenre = (cmbOrderBookGenres.SelectedItem as CB_class); CB_class selectBook = (cmbOrderBookName.SelectedItem as CB_class); ListClass list = new ListClass() { Id = selectBook.Id, Name = selectBook.Name, Price = selectBook.Price, Count = selectBook.Count }; listGiveBook.Items.Add(list); int total = int.Parse(lblBookCount.Text.Trim()); lblBookCount.Text = (total + 1).ToString(); selectBook.Count -= int.Parse(txtOrderBookCount.Text); txtOrderBookBalances.Text = selectBook.Count.ToString(); //txtOrderCustomerName.Text = ""; //txtOrderCustomerSurname.Text = ""; //txtOrderBookCount.Text = ""; //txtOrderBookBalances.Text = ""; }
private void PopulateViewList() { string[] Delhi_places = { "Taj Mahal", "Agra Fort", "India Gate", "Red Fort", "Lotus Temple" }; string[] Male_places = { "Male", "Baa Atoll", "Meeru Island" }; string[] Dubai_places = { "Dubai", "Atlantis Hotel", "Aquaventure WaterPark", "Dubai Underwater Aquarium", "Lost Chambers Aquarium" }; string[] Kuala_Lumpur_places = { "Batu Caves", "Petronas Tower", "Genting Highlands" }; string[] Singapore_places = { "Sentosa, Merlion", "Singapore Flyer", "Garden by the Bay", "Singapore Botanic Garden" }; string[] Tokyo_places = { "Skytree", "Tokyo Tower", "Mt Fuji", "Shinjuku Gyo - en" }; string[] Moscow_places = { "Lenin Mausoleum", "Red Square", "Alexander Garden" }; double[] Delhi_lat = { 27.1750, 27.1795, 28.6125, 28.6562, 28.5535 }; double[] Male_lat = { 4.1755, 5.2396, 4.4533 }; double[] Dubai_lat = { 25.1750, 25.1304, 25.1336, 25.1974, 25.1319 }; double[] Kuala_Lumpur_lat = { 3.2379, 3.1578, 3.4237 }; double[] Singapore_lat = { 1.2494, 1.2868, 1.2893, 1.2816, 1.3138 }; double[] Tokyo_lat = { 35.7101, 35.6586, 35.3606, 35.6852 }; double[] Moscow_lat = { 55.7537, 55.7539, 55.7521 }; double[] Delhi_long = { 78.0422, 78.0211, 77.2295, 77.2410, 78.2588 }; double[] Male_long = { 73.5093, 72.9933, 73.7169 }; double[] Dubai_long = { 55.2708, 55.1171, 55.1204, 55.2791, 55.1184 }; double[] Kuala_Lumpur_long = { 101.6840, 101.745, 101.7938 }; double[] Singapore_long = { 103.8303, 103.8545, 103.8631, 103.8636, 103.8159 }; double[] Tokyo_long = { 139.8107, 139.7454, 138.7278, 139.7101 }; double[] Moscow_long = { 37.6199, 37.6208, 37.6137 }; var List = new ObservableCollection <ListClass>(); var item1 = new ListClass { IconSource = "Taj_Mahal.png", websiteName = "1. Delhi/Agra, India", websiteDescription = "India's capital and major gateway of the country, " + "contemporary Delhi is bustling metropolis, which successfully " + "combines in its fold the ancient and the modern. Its strategic " + "location was one of the prime reasons why successive dynasties " + "chose it as their seat of power. It is one of the most populates" + "city in the world and also in India. There are some wonderful tourist attractions" + "such as Taj Mahal. ", latitude = Delhi_lat, longitude = Delhi_long, places = Delhi_places, wetherkey = "&q=Delhi" }; List.Add(item1); MyList[0] = item1; var item2 = new ListClass { IconSource = "Maldives.png", websiteName = "2. Male, Maldives", websiteDescription = "The isolated city in the island of Maldives, off coast of the Indian" + "Ocean where there is enjoyable time in doin watersports activities.", latitude = Male_lat, longitude = Male_long, places = Male_places, wetherkey = "&q=Maldives" }; List.Add(item2); MyList[1] = item2; var item3 = new ListClass { IconSource = "Dubai.png", websiteName = "3. Dubai, UAE", websiteDescription = "One of the most luxurious cities in the Arabian Peninsula." + "Most of the tourist from all over the world come to this city to visit this artificial" + "futuristic city.", latitude = Dubai_lat, longitude = Dubai_long, places = Dubai_places, wetherkey = "&q=Dubai" }; List.Add(item3); MyList[2] = item3; var item4 = new ListClass { IconSource = "Singapore.png", websiteName = "4. Singapore, Singapore", websiteDescription = "One of the luxurious cities in South East Asia. Tourist come here to" + "visit the merilion, and the sentosa islands. ", latitude = Singapore_lat, longitude = Singapore_long, places = Singapore_places, wetherkey = "&q=Singapore" }; List.Add(item4); MyList[3] = item4; var item5 = new ListClass { IconSource = "Kuala_Lumpur.png", websiteName = "5. Kuala Lumpur, Malaysia", websiteDescription = "Another city in south east asia. ", latitude = Kuala_Lumpur_lat, longitude = Kuala_Lumpur_long, places = Kuala_Lumpur_places, wetherkey = "&q=Kuala Lumpur" }; List.Add(item5); MyList[4] = item5; var item6 = new ListClass { IconSource = "Tokyo.png", websiteName = "6. Tokyo, Japan", websiteDescription = "The most well known city in Japan and also the capital city.", latitude = Tokyo_lat, longitude = Tokyo_long, places = Tokyo_places, wetherkey = "&q=Tokyo" }; List.Add(item6); MyList[5] = item6; var item = new ListClass { IconSource = "Moscow.png", websiteName = "7. Moscow, Russia", websiteDescription = "The most well known city in Russia and also the capital city.", latitude = Moscow_lat, longitude = Moscow_long, places = Moscow_places, wetherkey = "&q=Moscow" }; List.Add(item); MyList[6] = item; AS.ItemsSource = List; }
ListClass(int hd, ListClass tl) { head = hd; tail = tl; }
public void Setup() { _list = new ListClass(); }
public void TestIndexerLengthNegative() { var jane = new Person { Name = "Jane" }; var john = new Person { Name = "John" }; var mary = new Person { Name = "Mary" }; var jack = new Person { Name = "Jack" }; var nameList1 = new List<Person>() { jane, john, jack, mary }; var nameList2 = new List<Person>() { jane, john, jack }; var class1 = new ListClass<Person>(nameList1); var class2 = new ListClass<Person>(nameList2); var prior = _compare.Config.MaxDifferences; _compare.Config.MaxDifferences = int.MaxValue; ComparisonResult result = _compare.Compare(class1, class2); Assert.AreEqual(result.Differences.Count, 3); result = _compare.Compare(class2, class1); Assert.AreEqual(result.Differences.Count, 3); _compare.Config.MaxDifferences = prior; }
public void CreateMainProduct() { string mainProName = txtNameSubCategory.Text; string manProDes = txtDescribeSubCategory.Text; var selectedItem = cboMainCategory1.SelectedValue; if (selectedItem == null) { Message.ShowMessage("Create Main Sector First!"); } else if (mainProName == string.Empty) { Message.ShowMessage("Check field!"); } else if (mainProName.Length > 25) { Message.ShowMessage("More than 25 Character is not supported"); } else if (manProDes.Length > 50) { Message.ShowMessage("More than 50 Character is not supported"); } else { int invCode = Convert.ToInt32(selectedItem); List <MainProduct> productName = MainWindow.mainProducts.Where(x => x.MainName == txtNameSubCategory.Text && x.InventoryCode == invCode).ToList(); if (productName.Count != 0) { Message.ShowMessage("It exists!"); } else { int mainProductCode, maxProductCode; mainProductCode = maxProductCode = 0; List <MainProduct> prod = MainWindow.mainProducts.Where(x => x.InventoryCode == invCode).ToList(); if (prod.Count != 0) { maxProductCode = prod.Max(x => x.MainId); if (maxProductCode != invCode * 100 + 99) { mainProductCode = maxProductCode + 1; } else { Message.ShowMessage("99 Products have alreadey been added!"); return; } } else { mainProductCode = invCode * 100 + 1; } string Query = "INSERT INTO MProducts VALUES(@MId, @InvCCode, @MName, @Description)"; SqlParameter[] para = { new SqlParameter("@MId", mainProductCode), new SqlParameter("@InvCCode", invCode), new SqlParameter("@MName", mainProName), new SqlParameter("@Description", manProDes) }; try { ListClass lc = new ListClass(); MainWindow.mainProducts = SqlClass.ExecuteNonQuery(Query, MainWindow.mainProducts, lc.MainProductList, para); Message.ShowMessage("Product has been added to List"); int cbo1Index = cboMainCategory1.SelectedIndex; PopulateComboBox(); cboMainCategory1.SelectedIndex = cboMainCategory2.SelectedIndex = cbo1Index; int cbo2Index = cboSubCategory.Items.Count - 1; cboSubCategory.SelectedIndex = cbo2Index; txtNameSubCategory.Text = txtDescribeSubCategory.Text = string.Empty; } catch (Exception ex) { Message.ShowMessage(ex.ToString()); } } } }
private void PopulateViewList() { string[] LA_places = { "Universal Studios Hollywood", "Griffith Park and Griffith Observatory", "Disneyland Resort" }; string[] NY_places = { "Statue of Liberty", "Central Park", "Rockefeller Center and Top of the Rock Observation Deck" }; string[] HO_places = { "Makani Catamaran Sail", "Honolulu Museum of Art", "Waikiki Beach" }; string[] CA_places = { "Chichen Itza", "Isla Mujeres", "El Rey Ruins" }; string[] AC_places = { "Playa Condesa", "Paititi del Mar", "San Diego Fort" }; string[] MC_places = { "Zócalo: The Birthplace of the Constitution", "The National Museum of Anthropology", "Templo Mayor and the Great Pyramid of Tenochtitlán" }; string[] ON_places = { "Niagara Falls", "Toronto's CN Tower", "Royal Ontario Museum" }; double[] LA_lat = { 34.138117, 34.118434, 33.810485 }; double[] NY_lat = { 40.689249, 40.782865, 40.759243 }; double[] HO_lat = { 21.294374, 21.303898, 21.276218 }; double[] CA_lat = { 20.684285, 21.232180, 21.061141 }; double[] AC_lat = { 16.855025, 16.787317, 16.849939 }; double[] MC_lat = { 19.432602, 19.426003, 19.434604 }; double[] ON_lat = { 43.082816, 43.642566, 43.667710 }; double[] LA_long = { -118.353378, -118.300393, -117.918989 }; double[] NY_long = { -74.044500, -73.965355, -73.979294 }; double[] HO_long = { -157.857259, -157.848708, -157.827091 }; double[] CA_long = { -88.567783, -86.734093, -86.781224 }; double[] AC_long = { -99.873986, -99.793213, -99.902372 }; double[] MC_long = { -99.133205, -99.186279, -99.131881 }; double[] ON_long = { -79.074163, -79.387057, -79.394777 }; var List = new ObservableCollection <ListClass>(); var item = new ListClass { IconSource = "LA.png", websiteName = "1. Los Angeles, CA USA", websiteDescription = "Los Angeles is the second largest city in the United States in terms of population and " + "one of the largest in terms of area. It is the center of a five-county metropolitan area and is considered " + "the prototype of the future metropolis—a city on the cutting edge of all of the advantages and the problems " + "of large urban areas.", latitude = LA_lat, longitude = LA_long, places = LA_places, wetherkey = "&q=LA" }; List.Add(item); MyList[0] = item; var item1 = new ListClass { IconSource = "NewYorkCities.png", websiteName = "2. New York City, Ny USA", websiteDescription = "Welcome to New York. This is the most populated city in the United States. " + "Really a great tourist spot. Super Great City with Statues Of Liberty", latitude = NY_lat, longitude = NY_long, places = NY_places, wetherkey = "&q=NY" }; List.Add(item1); MyList[1] = item1; var item2 = new ListClass { IconSource = "Honolulu.png", websiteName = "3. Honolulu, Hawaii USA", websiteDescription = "Ohau Blends the cosmopolitan luxury and breathtaking scenery" + "more than any othe Hawaiian Islands. The state capital Honolulu showcases the " + "Urban appeal. Nearby You", latitude = HO_lat, longitude = HO_long, places = HO_places, wetherkey = "&q=Honolulu" }; List.Add(item2); MyList[2] = item2; var item3 = new ListClass { IconSource = "Cancun.png", websiteName = "4. Cancun, Mexico", websiteDescription = " It is a valuable tourist destination in Mexico. One of the" + "most well known cities in Mexico. It has a tropical climate.", latitude = CA_lat, longitude = CA_long, places = CA_places, wetherkey = "&q=Cancun" }; List.Add(item3); MyList[3] = item3; var item4 = new ListClass { IconSource = "acapulco-beach.png", websiteName = "5. Acapulco, Mexico", websiteDescription = "It is another well known city in Mexico. It has a tropical wet and " + "dry climate. It's the largest city in Mexico by far.", latitude = AC_lat, longitude = AC_long, places = AC_places, wetherkey = "&q=Acapulco" }; List.Add(item4); MyList[4] = item4; var item5 = new ListClass { IconSource = "MC.png", websiteName = "6. Mexico City, Mexico", websiteDescription = "It's the capital of Mexico. Ther city itself is pretty old. " + "In the early days, the Aztec Indians settled on the lake. They built a city called Tenochtitlán.", latitude = MC_lat, longitude = MC_long, places = MC_places, wetherkey = "&q=Mexico City" }; List.Add(item5); MyList[5] = item5; var item6 = new ListClass { IconSource = "Ontario.png", websiteName = "7. Ontario, Canada", websiteDescription = "One of the most well known cities in Canada. They speak French in Canada, as" + "well as English.", latitude = ON_lat, longitude = ON_long, places = ON_places, wetherkey = "&q=Ontario Canada" }; List.Add(item6); MyList[6] = item6; NA.ItemsSource = List; }
public void CreateGeneralProduct() { string genProdName = txtNameItem.Text; string genProdDes = txtDescribeItem.Text; var Code = cboMainCategory2.SelectedValue; if (Code == null) { Message.ShowMessage("Create Main Sector First!"); } else if (cboSubCategory.SelectedValue == null) { Message.ShowMessage("Create a Category First!"); } else if (genProdName == string.Empty) { Message.ShowMessage("Check field!"); } else if (genProdName.Length > 25) { Message.ShowMessage("More than 25 Ccharacter is not supported!"); } else if (genProdDes.Length > 50) { Message.ShowMessage("More than 50 Ccharacter is not supported!"); } else { List <GeneralProduct> genList = MainWindow.generalProducts.Where(x => x.GeneralName == genProdName && x.MainId == Convert.ToInt32(cboSubCategory.SelectedValue)).ToList(); if (genList.Count != 0) { Message.ShowMessage("Item exists!"); return; } else { int invCode, mainCode, generalCode, maxGeneralCode; generalCode = maxGeneralCode = 0; invCode = Convert.ToInt32(Code); mainCode = Convert.ToInt32(cboSubCategory.SelectedValue); List <GeneralProduct> geneList = MainWindow.generalProducts.Where(x => x.MainId == mainCode).ToList(); if (geneList.Count != 0) { maxGeneralCode = geneList.Max(x => x.GeneralId); if (maxGeneralCode == mainCode * 100 + 99) { Message.ShowMessage("99 Products have alreadey been added!"); return; } else { generalCode = maxGeneralCode + 1; } } else { generalCode = mainCode * 100 + 1; } double conversionFact; SqlParameter conFact; if (txtConvertItem.Text != string.Empty) { double.TryParse(txtConvertItem.Text, out conversionFact); if (conversionFact == 0) { Message.ShowMessage("Unexpected Factor!"); return; } else if (conversionFact < 0) { Message.ShowMessage("Negative Factor!"); return; } else { conFact = new SqlParameter("@ConToLoose", conversionFact); } } else { conFact = new SqlParameter("@ConToLoose", DBNull.Value); } string Query = "INSERT INTO GProducts VALUES(@GId, @MId, @InvCCode, @GName, @ConToLoose, @Description)"; SqlParameter[] para = { new SqlParameter("@GId", generalCode), new SqlParameter("@MId", mainCode), new SqlParameter("@InvCCode", invCode), new SqlParameter("@GName", txtNameItem.Text), conFact, new SqlParameter("@Description", txtDescribeItem.Text) }; try { ListClass lc = new ListClass(); MainWindow.generalProducts = SqlClass.ExecuteNonQuery(Query, MainWindow.generalProducts, lc.GeneralProductList, para); Message.ShowMessage("Item has been added to List"); txtNameItem.Text = txtDescribeItem.Text = txtConvertItem.Text = string.Empty; } catch (Exception ex) { Message.ShowMessage(ex.ToString()); } } } }
private void PopulateViewList() { string[] LO_places = { "Big Ben", "South Bank", "London Transport Museum", "Imperial War Museum", "London Square" }; string[] PA_places = { "St. Vincient de Paul", "75 St. Rue, Bob's Hotel", "Effel Tower", "Saint-Germain-des-Prés Abbey", "Mona Lisa Muesuem" }; string[] RE_places = { "Tommi's Burger Joint", "GeoIceLand Tours", "Golden Circle" }; string[] RO_places = { "Vatican Museum", "Colosseum", "Palatine Hill", "Sistine Chapel", "Leaning Tower of Piza" }; string[] MA_places = { "Madrid Marriott Museum", "Prado National Museum", "Mercado San Miguel", "Calle Avila", "Royal Palace of Madrid" }; string[] BE_places = { "Berlin Wall", "Reichstag Building", "Pergamon Museum", "East Side Gallery", "Brandenburg Gate" }; double[] LO_lat = { 51.5037, 51.4991, 51.5146, 51.4994, 51.5143 }; double[] PA_lat = { 48.8790, 48.8335, 48.8584, 48.853867, 48.860294 }; double[] RE_lat = { 64.1260, 64.1360, 64.1360 }; double[] RO_lat = { 41.9067, 41.8904, 41.8905, 41.9032, 43.7232 }; double[] MA_lat = { 40.4577, 40.4140, 40.4157, 40.6601, 40.4182 }; double[] BE_lat = { 52.5504, 52.5188, 52.5213, 52.5054, 52.5165 }; double[] LO_long = { -0.1246, -0.1079, -0.1172, -0.0999, -0.1303 }; double[] PA_long = { 2.3519, 2.3191, 2.2945, 2.334723, 2.338629 }; double[] RE_long = { -21.8162, -21.8236, -21.8236 }; double[] RO_long = { 12.4536, 12.4922, 12.4874, 12.4544, 10.3966 }; double[] MA_long = { -3.5432, -3.6917, -3.7085, -4.6886, -3.7142 }; double[] BE_long = { 13.3931, 13.3763, 13.3969, 13.4396, 13.3779 }; var List = new ObservableCollection <ListClass>(); var item = new ListClass { IconSource = "London.png", websiteName = "1. London, UK", websiteDescription = "Known for Big Ben, London Bridge and the South Bank.", latitude = LO_lat, longitude = LO_long, places = LO_places, wetherkey = "&q=London" }; List.Add(item); MyList[0] = item; var item1 = new ListClass { IconSource = "paris.png", websiteName = "2. Paris, France", websiteDescription = "Known for the Effel Tower. The best place of romance and french fries.", latitude = PA_lat, longitude = PA_long, places = PA_places, wetherkey = "&q=Paris" }; List.Add(item1); MyList[1] = item1; var item2 = new ListClass { IconSource = "reykjavik.png", websiteName = "3. Iceland", websiteDescription = "Not very well known, but it does have gorgeous scenery. A best place to get fish salmon. " + "They call it Iceland, but there are no ice. It is green", latitude = RE_lat, longitude = RE_long, places = RE_places, wetherkey = "&q=Reykjavik" }; List.Add(item2); MyList[2] = item2; var item3 = new ListClass { IconSource = "Rome.png", websiteName = "4. Rome, Italy", websiteDescription = "Known for the Leaning Tower of Pisa. It has been leaning like always. " + "It has been leaning since Iccas Newton and Gallieo proved the theorm of Gravity.", latitude = RO_lat, longitude = RO_long, places = RO_places, wetherkey = "&q=Rome" }; List.Add(item3); MyList[3] = item3; var item4 = new ListClass { IconSource = "madrid.png", websiteName = "5. Madrid, Spain", websiteDescription = "Known for the Royal Palace of Madrid. It is also well known for " + "bullfighting. ", latitude = MA_lat, longitude = MA_long, places = MA_places, wetherkey = "&q=Madrid" }; List.Add(item4); MyList[4] = item4; var item5 = new ListClass { IconSource = "berlin.png", websiteName = "6. Berlin, Germany", websiteDescription = "Known for the Berlin Wall. A nice historical site. " + "This city was divided since the end of World War 2 till 1989. ", latitude = BE_lat, longitude = BE_long, places = BE_places, wetherkey = "&q=Berlin" }; List.Add(item5); MyList[5] = item5; EUR.ItemsSource = List; }
public void CreateControlLedger() { var a = cboGeneralHead.SelectedItem; string controlName = txtNameControl.Text; string controlDes = txtDescribeControl.Text; if (a == null) { Message.ShowMessage("Create General Ledger"); } else if (controlName == string.Empty || controlDes == string.Empty) { Message.ShowMessage("Check field"); } else if (controlName.Length > 50 || controlDes.Length > 75) { Message.ShowMessage("Length of text is not supported"); } else { int generalCode = Convert.ToInt32(cboGeneralHead.SelectedValue); int mainCode, maxControlCode; mainCode = maxControlCode = 0; List <ControlHeads> lst = MainWindow.listControl.Where(x => x.ControlName == controlName && x.GeneralCode == generalCode).ToList(); if (lst.Count != 0) { Message.ShowMessage("It exists"); return; } else { List <ControlHeads> listControlheads = MainWindow.listControl.Where(x => x.GeneralCode == generalCode).ToList(); mainCode = Convert.ToInt32(cboMainHead2.SelectedValue); if (listControlheads.Count == 0) { maxControlCode = generalCode * 100 + 1; } else { maxControlCode = listControlheads.Max(x => x.ControlCode); if (maxControlCode == generalCode * 100 + 99) { Message.ShowMessage("99 Ledgers already added"); return; } else { maxControlCode++; } } } string Query = "INSERT INTO CHeads VALUES(@CCODE, @GCODE, @MCODE, @CHOA, @DESCRIPTION)"; SqlParameter[] para = { new SqlParameter("@CCODE", maxControlCode), new SqlParameter("@GCODE", generalCode), new SqlParameter("@MCODE", mainCode), new SqlParameter("@CHOA", controlName), new SqlParameter("@DESCRIPTION", controlDes) }; try { ListClass lc = new ListClass(); MainWindow.listControl = SqlClass.ExecuteNonQuery(Query, MainWindow.listControl, lc.ControlList, para); Message.ShowMessage("Control ledger has been added to List"); txtNameControl.Text = txtDescribeControl.Text = string.Empty; } catch (Exception ex) { Message.ShowMessage(ex.ToString()); } } }
private void CreateFAControlAccount() { string controlName, controlDescription; controlName = txtNameControl.Text; controlDescription = txtDescribeControl.Text; if (controlName == string.Empty || controlDescription == string.Empty) { Message.ShowMessage("Fill in the Text Boxes"); return; } if (controlName.Length > 100 || controlDescription.Length > 150) { Message.ShowMessage("Unexpected Length"); return; } List <GeneralHeads> FAGen = MainWindow.listGeneral.Where(x => x.GeneralName == "Fixed Assets").ToList(); int FAGenCode = FAGen.Select(x => x.GeneralCode).FirstOrDefault(); List <ControlHeads> FAControl = MainWindow.listControl.Where(x => x.GeneralCode == FAGenCode).ToList(); List <ControlHeads> names = FAControl.Where(x => x.ControlName == controlName).ToList(); if (names.Count != 0) { Message.ShowMessage("Head Exists"); return; } int controlCode = 0; int maxControlCode = FAControl.Select(x => x.ControlCode).LastOrDefault(); int upperLimit = FAGenCode * 100 + 99; if (maxControlCode != upperLimit) { controlCode = maxControlCode == 0 ? FAGenCode * 100 + 1 : maxControlCode + 1; } else { Message.ShowMessage("99 Items added"); return; } int FAMainCode = FAGen.Select(x => x.MainCode).FirstOrDefault(); string Query = "INSERT INTO CHeads VALUES(@CCODE, @GCODE, @MCODE, @CHOA, @DESCRIPTION)"; string CS = ConfigurationManager.ConnectionStrings["TestDB"].ConnectionString; using (SqlConnection con = new SqlConnection(CS)) { SqlParameter[] para = { new SqlParameter("@CCODE", controlCode), new SqlParameter("@GCODE", FAGenCode), new SqlParameter("@MCODE", FAMainCode), new SqlParameter("@CHOA", controlName), new SqlParameter("@DESCRIPTION", controlDescription) }; ListClass lc = new ListClass(); try { con.Open(); MainWindow.listControl = SqlClass.ExecuteNonQuery(Query, MainWindow.listControl, lc.ControlList, para); Message.ShowMessage("Ledger Created"); PopulateComboBox(); cboControl1.SelectedIndex = MainWindow.listControl.FindIndex(x => x.ControlCode == controlCode); } catch (Exception ex) { Message.ShowMessage(ex.ToString()); } } }
public void Initialise() { Simulations basicFile = Utilities.GetRunnableSim(); IModel simulation = basicFile.FindInScope <Simulation>(); IModel paddock = basicFile.FindInScope <Zone>(); // Add a weather component. Models.Climate.Weather weather = new Models.Climate.Weather(); weather.Name = "Weather"; weather.FileName = "asdf.met"; Structure.Add(weather, simulation); // Add a second weather component. Models.Climate.Weather weather2 = new Models.Climate.Weather(); weather2.FileName = "asdf.met"; weather2.Name = "Weather2"; Structure.Add(weather2, simulation); // Add a third weather component. Models.Climate.Weather weather3 = new Models.Climate.Weather(); weather3.FileName = "asdf.met"; weather3.Name = "Weather3"; Structure.Add(weather3, simulation); // Add a third weather component. Models.Climate.Weather weather4 = new Models.Climate.Weather(); weather4.FileName = "asdf.met"; weather4.Name = "Weather4"; Structure.Add(weather4, simulation); // Add a report. Models.Report report = new Models.Report(); report.Name = "Report"; Structure.Add(report, paddock); // Add the wheat model. string json = ReflectionUtilities.GetResourceAsString(typeof(IModel).Assembly, "Models.Resources.Wheat.json"); Plant wheat = FileFormat.ReadFromString <IModel>(json, e => throw e, false).Children[0] as Plant; wheat.ResourceName = "Wheat"; Structure.Add(wheat, paddock); Manager manager = new Manager(); manager.Code = @"using Models.PMF; using Models.Core; using System; namespace Models { [Serializable] public class Script : Model { [Description(""an amount"")] public double Amount { get; set; } } }"; Structure.Add(manager, paddock); Physical physical = new Physical(); physical.BD = new double[5]; physical.AirDry = new double[5]; physical.LL15 = new double[5]; Structure.Add(physical, paddock); Structure.Add(new WaterBalance(), paddock); Structure.Add(new SurfaceOrganicMatter(), paddock); ListClass <string> stringList = new ListClass <string>("StringList", 5); Structure.Add(stringList, simulation); ListClass <double> doubleList = new ListClass <double>("DoubleList", 5); Structure.Add(doubleList, simulation); basicFile.Write(basicFile.FileName); fileName = basicFile.FileName; // Create a new .apsimx file containing two weather nodes. Simulations test = Utilities.GetRunnableSim(); IModel sim = test.FindInScope <Simulation>(); Models.Climate.Weather w1 = new Models.Climate.Weather(); w1.FileName = "w1.met"; w1.Name = "w1"; Structure.Add(w1, sim); Models.Climate.Weather w2 = new Models.Climate.Weather(); w2.Name = "w2"; w2.FileName = "w2.met"; Structure.Add(w2, sim); extFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".apsimx"); test.Write(extFile); }
private void CreateCategory() { if (cboControl1.SelectedItem == null) { Message.ShowMessage("Create Control Ledger"); return; } bool notDepreciable = (bool)chkDepreciation.IsChecked; double depreciationRate = 0; string depreciation, categoryName, categoryDescription; categoryName = txtNameCategory.Text; categoryDescription = txtDescribeCategory.Text; depreciation = txtDepreciation.Text; if (categoryName == string.Empty || categoryDescription == string.Empty) { Message.ShowMessage("Check Text fields"); return; } else if (categoryName.Length > 100 || categoryDescription.Length > 150) { Message.ShowMessage("Check Text fields length"); return; } if (!notDepreciable) { if (depreciation == string.Empty) { Message.ShowMessage("Check Depreciation"); return; } else { double.TryParse(depreciation, out depreciationRate); if (depreciationRate <= 0) { Message.ShowMessage("Check Depreciation rate"); return; } } } int CCode, maxItemCode, uppreLimit, itemCode; CCode = Convert.ToInt32(cboControl1.SelectedValue); List <FixedAssets> FAlist = MainWindow.listFixedAssets.Where(x => x.CCode == CCode).ToList(); maxItemCode = FAlist.Count == 0 ? 0 : FAlist.Max(x => x.ItemCode); uppreLimit = CCode * 1000 + 999; if (maxItemCode == uppreLimit) { Message.ShowMessage("999 Items added under control account"); return; } else { itemCode = maxItemCode == 0 ? CCode * 1000 + 1 : maxItemCode + 1; } string Query = "INSERT INTO FixedAssetsItem VALUES(@CCode, @ItemCode, @Depreciation, @ItemName, @DESCRIPTION)"; string CS = ConfigurationManager.ConnectionStrings["TestDB"].ConnectionString; using (SqlConnection con = new SqlConnection(CS)) { SqlParameter Depre = depreciationRate == 0 ? new SqlParameter("@Depreciation", DBNull.Value) : new SqlParameter("@Depreciation", depreciationRate); SqlParameter[] para = { new SqlParameter("@CCode", CCode), new SqlParameter("@ItemCode", itemCode), Depre, new SqlParameter("@ItemName", categoryName), new SqlParameter("@DESCRIPTION", categoryDescription) }; ListClass lc = new ListClass(); try { con.Open(); MainWindow.listFixedAssets = SqlClass.ExecuteNonQuery(Query, MainWindow.listFixedAssets, lc.FixedAssetsControlList, para); Message.ShowMessage("Item added to List"); } catch (Exception ex) { Message.ShowMessage(ex.ToString()); } } }
public void LoadBuiltinClasses() { classes["Int"] = new IntClass(); classes["Float"] = new FloatClass(); classes["Boolean"] = new BooleanClass(); classes["String"] = new StringClass(); classes["Char"] = new CharClass(); classes["Byte"] = new ByteClass(); classes["Message"] = new MessageClass(); classes["Unassigned"] = new UnassignedClass(); classes["Tuple"] = new TupleClass(); classes["NameValue"] = new NameValueClass(); classes["Lambda"] = new LambdaClass(); classes["Void"] = new VoidClass(); classes["Some"] = new SomeClass(); classes["None"] = new NoneClass(); classes["Array"] = new ArrayClass(); classes["Iterator"] = new IteratorClass(); classes["LazyIterator"] = new LazyIteratorClass(); classes["StreamIterator"] = new StreamIteratorClass(); classes["Any"] = new AnyClass(); classes["Placeholder"] = new PlaceholderClass(); classes["Range"] = new RangeClass(); classes["Dictionary"] = new DictionaryClass(); classes["Container"] = new ContainerClass(); classes["Unmatched"] = new UnmatchedClass(); classes["Complex"] = new ComplexClass(); classes["Rational"] = new RationalClass(); classes["Long"] = new LongClass(); classes["Lazy"] = new LazyClass(); classes["YieldingInvokable"] = new YieldingInvokableClass(); classes["Del"] = new DelClass(); classes["Slice"] = new SliceClass(); classes["End"] = new EndClass(); classes["List"] = new ListClass(); classes["Arguments"] = new ArgumentsClass(); classes["Symbol"] = new SymbolClass(); classes["Infinity"] = new InfinityClass(); classes["OpenRange"] = new OpenRangeClass(); classes["KeyValue"] = new KeyValueClass(); classes["Regex"] = new RegexClass(); classes["Pattern"] = new PatternClass(); classes["PackageFunction"] = new PackageFunctionClass(); classes["Sys"] = new SysClass(); classes["Math"] = new MathClass(); classes["RuntimeFunction"] = new RuntimeFunctionClass(); classes["Reference"] = new ReferenceClass(); classes["Group"] = new RegexGroupClass(); classes["Match"] = new RegexMatchClass(); classes["Date"] = new DateClass(); classes["Interval"] = new IntervalClass(); classes["TypeConstraint"] = new TypeConstraintClass(); classes["ByteArray"] = new ByteArrayClass(); classes["Selector"] = new SelectorClass(); classes["Number"] = new NumberClass(); classes["Collection"] = new CollectionClass(); classes["TextFinding"] = new TextFindingClass(); classes["SkipTake"] = new SkipTakeClass(); classes["Constructor"] = new ConstructorClass(); classes["MutString"] = new MutStringClass(); classes["Error"] = new ErrorClass(); classes["Success"] = new SuccessClass(); classes["Failure"] = new FailureClass(); classes["Optional"] = new OptionalClass(); classes["Result"] = new ResultClass(); classes["Monad"] = new MonadClass(); classes["Unit"] = new UnitClass(); classes["YieldReturn"] = new YieldReturnClass(); classes["Index"] = new IndexClass(); classes["Cycle"] = new CycleClass(); classes["Set"] = new SetClass(); }
public TravelMoreInfo(ListClass listclass) { InitializeComponent(); BindingContext = listclass; x = listclass; }
public void TestIndexerWithIgnoreCollectionOrderNegative() { var jane = new Person { Name = "Jane" }; var john = new Person { Name = "Mary" }; var mary = new Person { Name = "Mary" }; var jack = new Person { Name = "Jack" }; var jo = new Person { Name = "Jo" }; var sarah = new Person { Name = "Sarah" }; var nameList1 = new List<Person>() { jane, jack, mary, jo }; var nameList2 = new List<Person>() { jane, john, jack, sarah }; var class1 = new ListClass<Person>(nameList1); var class2 = new ListClass<Person>(nameList2); _compare.Config.IgnoreCollectionOrder = true; Assert.IsFalse(_compare.Compare(class1, class2).AreEqual); Assert.IsFalse(_compare.Compare(class2, class1).AreEqual); }
public void TestIndexerWithIgnoreCollectionLengthNegative() { var jane = new Person { Name = "Jane" }; var john = new Person { Name = "John" }; var mary = new Person { Name = "Mary" }; var jack = new Person { Name = "Jack" }; var nameList1 = new List<Person>() { jane, john, jack, mary }; var nameList2 = new List<Person>() { jane, john, jack }; var class1 = new ListClass<Person>(nameList1); var class2 = new ListClass<Person>(nameList2); var prior = _compare.Config.MaxDifferences; _compare.Config.MaxDifferences = int.MaxValue; _compare.Config.IgnoreCollectionOrder = true; var result = _compare.Compare(class1, class2); Console.WriteLine(result.DifferencesString); Assert.AreEqual(3, result.Differences.Count); result = _compare.Compare(class2, class1); Console.WriteLine(result.DifferencesString); Assert.AreEqual(3, result.Differences.Count); _compare.Config.MaxDifferences = prior; }
static ListClass quick(ListClass l) { return(quickaux(l, null)); }
private void PopulateViewList() { string[] CO_places = { "Pyramids of Giza", "Al Azhar Park", "Saqqara", "Egyptian Muesuem", "Sphinx" }; string[] SE_places = { "Mahe", "Victoria", "Beau Vallon", "La Digue" }; string[] DU_places = { "Shaka Marine World", "Umgeni River Bird Park", "Botanic Gardens", "Suncoast Casino and Entertainment World", "Moses Mabhida Stadium" }; string[] AD_places = { "Holy Trinity Cathedral", "Adadi Mariyam", "Mt.Entoto", "Afar Region", "Lake Tana" }; double[] CO_lat = { 29.9792, 30.0406, 29.5216, 30.0478, 29.9753 }; double[] SE_lat = { -4.6827, -4.6191, -4.6211, -4.3591 }; double[] DU_lat = { -29.8086, -29.8086, -29.8479, -29.8354, -29.8290 }; double[] AD_lat = { 9.0303, 8.6305, 9.1156, 11.7559, 12.0266 }; double[] CO_long = { 31.1342, 31.2647, 31.125897, 31.2336, 31.1376 }; double[] SE_long = { 55.4804, 55.4513, 55.4278, 55.8412 }; double[] DU_long = { 31.0459, 31.0174, 31.0082, 31.0346, 31.0304 }; double[] AD_long = { 38.7664, 38.5020, 38.7722, 40.9587, 37.3035 }; var List = new ObservableCollection <ListClass>(); var item = new ListClass { IconSource = "Cairo.png", websiteName = "1. Cairo, Egypt", websiteDescription = "It's the capital of Egypt.It's the largest city in Egypt, and" + "also the 15th largest city in the world.", latitude = CO_lat, longitude = CO_long, places = CO_places, wetherkey = "&q=Cairo" }; List.Add(item); MyList[0] = item; var item1 = new ListClass { IconSource = "Seychelles.png", websiteName = "2. Seychelles", websiteDescription = "It's a republic in France, and one of the sovereign states" + "in the Indian Ocean.", latitude = SE_lat, longitude = SE_long, places = SE_places, wetherkey = "&q=Seychelles" }; List.Add(item1); MyList[1] = item1; var item2 = new ListClass { IconSource = "Durban.png", websiteName = "3. Durban, South Africa", websiteDescription = "Located on east coast of South Africa, and one of the largest cities.", latitude = DU_lat, longitude = DU_long, places = DU_places, wetherkey = "&q=Durban" }; List.Add(item2); MyList[2] = item2; var item3 = new ListClass { IconSource = "Adidas-Ababa.png", websiteName = "4. Adidas Ababa, Ethopia", websiteDescription = "It's the capital of Ethiopia.", latitude = AD_lat, longitude = AD_long, places = AD_places, wetherkey = "&q=Addis Ababa" }; List.Add(item3); MyList[3] = item3; AFR.ItemsSource = List; }
void worker_DoWork(object sender, DoWorkEventArgs e) { _list = BS_PokedexManager.Business.GeneratePokeList(generation, sender as BackgroundWorker); }
private void PopulateViewList() { string[] SP_places = { "South Pole City" }; string[] NP_places = { "Santa Town", "North Pole City" }; string[] MM_places = { "McMuradoBase" }; double[] SP_lat = { -90 }; double[] NP_lat = { 83.40, 90 }; double[] MM_lat = { -77.50599 }; double[] SP_long = { 0 }; double[] NP_long = { -29.50, 0 }; double[] MM_long = { 166.395999 }; var List = new ObservableCollection <ListClass>(); var item = new ListClass { IconSource = "Antartica.png", websiteName = "1. South Pole, Antartica", websiteDescription = "One of the hemispheres in Antartica. ", latitude = SP_lat, longitude = SP_long, places = SP_places, wetherkey = "&q=Nuuk" }; List.Add(item); MyList[0] = item; var item1 = new ListClass { IconSource = "Antartica.png", websiteName = "2. North Pole, Antarctica", websiteDescription = "A random city in Antartica. How do I get there?" + "First, go to south pole. There is a magical portal in south pole which will teleport you to north pole.", latitude = NP_lat, longitude = NP_long, places = NP_places, wetherkey = "&q=Nuuk" }; List.Add(item1); MyList[1] = item1; var item2 = new ListClass { IconSource = "Antartica.png", websiteName = "3. Mc.Murdo Station, Antartica", websiteDescription = "Another random city in Antartica. The only city in Antartica that has life.", latitude = MM_lat, longitude = MM_long, places = MM_places, wetherkey = "&q=Nuuk" }; List.Add(item2); MyList[2] = item2; ANT.ItemsSource = List; }
public void Teardown() { _list = null; }
public CitiesMoreInfo(ListClass listclass) { InitializeComponent(); MyList = listclass; welcome.Text = MyList.websiteName; }