-->

Monday, 18 April 2016

Creating a MVC Web Application Project with a Class Library in C#

Classes provide reusable code in the form of objects. A class library contains one or more classes that can be called on to perform specific actions. This walkthrough shows how to create a class library project in C# and incorporate it into a Web application project.

In order to complete this walkthrough, you will need:
  • The .NET Framework version 3.5.
  • The SP1 release of Visual Web Developer 2010 Express.
The following procedures build upon each other. Therefore, you must follow the order of the procedures to successfully complete this walkthrough.

Creating the Class Library Project

To create the CDemoLib class library and the Customer class file

1.      On the File menu, select New Project to open the New Project dialog box.
2.      In the list of Windows project types, select Class Library, and then type CDemoLib in the Name box.
3.      In Solution Explorer, right-click CDemoLib and then click Properties.
Notice that the Default namespace box contains CDemoLib. The root namespace is used to qualify the names of class in the assembly. For example, if two assemblies provide class named Customer, you can specify the Customer class by using CDemoLib.Customer.
Close the properties window.
4.      In Solution Explorer, right-click CDemoLib, click Add, and then click Class.
The Add New Item dialog box is displayed.
5.      Type Customer.cs in the Name box and then click Add to create the class.
A class named Customer is added to your class library.
6.      In Solution Explorer, right-click Class1.cs and then click Delete.
This deletes the default class that is provided with the class library, because it will not be used in this walkthrough.
7.      In the File menu, click Save All to save the project.

Creating the Class

Constructors control the way your class is initialized. Properties are values of the class that you can get and set. In Visual C#, all constructors have the same name as the class.

To add code to define the Customer class

·         In the code editor, replace the existing code with the following code to define the Customer class in the CDemoLib class library.
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 namespace CDemoLib
{
    public class Customer
    {
        private int _age;
        private string _name;
         public Customer()
        {
            Age = 0;
            Name = "Not available";
        }
         public int Age
        {
            get { return _age; }
            set { _age = value; }
        }
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }
    }
}

Adding the Class Library to a Web Application Project

To test the class, you must have a project that uses it. This project must be the first project that starts when you run the application.

To add the CDemoTest Web Application project as the startup project for the solution

1.      In the File menu, click Add and then click New Project.
The Add New Project dialog box is displayed.
2.      Under Project types, expand Visual Basic or Visual C#, and then click Web to display available Web templates.
3.      In the Templates box, select ASP.NET Web Application.
4.      In the Name box, type CDemoTest as the name of the new application.
5.      Click OK.
creates the Web application project in the existing solution.
In order to use the Customer class, the client test project must have a reference to the class library project. After you add the reference, it is a good idea to add a using statement in C# (an Imports statement in Visual Basic) to the test application to simplify the use of the class.

To add a reference to the class library project

1.      In Solution Explorer, right-click the References node underneath CDemoTest, and then click Add Reference.
2.      In the Add Reference dialog box, select the Projects tab.
3.      Double-click the CDemoLib class library project. CDemoLib will appear under the References node for the CDemoTest project.
4.      In Solution Explorer, right-click Default.aspx and then click View Code.
Adding the reference to CDemoLib lets you use the fully qualified name of the Customer class, which is CDemoLib.Customer.

To add a using or Imports statement

·         Add the following using statement (Imports in Visual Basic) at the top of the code editor window for the Default.aspx page.
C#
using CDemoLib;
·         Adding this statement lets you omit the library name, and refer to the class type as Customer.

Using the Class from the Class Library

The CDemoTest Web application will call the class that is contained in the class library and display the results.

To add code to create and use a Customer object

1.      In Solution Explorer, right-click Default.aspx and select View Designer.
2.      From the Standard tab of the Toolbox, drag a Label control onto the design surface.
3.      Double-click the design surface to display the Page_Load event handler.
4.      In the Page_Load event handler add the following code:
C#
Customer myCustomer = new Customer();
myCustomer.Name = "Alex Jendar";
myCustomer.Age = 30;
Label1.Text = "Name: " + myCustomer.Name +
    "<br/>Age: " + myCustomer.Age.ToString();
5.      In the File menu, click Save All to save the solution.

To run and debug the CDemoTest project

1.      Press CTRL+F5 to start the solution.
Notice that the Customer class properties are automatically displayed in the label control.
2.      Close the browser window to return to the development environment.


Wednesday, 15 October 2014

Mail Marketing Windows Form Project in C Sharp

Project Description: This project is used to send bulk mails without spamming to promote your products and services. You can send thousands mail using this tool, all mailing address stored in local database and bind with dataGridView data control. Mail marketing or bulk mailing tool send one by one mail and pick mail address for datagridview which import mail addresses from local database. Mail marketing project created in .net framework 3.5 using c sharp language.

Mail Marketing Windows Form Project in C Sharp

Features of Mail Marketing Project:
  • Send thousands of mail on one click.
  • DataGridView Control to bind database on runtime.
  • Used local database to store mail addresses.
  • Protected for mass mailing or spamming.
  • Easy to manage controls and database.
  • Secure app.config file.
download
ProSoureCode:

To Bind Database:
  private void Form1_Load(object sender, EventArgs e)
        {
            DataTable dT;
            BindingSource bS;

            using (SqlCeConnection con = new SqlCeConnection("Data Source=|DataDirectory|\\Database1.sdf"))
            {
                dT = new DataTable();
                bS = new BindingSource();
                string query = "SELECT * FROM mailinglist";
                SqlCeDataAdapter dA = new SqlCeDataAdapter(query, con);
                SqlCeCommandBuilder cBuilder = new SqlCeCommandBuilder(dA);
                dA.Fill(dT);
                bS.DataSource = dT;
                dataGridView1.DataSource = bS;
            }
           
        }

To Send Mails:
   private void button1_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in this.dataGridView1.Rows)
            {

                var email = row.Cells[2].Value.ToString();
        try
        {
            SmtpClient client = new SmtpClient("smtp.gmail.com");
            client.Port = 587;
            client.EnableSsl = true;
            client.Timeout = 100000;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.Credentials = new NetworkCredential("your mail address", "your mail password");
            MailMessage msg = new MailMessage();
            msg.To.Add(email);
            msg.From = new MailAddress("your mail address");
            msg.Subject = textBox1.Text;
            msg.Body = richTextBox1.Text;
            client.Send(msg);
            MessageBox.Show("Successfully Sent Message.");
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
   
            }
        }

    
      
    }

Tuesday, 14 October 2014

Auto Bookmark and SEO Optimizer Windows Form Project in C Sharp

Project Description: Auto Bookmark and SEO Optimizer windows application project is used for auto linking of your site or blog to high page rank sites. This tool ping your site or blog more than 100 sites to check SEO, backlinks, keyword density, bed neighborhood etc. and Analysis html, quality, whois, trustworthiness, CSS, DAML, hCard, JSON validator, W3C link, WCAG 1.0 etc. and accessibility, site network  performance and sites security factors, performance and more, and provide real time view using webBrowser control.  This project build in .net framework 3.5 using c sharp language.

Auto Bookmark and SEO Optimizer Windows Form

Features of Auto Bookmark and SEO Optimizer Project:
  • Instant Backlining.
  • Real Time control.
  • Check Site or blog Performance.
  • Check all W3C validator.
  • Check Meta data and other SEO factors.
  • Check site or blog network performance.
  • Check site security factors.
  • Check site info, grader and review etc.
download

This project containing solution file and form files not setup file, you can request it for $5.


After completing of all submissions, Google index your site or blog within 24 hours. As a result you can see snapshot below:
Google index

Thursday, 9 October 2014

Salary Calculate/Pay Slip Generator Windows Application Project in C Sharp

Project Description: Salary Management System or Pay Slip Generator Application project is a windows application project used for calculates the monthly salary of an employee on the basic of Allowance, Bonuses, Provident Fund Medical Deduction and Other Benefit. This project builds in .net framework 3.5 using c sharp language.

Salary Calculate Windows Application Project in C Sharp

Features of Salary Calculate Application Project:
  • Build in single windows form.
  • Platform independent.
  • Easy customization(add or delete fields).
  • One click edit and reset feature.
download
ProSourceCode:
On Button Click Even:
        private void button1_Click(object sender, EventArgs e)
        {
            int sal = 0;
            sal += int.Parse(comboBox2.Text);
            if (checkBox1.Checked == true)
            {
                sal += 5000;
            }
            if (checkBox2.Checked == true)
            {
                sal += 5000;
            }
            if (checkBox3.Checked == true)
            {
                sal += 5000;
            }
            if(checkBox4.Checked==true){
                sal +=5000;
                sal += (10000 * listBox1.SelectedIndices.Count);
            }

            if (checkBox5.Checked == true)
            {
                sal -= 1500;
            }
            if (checkBox6.Checked == true)
            {
                sal -= 2500;
                
            }
            textBox2.Text = sal.ToString();
        }

       

Wednesday, 8 October 2014

Net Booster Windows Form Project in .Net 3.5 Framework

Project Description: Net Booster project is windows application which main purpose is boost 20% and more Dial up or Broadband network internet speed by updating windows registry files these updates known as window tweaks. This project built in .net framework 3.5, so after build a setup file you must need .net framework 3.5 to run this project and it also need administrator privileges to manipulate windows configuration, so run this project in “Run as administrator” mode. 

Net Booster Windows Form Project in .Net 3.5 Framework

Features of Net Booster Project:
  • Build in windows form.
  • Integrated with process bar.
  • Demonstrate how to access window registry file.
  • One click edit and reset feature.
  • Build individual setup file.

”download”
ProSourceCode:

To add Values:
string add = @"SYSTEM\CurrentControlSet\Services\TCPIP\Parameters";
            key1 = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(add);
            key1.SetValue("TcpTimedWaitDelay",30);
            key1.SetValue("MaxUserPort",32768);
            key1.SetValue("KeepAliveInterval",1);
            key1.SetValue("GlobalMaxTcpWindowSize", 256960);
            key1.SetValue("TcpWindowSize", 256960);
            key1.SetValue("DefaultTTL", 64);
            key1.SetValue("EnablePMTUDiscovery", 1);
            key1.SetValue("SackOpts", 1);
            key1.SetValue("TcpMaxDupAcks", 2);
            key1.Close();
            string add1 = @"SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters";
            key = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(add1);
            key.SetValue("IRPStackSize", 32);
            key.SetValue("SizReqBuf", 17424);
            key.Close();

To delete Values:
                    key.DeleteValue("TcpTimedWaitDelay");
                    key.DeleteValue("MaxUserPort");
                    key.DeleteValue("KeepAliveInterval");
                    key.DeleteValue("GlobalMaxTcpWindowSize");
                    key.DeleteValue("DefaultTTL");
                    key.DeleteValue("EnablePMTUDiscovery");
                    key.DeleteValue("SackOpts");
                    key.DeleteValue("TcpMaxDupAcks");
                    key.DeleteValue("TcpWindowSize");
                    key.Close();

Friday, 3 October 2014

E-Learning or Virtual Classes Hub Project In ASP.Net using C#

Project Description: E-Learning education is an effective term describing online education system through the internet. This term also known as Virtual Classes that means it is a portal to learning from home no needs to go tuition classes. A virtual program is a study program in which college and university offers all courses, or a significant portion of the courses which require, are virtual courses, E-learning mostly provided by universities and schools which offers distance education, the current intersection of virtual portal is as a means to facilitate real-time communication with community-centered interaction.

E-Learning or Virtual Classes Hub Project In ASP.Net using C#

Features of E – Learning or Virtual Classes Hub Project:
  •   Integrate Videos Tutorials.
  •  Online and offline payment option.
  •  Live demo classes
  •  Audio and visual integrated lessons 
  •  No need of physical class structure.
  •  Beneficial for Distance Education
  • Admin account to manage Teachers and Students A/C
download

© Copyright 2019 Project Source Code | All Right Reserved