Articles by "C#"
Showing posts with label C#. Show all posts
Print Friendly and PDF
no image
Place where all sort of programming stuff and reviews,technology news are shared and Useful Project of C++,C,java C# etc
In this article, I am going to explain how to perform Crud Operation with AngularJs in asp.net MVC.

First Of All,  Create A Database with Name Testdb with following script copy and paste into SQL server.

Database Table 
USE [Testdb]
GO

/****** Object:  Table [dbo].[Employe]    Script Date: 9/16/2017 1:15:19 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Employe](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Name] [varchar](50) NULL,
    [Phone] [int] NULL,
    [Salary] [int] NULL,
    [Department] [varchar](50) NULL,
    [EmailId] [varchar](50) NULL,
 CONSTRAINT [PK_Employe] PRIMARY KEY CLUSTERED 
(
    [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
 ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

After Creating Database we need to run the Visual Studio create a new empty MVC Project.Now first going to right-click on Models Folder and then Click add →New Item → Data→Select  ADO.Net Entity Data model→ after Completing the whole steps than import the Appropriate database into your project. 

Entity Data Model Look like this
namespace CrudApp.Models
{
    using System;
    using System.Collections.Generic;
    
    public partial class Employe
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public Nullable<int> Phone { get; set; }
        public Nullable<int> Salary { get; set; }
        public string Department { get; set; }
        public string EmailId { get; set; }
    }
}
After Completing the entity data model now time to create a controller into Controller folder with Name TechSpiderController.cs. 
First Adding the model reference into controller file in my case Model Name Look line this 
using CrudApp.Models;
TechSpiderController.cs

First, i am initializing the entity database connection into my controller file in my case I have a connection string name TestdbEntities that comes from web.config file 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CrudApp.Models;
namespace CrudApp.Controllers
{
    public class TechSpiderController : Controller
    {

        TestdbEntities db = new TestdbEntities();

        // GET: Demo
        public ActionResult Index()
        {
            return View();
        }
}
}

Whole Source code of this Controller 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CrudApp.Models;
namespace CrudApp.Controllers
{
    public class TechSpiderController : Controller
    {

        TestdbEntities db = new TestdbEntities();

        // GET: Demo
        public ActionResult Index()
        {
            return View();
        }

        public JsonResult GetEmployee()
        {
            var emp = db.Employes.ToList();
            return Json(emp, JsonRequestBehavior.AllowGet);


        }
        [HttpPost]
        public JsonResult InsertEmployee(Employe em)
        {
            db.Employes.Add(em);
            db.SaveChanges();
            string message = "Success";
            return new JsonResult { Data = message, JsonRequestBehavior = 
             JsonRequestBehavior.AllowGet };


        }
        [HttpPost]
        public JsonResult UpdateEmployee(int id,string name,string department,
          int phone,int salary,string emailId)
        
        {

            var emp = db.Employes.Where(x => x.Id == id).FirstOrDefault();
            emp.Name = name;
            emp.Phone = phone;
            emp.Department = department;
            emp.Salary = salary;
            emp.EmailId = emailId;
            db.SaveChanges();
            return Json(emp, JsonRequestBehavior.AllowGet);
        }
        [HttpDelete]
        public JsonResult DeleteEmployee(int id)
        {
            Employe emp = db.Employes.Find(id);
            db.Employes.Remove(emp);
            db.SaveChanges();
            return Json(emp, JsonRequestBehavior.AllowGet);
        }
        [HttpGet]
        public JsonResult getByid(int id)
        {
            Employe emp = db.Employes.Find(id);
            return Json(emp, JsonRequestBehavior.AllowGet);
        }
    }
}

Now it's time to add view into your project right click on View in controller file and click  Add View→Save 

Index.chtml


@{ 
    ViewBag.Title = "Crud with AngularJs asp.net MVC";
}
<style>
    input[type=button][disabled=disabled] {
        opacity: 0.65;
        cursor: not-allowed;
    }

    table tr th {
        padding: 10px 30px;
    }

    table tr td {
        padding: 10px 30px;
    }
</style>
<h2>AngularJs Tutorial : CRUD operation</h2> <div ng-app="myapp" ng-controller="TechSpiderController"> <form name="myform"> <table class="table"> <tr> <td>Name :</td> <td> <input type="text" ng-model="empModel.Name" placeholder="Name"
                   class='form-control' required />
                </td>
            </tr>
            <tr>
                <td>Phone :</td>
                <td>
                    <input type="text" ng-model="empModel.Phone" placeholder="Phone" 
                class='form-control' required />
                </td>
            </tr>
            <tr>
                <td>Salary :</td>
                <td>
                    <input type="text" ng-model="empModel.Salary" placeholder="Salary" 
                    class='form-control' required />
                </td>
            </tr>
            <tr>
                <td>Department :</td>
                <td>
                    <input type="text" ng-model="empModel.Department" placeholder="Department" 
                   class='form-control' required />
                </td>
            </tr>
            <tr>
                <td>Email :</td>
                <td>
                    <input type="email" ng-model="empModel.EmailId"
                  class='form-control' placeholder="Email" required />
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="button" value="Save" id="btnsave" ng-disabled="isDisabledsave"
                    ng-click="myform.$valid && saveCustomer()" />
                    <input type="button" value="Update" id="btnupdate" ng-disabled="isDisabledupdate" 
                   ng-click="myform.$valid && updateCustomer()" />
                </td>
            </tr>
        </table>
    </form>
    <table>
        <tr>
            <th>S.No</th>

            <th>
                Name
            </th>
            <th>
                Phone
            </th>
            <th>
                Department
            </th>
            <th>
                Salary
            </th>
            <th>
                Email
            </th>
        </tr>
        <tr ng-repeat="empModel in employees">
            <td>{{empModel.Id}}</td>
            <td>{{empModel.Name }}</td>
            <td>{{empModel.Phone }}</td>
            <td>{{empModel.Department}}</td>
            <td>{{empModel.Salary }}</td>
            <td>{{empModel.EmailId ||'Email not available'}}</td>
            <td>
                <a href="" ng-click="getCustomer(empModel)" title="Delete Record">Edit</a>  |
                <a href="" ng-click="deleteemp(empModel)" title="Delete Record">
                    Delete
                </a>
            </td>
        </tr>
    </table>

</div>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js"></script>
<script>
    var angular = angular.module('mapp', []);

    angular.controller('TechSpiderController', function ($scope, $http) {

        GetAllData();
        $scope.isDisabledupdate = true;
        //Get All Employee
        function GetAllData() {
            $http.get('/Demo/GetEmployee').success(function (data) {
                $scope.employees = data;
            });
        };

        //Insert Employee
        $scope.saveCustomer = function () {
            debugger
            $http({
                method: 'POST',
                url: '/Demo/InsertEmployee',
                data: $scope.empModel
            }).success(function () {
                GetAllData();
                $scope.empModel = null;
                alert("Employee Added Successfully!!!");
            }).error(function () {
                alert(data.errors);
            });
            GetAllData();
        };

        //Delete Employee
        $scope.deleteemp = function (empModel) {
            debugger
            varIsConf = confirm('Want to delete ' + empModel.Name + '. Are you sure?');
            if (varIsConf) {
                $http.delete('/Demo/DeleteEmployee/' + empModel.Id).success(function () {
                    $scope.errors = [];
                    GetAllData();
                    alert(empModel.Name + " Deleted Successfully!!!");
                }).error(function () {
                    alert(data.errors);
                });
            }
        };

        //Get Employee by id to edit
        $scope.getCustomer = function (empModel) {
            $http.get('/Demo/getByid/' + empModel.Id)
                .success(function (data, status, headers, config) {
                    //debugger;
                    $scope.empModel = data;
                    GetAllData();
                    $scope.isDisabledsave = true;
                    $scope.isDisabledupdate = false;
                })
                .error(function () {
                    alert(data.errors);
                });
        };

        //Update Employee
        $scope.updateCustomer = function () {
            debugger
            $http({
                method: 'POST',
                url: '/Demo/UpdateEmployee',
                data: $scope.empModel
            }).success(function () {
                GetAllData();
                $scope.isDisabledsave = false;
                $scope.isDisabledupdate = true;
                $scope.empModel = null;
                alert("Employee Updated Successfully!!");
            }).error(function () {
                alert(data.errors);
            });
        };

    });
</script>

If You have any confusion in this articles please feel free and discuss with us.





no image
Place where all sort of programming stuff and reviews,technology news are shared and Useful Project of C++,C,java C# etc
In C#, types are divided into two categories:
  • value types 
  • Reference types. 
Value types directly contain their data, and reference types store references to their data. The third category of types called pointers is available only in unsafe code. This pointer type will not be discussed in this document.

VALUE TYPES

In C#, a value type can be either a Struct or an enumeration. C# contains a set of predefined Struct types called the simple types. These simple types are identified through reserved words. All value types implicitly inherit from a class called object. Also, no type can derive from a value type. It is not possible for a value type to be null (null means “nothing” or “no value”). Assigning a variable of a value type creates a copy of the value. This is different from assigning a variable of a reference type, which copies the reference and not the object identified by the reference.

Example

Int,char,byte,bool,decimal ,double, enum , long ,sbyte,short ,struct,uint ,ulong ,ushort

REFERENCE TYPES

A reference type is one of the following: a class, an interface, an array, or a delegate. A reference type value is a reference to an instance of the type. null is compatible with all reference types and indicates the absence of an instance.

Class Types

A class defines a data structure containing data members (constants and fields), function members (methods, properties, events, indexers, operators, instance constructors, destructors and static constructors), and nested types.

The Object Type

The object class type is the ultimate base class of all other types. Every type in C# directly or indirectly derives from the object class type.

The String Type

The string type inherits directly from the class object.

Interface Types

An interface defines a contract. A class implementing an interface must adhere to its contract.

Array Types

An array is a data structure containing a number of variables that are accessed through indices. The variables contained in an array are called the elements of the array. They are all of the same types, and this type is called the element type of the array
Place where all sort of programming stuff and reviews,technology news are shared and Useful Project of C++,C,java C# etc
In C#, a variable represents a storage location. A variable has a type that determines what values can be stored in this variable. Because C# is a type-safe language, the C# compiler guarantees that values stored in variables are always of the appropriate type.

 The value of a variable is changed through the assignment operator and through the use of the ++ and -- operators. A variable must be definitely assigned before its value can be obtained: variables are either initially assigned or initially unassigned. An initially assigned variable has a well-defined initial value, while an initially unassigned variable has no initial value.
Variables In C#

CATEGORIES OF VARIABLES IN C#

C# has seven categories of variables: static variables, instance variables, array elements, value parameters, reference parameters, output parameters, and local variables. The following sections describe each of these categories.

Static Variables

A variable, declared with the static keyword, is a static variable. The initial value of a static variable is the default value of the variable’s type. A static variable is initially assigned.

Instance Variables

A variable declared without the static keyword is an instance variable. An instance variable of a class exists when a new instance of that class is created and ceases to exist when there are no references to that instance and the instance’s destructor (if any) has executed. The initial value of an instance variable of a class is the default value of the variable’s type. An instance variable of a class is initially assigned.

Array Elements

Array elements exist when an array instance is created and cease to exist when there are no references to that array instance. The initial value of each of the elements of an array is the default value of the type of the array elements. An array element is initially assigned.

Local Variables

A local variable is declared within a block, a for-statement, a switch-statement, or a using-statement. The lifetime of a local variable is implementation-dependent. For example, the compiler could generate code that results in the variable’s storage having a shorter lifetime than its containing block. A local variable is not automatically initialized and it has no default value. A local variable is initially unassigned. It is a compile-time error to refer to the local variable in a position that precedes its declaration.

Value Parameters

A parameter declared without a ref or out modifier is a value parameter. A value parameter is initially assigned.

Reference Parameters

A parameter declared with a ref modifier is a reference parameter. A reference parameter represents the same storage location as the variable given as the argument in the function member invocation. Therefore, the value of a reference parameter is always the same as the underlying variable. A variable has to be definitely assigned before it can be passed as a reference parameter in a function member invocation. A reference parameter is considered initially assigned to a function member.

Output Parameters

An output parameter is a parameter declared with an out modifier. An output parameter represents the same storage location as the variable given as the argument in the function member invocation. Therefore, the value of an output parameter is always the same as the underlying variable. A variable does not need to be definitely assigned before it can be passed as an output parameter in a function member invocation. An output parameter is initially unassigned within a function member.

no image
Place where all sort of programming stuff and reviews,technology news are shared and Useful Project of C++,C,java C# etc
In this Article am describing how to integrate SMS API in C#  that can send SMS to your mobile phone within Pakistan.
 First go to this website and signup here

Here are the simple Steps that you follow  :

  1. First Launch a visual studio 
  2. Create a console Application in visual studio 
  3. After that first added assembly reference into your project

using System.Net;
using System.Web;
Here is Implementation

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string MyUsername = "xxxx"; //Your Username At Sendpk.com 
            string MyPassword = "xxxx"; //Your Password At Sendpk.com 
            string toNumber = "xxxxx"; //Recepient cell phone number with country code 
            string Masking = "Tech Spider"; //Your Company Brand Name 
            string MessageText = "Application Done";
            string jsonResponse = SendSMS(Masking, toNumber, MessageText, MyUsername, MyPassword);
            Console.Write(jsonResponse);
            //Console.Read(); //to keep console window open if trying in visual studio 
            Console.ReadLine();
        }
        public static string SendSMS(string Masking, string toNumber, string MessageText, string MyUsername, string MyPassword)
        {
            String URI = "http://Sendpk.com" +
            "/api/sms.php?" +
            "username=" + MyUsername +
            "&password=" + MyPassword +
            "&sender=" + Masking +
            "&mobile=" + toNumber +
            "&message=" + Uri.UnescapeDataString(MessageText); // Visual Studio 10-15 
          
            try
            {
                WebRequest req = WebRequest.Create(URI);
                WebResponse resp = req.GetResponse();
                var sr = new System.IO.StreamReader(resp.GetResponseStream());
                return sr.ReadToEnd().Trim();
            }
            catch (WebException ex)
            {
                var httpWebResponse = ex.Response as HttpWebResponse;
                if (httpWebResponse != null)
                {
                    switch (httpWebResponse.StatusCode)
                    {
                        case HttpStatusCode.NotFound:
                            return "404:URL not found :" + URI;
                            break;
                        case HttpStatusCode.BadRequest:
                            return "400:Bad Request";
                            break;
                        default:
                            return httpWebResponse.StatusCode.ToString();
                    }
                }
            }
            return null;
            
        }
    
    }
   
    }
no image
Place where all sort of programming stuff and reviews,technology news are shared and Useful Project of C++,C,java C# etc
You can redefine or overload most of the built-in operators available in C#. Thus a programmer can use operators with user-defined types as well. Overloaded operators are functions with special names the keyword operator followed by the symbol for the operator being defined. similar to any other function, an overloaded operator has a return type and a parameter list.

For example:

using System;
public class Program
{
 int x, y, z;
 public Program()
 {
 x = y = z = 0;
 }
 public Program(int i, int j, int k)
 {
 x = i;
 y = j;
 z = k;
 }
 public static Program operator +(Program a, Program b)
 {
 Program c = new Program();
 c.x = a.x + b.x;
 c.y = a.y + b.y;
 c.z = a.y + b.y;
 return c;
 }
 public static Program operator -(Program a, Program b)
 {
 Program c = new Program();
 c.x = a.x - b.x;
 c.y = a.y - b.y;
 c.z = a.y - b.y;
 return c;
 }
 public void show()
 {
 Console.WriteLine(x + " , " + y + " , " + z);
 }
}
class second
 {
 static void Main(string[] args)
 {
 Program n1 = new Program(1,2,3);
 Program n2 = new Program(10,10,10);
 Program n3 = new Program();
 Console.WriteLine("here is n1");
 n1.show();
 Console.WriteLine("here is n2");
 n2.show();
 n3 = n1 + n2;
 Console.WriteLine("Result of n1 + n2");
 
 n3.show();
 n3 = n1 + n2+n3;
 Console.WriteLine("Result of n1 + n2 + n3");
 n3.show();

 n3 = n3 - n1;
 Console.WriteLine("Result of n3 - n1");
 n3.show();
 n3 = n3 - n2;
 Console.WriteLine("Result of n3 - n2");
 n3.show();

 }
 }
Place where all sort of programming stuff and reviews,technology news are shared and Useful Project of C++,C,java C# etc
Q No. 1 Write a program that takes a quadratic equation as input and return whether it has two distinct roots, a double root, or not roots Using if else Condition.

Solution:
1

Q No.2  write a program that reads a number, check if this number is divisible by 4 then display “OK”, otherwise display “ failure “.


Solution.

Q No.3 Write a program to display alphabet pattern like 'U' with an asterisk.
Solution:


Q No.4 Create a program to ask the user for a symbol and answer if it is a (lowercase) vowel, a digit, or any other symbol, using "switch".

Solution:

 
Q No.5 write an application that keeps track of our grocery list. It should save our grocery needs into an array, and then print the grocery list out for us when we run the application
 "eggs", "milk", "bread", "bananas", "cereal", "rice", "yogurt"

Solution:


no image
Place where all sort of programming stuff and reviews,technology news are shared and Useful Project of C++,C,java C# etc
Make a program that associates all 26 English alphabets A-Z with the index 1-26. User will enter a number from 1 to 26 and it will show the associated alphabet.

Solution:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace alpha
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Number");
            while (true)
            {

                int number = Convert.ToInt32(Console.ReadLine());
                char[] alpha = { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };

                if (number > 0 && number <= 26)
                {
                    for (int i = 1; i <= alpha.Length; i++)
                    {
                        if (i == number)
                        {
                            Console.WriteLine(alpha[i].ToString());
                        }
                    }

                }
                else
                {
                    Console.WriteLine("Invalid input");
                }

            }
            Console.ReadLine();
        }
    }
}


no image
Place where all sort of programming stuff and reviews,technology news are shared and Useful Project of C++,C,java C# etc
Create a new C# project and create a program that assigns values to the specific variables after checking that whether the input is integer, float, signed or unsigned.

Solution:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace alphabet
{
    class Program
    {
        static void Main(string[] args)
        {

            string a;
            Console.WriteLine("Enter the a");
            int result1;
            float result2;

            a = Console.ReadLine();

            if (int.TryParse(a, out result1) == true)
            {
                Console.WriteLine("Moved to int");

            }
            else if (float.TryParse(a, out result2) == true)
            {
                Console.WriteLine("Moved to float");
            }

            Console.ReadLine();
        }

    }

}

no image
Place where all sort of programming stuff and reviews,technology news are shared and Useful Project of C++,C,java C# etc
Write a program for a calculator that will be able to perform addition, subtraction, multiplication and division. Make a main menu. It should take float values from user as inputs and display outputs as a string after performing selected operation.

Solution:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace calculator
{
    class Program
    {
        static void Main(string[] args)
        {
            float a, b,c, result;
            Console.WriteLine("Add Sub Mult Div\n ");
            Console.WriteLine("Enter the a");
                a = float.Parse(Console.ReadLine());
            Console.WriteLine("Enter the b");
            b = float.Parse(Console.ReadLine());
            Console.WriteLine("1 for Add\n 2 for Sub\n 3 f0r Mult\n 4 for Div\n ");
            Console.WriteLine("Enter the c");
            c = float.Parse(Console.ReadLine());
           
            if (c==1)
            {
                result= a + b;
                Console.WriteLine(result);
            }
            if (c==2)
            {
                result = a - b;
                Console.WriteLine(result);
            }
            if (c==3)
            {
                result = a * b;
                Console.WriteLine(result);
            }
            if (c==4)
            {
                result = a / b;
                Console.WriteLine(result);

            }
            Console.ReadLine();

           

        }
    }
}



Place where all sort of programming stuff and reviews,technology news are shared and Useful Project of C++,C,java C# etc

Introduction™

Windows application to Capture Screen as Picture(Screen Shots) or as Video along with or without Mouse Cursor, Audio from Microphone , Mouse Clicks


Screen Capturing Application using C#


Business Requirements

Application allow user to make video , Audio , Screenshot and want to see the work done by him he can easily see by clicking the related option. A user can even set the color of app according to the environment. Give option to the user to just make the video of the folder to i-e desktop or the Folder

Functional Requirements


  • Video
  • Audio 
  • Screenshot

Non-Functional Requirements

These are the following non-functional requirement 
  • Capture system will be Desktop Based application. 
  • Physical environment 
  • Application shall be implemented on C# 
  • Operating System: Windows 
  • User Interface and human factor System shall use graphical user interface (GUI) applications to interact with other system.

Key Feature

  • Take Screen Shots. 
  • Capture everything that is performing on screen. 
  • Make Videos 
  • Captures the Selective Area 
  • Customize ColorvTake Screen Shots. 
  • Capture everything that is performing on screen. 
  • Make Videos 
  • Captures the Selective Area 
  • Customize Color


Uses Cases Diagram 


Uses Cases Diagram


Note :Complete Source Code Download from Here
Download
Place where all sort of programming stuff and reviews,technology news are shared and Useful Project of C++,C,java C# etc

In this articles, I am using Listbox ,radio box ,check box,and textbox  Admission Form

Admission Form with List Box using C#

Program

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Admission_Form_with_List_Box
{
     public partial class frmAdmission : Form
     {
          public frmAdmission()
          {
               InitializeComponent();
          }

          private void btnDisplay_Click(object sender, EventArgs e)
          {
               double mobt = 0, mtot = 0,
                         iobt = 0, itot = 0,
                         bobt = 0, btot = 0,
                         merit = 0;
               int hafiz = 0, computer = 0;
               if (chkHafiz.Checked)
               {
                    hafiz = 20;
               }
               if (chkComputer.Checked)
               {
                    computer = 10;
               }
               if (lstProgram.SelectedIndex != -1)
               {
                    if (lstProgram.SelectedItem.ToString() == "BS( CS )")
                    {
                         iobt = Convert.ToDouble(txtIObt.Text);
                         itot = Convert.ToDouble(txtITot.Text);
                         merit = (iobt + hafiz) / itot * 100;
                         txtMerit.Text = merit.ToString();
                         if (merit > 80)
                         {
                              txtRemarks.Text = "Congratulations...!";
                         }
                         else
                         {
                              txtRemarks.Text = "Wait for other merit list";
                         }
                    }
                    else if (lstProgram.SelectedItem.ToString() == "MCS")
                    {
                         mobt = Convert.ToDouble(txtMObt.Text);
                         mtot = Convert.ToDouble(txtMTot.Text);
                         merit += mobt / mtot * 30;
                         iobt = Convert.ToDouble(txtIObt.Text);
                         itot = Convert.ToDouble(txtITot.Text);
                         merit += iobt / itot * 30;
                         bobt = Convert.ToDouble(txtBObt.Text);
                         btot = Convert.ToDouble(txtBTot.Text);
                         merit += (bobt + hafiz + computer) / btot * 40;
                         txtMerit.Text = merit.ToString();
                         if (merit > 71)
                         {
                              txtRemarks.Text = "Congratulations...!";
                         }
                         else
                         {
                              txtRemarks.Text = "Wait for other merit list";
                         }
                    }
               }
          }

          private void lstProgram_SelectedIndexChanged(object sender, EventArgs e)
          {
               if (lstProgram.SelectedIndex != -1)
               {
                    if (lstProgram.SelectedItem.ToString() == "BS( CS )")
                    {
                         txtAppNo.Enabled = true;
                         txtName.Enabled = true;
                         txtMObt.Enabled = false;
                         txtMTot.Enabled = false;
                         txtIObt.Enabled = true;
                         txtITot.Enabled = true;
                         txtBObt.Enabled = false;
                         txtBTot.Enabled = false;
                    }
                    else if (lstProgram.SelectedItem.ToString() == "MCS")
                    {
                         txtAppNo.Enabled = true;
                         txtName.Enabled = true;
                         txtMObt.Enabled = true;
                         txtMTot.Enabled = true;
                         txtIObt.Enabled = true;
                         txtITot.Enabled = true;
                         txtBObt.Enabled = true;
                         txtBTot.Enabled = true;
                    }
               }
          }

          private void frmAdmission_Load(object sender, EventArgs e)
          {
               txtAppNo.Enabled = false;
               txtName.Enabled = false;
               txtMObt.Enabled = false;
               txtMTot.Enabled = false;
               txtIObt.Enabled = false;
               txtITot.Enabled = false;
               txtBObt.Enabled = false;
               txtBTot.Enabled = false;
          }

          private void btnClear_Click(object sender, EventArgs e)
          {
               lstProgram.ClearSelected();
               txtAppNo.Clear();
               txtName.Clear();
               txtAppNo.Enabled = false;
               txtName.Enabled = false;
               rdoMale.Checked = false;
               rdoFemale.Checked = false;
               chkComputer.Checked = false;
               chkHafiz.Checked = false;
               txtMObt.Enabled = false;
               txtMTot.Enabled = false;
               txtIObt.Enabled = false;
               txtITot.Enabled = false;
               txtBObt.Enabled = false;
               txtBTot.Enabled = false;
               txtMerit.Enabled = false;
               txtRemarks.Enabled = false;
               txtMObt.Clear();
               txtMTot.Clear();
               txtIObt.Clear();
               txtITot.Clear();
               txtBObt.Clear();
               txtBTot.Clear();
               txtMerit.Clear();
               txtRemarks.Clear();
          }

          private void btnExit_Click(object sender, EventArgs e)
          {
               this.Close();
          }
    }
}