private void RefreshList() { int totalPage = PageList.GetTotalPage(); int currentPage = PageList.GetCurrentPage(); if (currentPage == 1) { PrePageLBtn.Enabled = false; } else { PrePageLBtn.Enabled = true; } if (currentPage == totalPage) { NextPageLBtn.Enabled = false; } else { NextPageLBtn.Enabled = true; } CurrentPageLbl.Text = PageList.GetCurrentPage().ToString(); TotalPageLbl.Text = PageList.GetTotalPage().ToString(); ExampleList.DataSource = PageList.GetCurrentList(); ExampleList.DataBind(); }
static void Main(string[] args) { var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appconfig.json") .Build(); string connectionString = $"Persist Security Info=False;database={config["database"]};" + $"server={config["server"]};" + $"user id={config["user"]};" + $"Password={config["password"]}"; MySqlConnection connection = null; try { connection = new MySql.Data.MySqlClient.MySqlConnection(connectionString); connection.Open(); foreach (var runExample in ExampleList.GetList()) { runExample(connection); } } catch (Exception ex) { connection?.Dispose(); Console.WriteLine(ex.Message); } }
static void Main(string[] args) { ExampleArrayList exampleArrayList = new ExampleArrayList(); exampleArrayList.ShowExample(); ExampleHashTable exampleHashTable = new ExampleHashTable(); exampleHashTable.ShowExample(); ExampleStack exampleStack = new ExampleStack(); exampleStack.ShowExample(); ExampleQueue exampleQueue = new ExampleQueue(); exampleQueue.ShowExample(); ExampleList exampleList = new ExampleList(); exampleList.ShowExample(); ExampleDictionary exampleDictionary = new ExampleDictionary(); exampleDictionary.ShowExample(); ExampleStackGeneric exampleStackGeneric = new ExampleStackGeneric(); exampleStackGeneric.ShowExample(); ExampleQueueGeneric exampleQueueGeneric = new ExampleQueueGeneric(); exampleQueueGeneric.ShowExample(); ExampleLinkedList exampleLinkedList = new ExampleLinkedList(); exampleLinkedList.ShowExample(); ExInterfaces exInterfaces = new ExInterfaces(); exInterfaces.ShowExample(); Console.ReadKey(); }
/// <summary> /// Method to create Excel based on options selected by the user. /// </summary> private void GenerateExcel() { openBtn.Enabled = false; try { FileInfo file = new FileInfo(RESULT_FILE); if (file.Exists && IsFileAlreadyOpen(file)) { return; } string text = File.ReadAllText(SOURCE_JSON); ExampleList list = JsonConvert.DeserializeObject <ExampleList>(text); Workbook book = new Workbook(); Worksheet dataSheet = book.Worksheets[0]; dataSheet.Name = "DataSheet"; Cell cell = dataSheet.Cells["A1"]; cell.Value = "EmployeeId"; cell = dataSheet.Cells["B1"]; cell.Value = "Type"; cell = dataSheet.Cells["C1"]; cell.Value = "Price"; dataSheet.Import(list, 1, 0); if (chartCB.Checked) { Worksheet chartsSheet = book.Worksheets.Add("Charts"); Chart chart = chartsSheet.Charts.Add(ChartType.Pie); chart.TopLeftCell = chartsSheet.Cells["B2"]; chart.BottomRightCell = chartsSheet.Cells["P30"]; // Add chart series using worksheet ranges as the data sources. Series series1 = chart.Series.Add(dataSheet["B1"], dataSheet["B2:B10"], dataSheet["C2:C10"]); chart.Series.Add(dataSheet["A1"], dataSheet["A2:A10"], dataSheet["C2:C10"]); // Display the category name and percentage. DataLabelOptions dataLabels = chart.Views[0].DataLabels; dataLabels.ShowCategoryName = true; dataLabels.LabelPosition = DataLabelPosition.OutsideEnd; dataLabels.ShowPercent = true; } if (tableCB.Checked) { Worksheet tableSheet = book.Worksheets.Add("Table"); cell = tableSheet.Cells["A1"]; cell.Value = "EmployeeId"; cell = tableSheet.Cells["B1"]; cell.Value = "Type"; cell = tableSheet.Cells["C1"]; cell.Value = "Price"; tableSheet.Import(list, 1, 0); Table table = tableSheet.Tables.Add(tableSheet["A1:C" + (list.Count + 1)], true); table.ShowTotals = true; table.Style = book.TableStyles[BuiltInTableStyleId.TableStyleMedium27]; } if (pivotCB.Checked) { Worksheet pivotSheet = book.Worksheets.Add("Pivot"); PivotTable table = pivotSheet.PivotTables.Add(dataSheet["A1:C10"], pivotSheet["A1"], "PivotTable"); table.RowFields.Add(table.Fields["EmployeeId"]); table.ColumnFields.Add(table.Fields["Type"]); table.DataFields.Add(table.Fields["Price"]); table.Style = book.TableStyles[BuiltInPivotStyleId.PivotStyleDark6]; } dataSheet.Visible = false; dataSheet.VisibilityType = WorksheetVisibilityType.VeryHidden; book.SaveDocument(RESULT_FILE, DocumentFormat.Xlsx); MessageBox.Show("Excel created successfully."); } catch (Exception ex) { MessageBox.Show("Some error occurred, Please try again."); } openBtn.Enabled = true; }