I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
Introduction
Design simple age calculator , calculate remaining days from two dates. Suppose your Date of Birth is 19/mar/1987 and you want to calculate total days on till date. Here we take an simple demonstration of this type of application.Design
Step-1 : Add two DateTimerPicker and one button control on windows form.Step-2 : Take Two Datetime class instance, first for starting date and second for ending date.
Step-3 : Calulate difference between two dates using Timespan structure.
Step-4 : Using TotalDays property of TimeSpan structure you can calculate days.
Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace datecalulator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DateTime dtstart = dateTimePicker1.Value;
DateTime enddate = dateTimePicker2.Value;
TimeSpan totaldays = enddate - dtstart;
int calculate =Convert .ToInt32 (totaldays.TotalDays);
MessageBox.Show(calculate.ToString()+" Days");
}
}
}
Comments
Post a Comment