September 29, 2017


September 5, 2017

Getting Started With Material Design and MahApps

Quick Start

You can install MahApps.Metro via the NuGet GUI (right click on your project, click Manage NuGet Packages, select Online and search for MahApps.Metro) or with the Package Manager Console




or use the Package Manager Console

In the next we will learn how to style Window

August 7, 2017

Styling the Window

Styling the Window

In the previous post we have learn the basic for mahApps. In this post we will learn how to make a widow look good.

That's simple:
  • You can use the included MetroWindow control.
For now we’ll use MetroWindow, as this approach will work for a good percentage of apps and is the quickest and easiest way to get going. 

Modifying the XAML file

After installing MahApps.Metro:
  • open up MainWindow.xaml
  • add this attribute inside the opening Window tag. (It’s how you reference other namespaces in XAML):
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    or
    xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
  • change  tag to  (remember to change the closing tag too!)
 

    
        
    

You’ll also need to modify the MainWindow.xaml.cs file so that the base class for MainWindow matches the MetroWindow class of the XAML file.

public partial class MainWindow : MetroWindow

Using Built-In Styles

All of MahApp.Metro’s resources are contained within separate resource dictionaries. In order for most of the controls to adopt the MahApps.Metro theme, you will need to add the ResourceDictionaries to your App.xaml.
App.xaml
 x:Class="WpfApplication.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
                 
         Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
         Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
         Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
        
         Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
         Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />   
The end result will look something like this. If you want to know more about how the control works, more information can be found below.



In the next post we will give border to Windows Form

July 17, 2017

Giving borders to mahApps Windoes Form

Window borders

In the previous post we have given style to Windows form. In this post we will learn how to give border to the windows form.
The MetroWindow can have…
…a border
  
  BorderThickness="1"
   BorderBrush="{DynamicResource AccentColorBrush}"

July 13, 2017

How to drop all tables from a database with one SQL query?

Note: If you have any foreign Keys defined between tables then first run the below query to disable all foreign keys present in your database.

EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
 
Use the INFORMATION_SCHEMA.TABLES view to get the list of tables. Generate Drop scripts in the select statement and drop it using Dynamic SQL:

DECLARE @sql NVARCHAR(max)='' SELECT @sql += ' Drop table ' + QUOTENAME(TABLE_SCHEMA) + '.'+ QUOTENAME(TABLE_NAME) + '; ' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' Exec Sp_executesql @sql
 

July 10, 2017

Creating Login In C# MVC



Add a class in Model Folder
Right click on the Model folder ->add new items->add class.
    Name of Class is "UserMaster"
    In a class define the properties.


public string UserName
        { get; set; }
        public string UserID
        { get; set; }
        public string Password
        { get; set; }
        public string GroupID
        { get; set; }
        public string EmployeeID
        { get; set; }
        public string UserEmail
        { get; set; }
        public string CreatedBy
        { get; set; }
        public string ModifiedBy
        { get; set; }
        public string NewPswd
        { get; set; }

Add a controller.
  • Right click on the Controllers folder ->add->Controllers.
  • Name of Controllers is "Login".
  • In a controller, define the request.
  •