public void GetTeams() { DataTable dt = null; var teams = _quizTeamService.GetAll().Select(x => new { x.Id, x.Name, x.Schoolname, x.Marks }).ToList(); if (teams != null && teams.Count() != 0) { if (teams.Count() > 0) { dt = ExportExcelhelper.ListToDataTable(teams); } } else { List <QuizTeam> list = new List <QuizTeam>(); QuizTeam quizTeam = new QuizTeam(); list.Add(quizTeam); dt = ExportExcelhelper.ListToDataTable(list); dt.Rows.RemoveAt(0); } QuestiondataGridView.AutoGenerateColumns = true; QuestiondataGridView.DataSource = dt; QuestiondataGridView.Columns["Id"].Visible = false; }
public ActionResult GetOrderExitReport(DateTime fromDate, DateTime toDate) { List <string> Exitheders = new List <string>(); Exitheders.Add("Product Name"); Exitheders.Add("Product Number"); Exitheders.Add("Client Name"); Exitheders.Add("Quantity"); Exitheders.Add("Cost"); Exitheders.Add("Exit Date"); var ordersExit = (from sto in orderExitService.GetAll().ToList() join cli in clientService.GetAll().ToList() on sto.ClientId equals cli.UniqueId join pro in productService.GetAll().ToList() on sto.ProductId equals pro.UniqueId where sto.CreatedDate.Date >= fromDate.Date && sto.CreatedDate.Date <= toDate.Date && sto.IsActive == true select new WMS.WebUI.Models.OrderExitReport { ProductName = pro.Name, ProductNumber = pro.Number, ClientName = cli.Name, Quantity = sto.Quatity, Cost = sto.Cost, ExitDate = sto.ExitDate.ToString("dd-MM-yyyy") }).ToList(); DataSet ds = new DataSet(); DataTable orderExitTable = ExportExcelhelper.ListToDataTable(ordersExit); ds.Tables.Add(orderExitTable); byte[] filecontent = ExportExcelhelper.ExportExcelDataset(ds, Exitheders, "Sell Orders", true, null, null, Exitheders.ToArray()); return(File(filecontent, ExportExcelhelper.ExcelContentType, "OrderExit.xlsx")); }
public void GetQuestions() { DataTable dt = null; var questions = (from qq in _quizQuestionService.GetAll().ToList() join ql in _quizLevelService.GetAll().ToList() on qq.LevelId equals ql.Id join qr in _quizRoundService.GetAll().ToList() on qq.RoundId equals qr.Id select new QuizQuestions { Id = qq.Id, AcademicYear = qq.AcademicYear, Level = ql.Name, Round = qr.Name, QuestionText = qq.Question, QuestionType = qq.QuestionType, DocUrl = qq.DocUrl, IsMCQ = qq.IsMCQ, CorrectAnswer = qq.CorrectAnswer, Option1 = qq.Option1, Option2 = qq.Option2, Option3 = qq.Option3, Option4 = qq.Option4, Time = qq.Time + " Sec." }).ToList(); if (questions != null && questions.Count() != 0) { if (questions.Count() > 0) { dt = ExportExcelhelper.ListToDataTable(questions); } } else { List <QuizQuestions> list = new List <QuizQuestions>(); QuizQuestions quizQuestion = new QuizQuestions(); list.Add(quizQuestion); dt = ExportExcelhelper.ListToDataTable(list); dt.Rows.RemoveAt(0); } QuestiondataGridView.AutoGenerateColumns = true; QuestiondataGridView.DataSource = dt; QuestiondataGridView.Columns["Id"].Visible = false; }
private void FillLevels() { var levels = _quizLevelService.GetAll().Select(x => new { x.Id, x.Name }).ToList(); DataTable dt = ExportExcelhelper.ListToDataTable(levels); DataRow dr1 = dt.NewRow(); dr1["Id"] = 0; dr1["Name"] = "--Select Level --"; dt.Rows.InsertAt(dr1, 0); LevelcomboBox.ValueMember = "Id"; LevelcomboBox.DisplayMember = "Name"; LevelcomboBox.DataSource = dt; }
private void FillTeamsOne() { var teams = _quizTeamService.GetAll().Select(x => new { x.Id, x.Name }).ToList(); DataTable dt = ExportExcelhelper.ListToDataTable(teams); DataRow dr0 = dt.NewRow(); dr0["Id"] = "0"; dr0["Name"] = "-- Select Team 1 --"; dt.Rows.InsertAt(dr0, 0); ChooseTeam1comboBox.ValueMember = "Id"; ChooseTeam1comboBox.DisplayMember = "Name"; ChooseTeam1comboBox.DataSource = dt; }
public DataSet GetLevelListData() { DataSet ds = new DataSet(); try { var quizLevels = _quizLevelService.GetAll().Select(x => new { x.Name, x.Description }).ToList(); DataTable dt = ExportExcelhelper.ListToDataTable(quizLevels); ds.Tables.Add(dt); return(ds); } catch (Exception ex) { throw; } }
public ActionResult GetOrderEntryReport(DateTime fromDate, DateTime toDate) { List <string> Entryheders = new List <string>(); Entryheders.Add("Product Name"); Entryheders.Add("Product Number"); Entryheders.Add("Supplier Name"); Entryheders.Add("Unit Name"); Entryheders.Add("Quantity"); Entryheders.Add("Cost"); Entryheders.Add("Entry Date"); var ordersEntry = (from sto in stockService.GetAll().ToList() join sup in supplierService.GetAll().ToList() on sto.SupplierId equals sup.UniqueId join pro in productService.GetAll().ToList() on sto.ProductId equals pro.UniqueId join un in unitService.GetAll().ToList() on sto.UnitId equals un.UniqueId where sto.CreatedDate.Date >= fromDate.Date && sto.CreatedDate.Date <= toDate.Date && sto.IsActive == true select new OrderEnterReport { ProductName = pro.Name, ProductNumber = pro.Number, SupplierName = sup.Name, UnitName = un.Name, Quantity = sto.Quatity, CostPerProduct = sto.CostPerProduct, EntryDate = sto.EntryDate.ToString("dd-MM-yyyy") }).ToList(); DataSet ds = new DataSet(); DataTable orderEntryTable = ExportExcelhelper.ListToDataTable(ordersEntry); ds.Tables.Add(orderEntryTable); byte[] filecontent = ExportExcelhelper.ExportExcelDataset(ds, Entryheders, "Purchase Orders", true, null, null, Entryheders.ToArray()); return(File(filecontent, ExportExcelhelper.ExcelContentType, "OrderEntries.xlsx")); }