Saturday, June 20, 2015

Forloop and Foreachloop in C#.net

It depends on what you are doing, and what you need. If you are iterating through a collection of items, and do not care about the index values then foreach is more convenient, easier to write and safer: you can't get the number of items wrong. If you need to process every second item in a collection for example, or process them ion the reverse order, then a for loop is the only practical way.

The biggest differences are that a foreach loop processes an instance of each element in a collection in turn, while a for loop can work with any data and is not restricted to collection elements alone. This means that a for loop can modify a collection - which is illegal and will cause an error in a foreach loop.



The for loop executes a statement or a

block of statements repeatedly until a specified expression evaluates to

false.  there is need to specify the loop bounds( minimum or maximum).


int j = 0;


for (int i = 1; i <= 5; i++)
{
j

= j + i ;
}


The foreach statement repeats a group of

embedded statements for each element in an array or an object

collection.you do not need to specify the loop bounds minimum or

maximum.
int j = 0;


int[] tempArr = new int[] { 0, 1, 2, 3, 5, 8,

13 };
foreach (int i in tempArr )
{
j = j + i ;
}


ATTENDANCE MANAGEMENT SYSTEM PROJECT WITH SOURCE CODE

PROJECT SOURCE CODE

You can download source code of this project from given download links

 Attendance Tracker System, Source Code in : PHP , MYSQL , Category: Management System Major project, Cost : Free Download, Code: Open source.
"Attendance Management System Project in PHP with Report" (Source Code / Report / PPT) Totally belong to CodingTalks Team and We always ready to Share our Stuff
Attendance Management System is a complete system for any organization to take attendance of its staff. It is written in PHP and released as an open source project
Online attendance management system for employees project is a web application which is implemented in Php platform. They are modification this project as per
Attendance Management System 1 Project Report On “Attendance Management System”  Attendance Management System 30 8.2. Attendance Status Form




The purpose of Online Attendance Management System Project in Java is to provide attendance for students in both online and offline and finally we can also generate
Student Attendance Management System Project Topics or Ideas for Computer Science Engineering . Projecttopics.info. Home. Computer. Electronics. IT. Java.
Attendance management system project is developed in Vb.Net programming language using sql server database. Download code, Project Report, PPT ,
Introduction. Attendance Management System is software developed for daily student attendance inschools, colleges and institutes. If facilitates to access the attendance
Attendance Management System is an easy way to keep track of attendance for school activities, church groups, and community organizations. About Us; Projects
 Track employee time and attendance, employee time clock software, employee scheduling software and payroll software all in a single package. You can also
Attendance Management Solution Gaytes Attendance Management solution would be one which is able to automate the tabulations of staff time clocking, calculate
Student Attendance Management System, HBTI, Kanpur, 30.07.2007 Teacher Teacher will access the Student Attendance Management System through their user name
Positive approach to absenteeism which applies principles of behavior modification to achieve improved attendance at work. Although it relies on both reward and
Attendance Management System is a complete system for any organization to take attendance of its staff. It is written in PHP and released as an open source project

DownLoad Link:
DropBoxSoftwarehub

Send email in asp.net

 <%this is the client side code for the design and display%>
<asp:Panel ID="Panel1" runat="server" DefaultButton="btnSubmit">
<p>
Please Fill the Following to Send Mail.</p>
<p>
Your name:
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ErrorMessage="*"
ControlToValidate="YourName" ValidationGroup="save" /><br />
<asp:TextBox ID="YourName" runat="server" Width="250px" /><br />
Your email address:
 
 <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
ControlToValidate="YourEmail" ValidationGroup="save" /><br />
<asp:TextBox ID="YourEmail" runat="server" Width="250px" />
<asp:RegularExpressionValidator runat="server" ID="RegularExpressionValidator23"
SetFocusOnError="true" Text="Example: username@gmail.com" ControlToValidate="YourEmail"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="Dynamic"
ValidationGroup="save" /><br />
Subject:
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
ControlToValidate="YourSubject" ValidationGroup="save" /><br />
<asp:TextBox ID="YourSubject" runat="server" Width="400px" /><br />
Your Question:
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="*"
ControlToValidate="Comments" ValidationGroup="save" /><br />
<asp:TextBox ID="Comments" runat="server"
TextMode="MultiLine" Rows="10" Width="400px" />
</p>
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Send"
OnClick="Button1_Click" ValidationGroup="save" />
</p>
</asp:Panel>
<p>
<asp:Label ID="DisplayMessage" runat="server" Visible="false" />
</p>
 
 
protected void SendMail()
{
// Gmail Address from where you send the mail
var fromAddress = "Gmail@gmail.com";
// any address where the email will be sending
var toAddress = YourEmail.Text.ToString();
//Password of your gmail address
const string fromPassword = "Password";
// Passing the values and make a email formate to display
string subject = YourSubject.Text.ToString();
string body = "From: " + YourName.Text + "\n";
body += "Email: " + YourEmail.Text + "\n";
body += "Subject: " + YourSubject.Text + "\n";
body += "Question: \n" + Comments.Text + "\n";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;
}
// Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body);
}

protected void Button1_Click(object sender, EventArgs e)
{
try
{
//here on button click what will done
SendMail();
DisplayMessage.Text = "Your Comments after sending the mail";
DisplayMessage.Visible = true;
YourSubject.Text = "";
YourEmail.Text = "";
YourName.Text = "";
Comments.Text = "";
}
catch (Exception) { }
}

Patient and Friends


AJAX Control Toolkit Control Extender (C#)

The CSASPNETAjaxExtender sample demonstrates how to create an ASP.Net Ajax ExtenderControl, which is a TimePicker to allow the user dragging the minute/hour pointer to select a time of a day on a clock.
Microsoft ASP.Net Ajax Extensions enables you to expand the capabilities of an ASP.Net Web Application in order to create a rich client user experience.
To encapsulate the client behavior for use by ASP.NET page developers, you can use an extender control.  An extender control is a Web server control that inherits the ExtenderControl abstract class in the System.Web.UI namespace.

1.       Creating an Extender Control.
 We can create ExtenderControl by using the template "Asp.Net Ajax Server Control Extender".
 It will present to you a class file, a resource file(Actually, we don't need it in this sample.) and a JS file as default. We can create the extender in class file and create behavior in JS file.
  
2.       Extender control is used for client script functionality extension of an existing web control. It can be applied to specific Web server control types.
 You identify the types of Web server controls to which an extender control  can be applied by using the TargetControlTypeAttribute attribute.

   [TargetControlType(typeof(TextBox))]
   public class TimePicker: ExtenderControl


3.       The following two methods of the ExtenderControl abstract class that you must implement in an extender control.

   protected override IEnumerable<ScriptDescriptor>  GetScriptDescriptors(Control targetControl)
   {
      ScriptControlDescriptor descriptor = new ScriptControlDescriptor ("CSASPNETAjaxExtender.TimePicker", targetControl.ClientID);
      descriptor.AddElementProperty("errorSpan", this.NamingContainer.FindControl
(ErrorPresentControlID).ClientID);
                   
      descriptor.AddProperty("timeType", TimeType);
      descriptor.AddEvent("showing", OnClientShowing);
      yield return descriptor;
   }


   protected override IEnumerable<ScriptReference> GetScriptReferences()
   {
      yield return new ScriptReference(Page.ClientScript.GetWebResourceUrl
(this.GetType(), "CSASPNETAjaxExtender.TimePicker.TimePicker.js"));
   }

4.       Embed Css reference in PreRender phase if you have a css style file to decorate the extender control.
   private void RenderCssReference()
   {
      string cssUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "CSASPNETAjaxExtender.TimePicker.TimePicker.css");

      HtmlLink link = new HtmlLink();
      link.Href = cssUrl;
      link.Attributes.Add("type", "text/css");
      link.Attributes.Add("rel", "stylesheet");
      Page.Header.Controls.Add(link);
   }
  
5.       Set all resources(contain images, css file and js file) embedded in this extender control as "Embedded Resource"(property "Build Action").

6.       The control can derive from other server controls if you want to make it inherit a server control than ExtenderControl. In this scenario, it should derive from
   IExtenderControl interface and a server control class. Meanwhile, we have another
   three steps need to do:
   1) Define TargetControl property
   2) Override OnPreRender method. Register the web control as the ExtenerControl in OnPreRender phase.
  
            ScriptManager manager = ScriptManager.GetCurrent(this.Page);
            if (manager == null)
            {
                throw new InvalidOperationException("A ScriptManager is required on the page.");
            }
            manager.RegisterExtenderControl<TimePicker>(this);
   3) Override Render method. Register the script descriptor which has been defined.
  
            ScriptManager.GetCurrent(this.Page).RegisterScriptDescriptors(this);

7.       The rest work is on client-side. Register client NameSpace first.
 Type.registerNamespace("CSASPNETAjaxExtender");

8.       Build client class.
   CSASPNETAjaxExtender.TimePicker = function(element) {
   
   }

   CSASPNETAjaxExtender.TimePicker.prototype = {

   }

9.       Register the class that inherits "Sys.UI.Behavior".
  
 CSASPNETAjaxExtender.TimePicker.registerClass('CSASPNETAjaxExtender.TimePicker', Sys.UI.Behavior);

10.   Call base method in constructor method
CSASPNETAjaxExtender.TimePicker.initializeBase(this, [element]);

11.   Implementing the Initialize and Dispose Methods.
   Build "initialize" and "dispose" method in prototype of the class. The initialize method is called when an instance of the behavior is created. Use this method to set default property values, to create function delegates, and to add delegates as event handlers. The dispose method is called when an instance of the behavior is no longer used on the page and is removed. Use this method to free any resources that are no longer required for the behavior, such as DOM event handlers.
   initialize: function() {
       CSASPNETAjaxExtender.TimePicker.callBaseMethod(this, 'initialize');      

   },

   dispose: function() {       
       CSASPNETAjaxExtender.TimePicker.callBaseMethod(this, 'dispose');
   }

12.   Defining the Property Get and Set Methods.
Each property identified in the ScriptDescriptor object of the extender control's GetScriptDescriptors(Control) method must have corresponding client assessors.  The client property assessors are defined as get_<property name> and set_<property name> methods of the client class prototype.

   get_timeType: function() {
       return this._timeType;
   },

   set_timeType: function(val) {
       if (this._timeType !== val) {
           this._timeType = val;
           this.raisePropertyChanged('timeType');
       }
   },

13.   Defining the Event Handlers for the DOM Element
   1) Defining the handler in constructor function:
        this._element_focusHandler = null;
   2) Associate the handler with the DOM Element event in initailize method:
           this._element_focusHandler = Function.createDelegate(this, this._element_onfocus);
   3) Add the handler in initailize method:
           $addHandler(this.get_element(), 'focus', this._element_focusHandler)
   4) Build callback method about this event:
           _element_onfocus:function(){

           }

14.   Defining the Event Handlers for the behavior
             Each event identified in the ScriptDescriptor object of the extender control's GetScriptDescriptors(Control) method must have corresponding client accessors. The client event accessors are defined as add_<event name> and remove_<event name> methods of the client class prototype.
   The method Raise<event name> is defined to trigger the event. 

    add_showing: function(handler) {
        this.get_events().addHandler("showing", handler);
    },
    remove_showing: function(handler) {

        this.get_events().removeHandler("showing", handler);
    },
    raiseShowing: function(eventArgs) {

        var handler = this.get_events().getHandler('showing');
        if (handler) {
            handler(this, eventArgs);
        }
    },
   
15.   Use this extender control TimePicker in page.
    The usage of the extender control is the same to the custom control.   
         1) Register the assembly in page.
            <%@ Register TagPrefix="CSASPNETAjaxExtender" Assembly="CSASPNETAjaxExtender"
            Namespace="CSASPNETAjaxExtender" %>
         2) Add a ScriptManager control in page, and create TimePicker control to bind on a TextBox.
        
            <asp:TextBox ID="TextBox1" Text="" runat="server"></asp:TextBox>
            <CSASPNETAjaxExtender:TimePicker runat="server" ID="t1" TargetControlID="TextBox1" TimeType="H24" />
3) Then we have built this TimePicker on the page as below. You can drag the minute or hour pointer to locate the time.

Friday, June 19, 2015

USB Bootable

How we make bootable USB

 Bootable Windows 7 USB flash drive :
 For those who don’t have a windows 7 installation disk or either it is damaged, then you can create and use a Bootable USB flash drive to install Windows 7 on your PC. The process of creating a Bootable windows 7 USB flash drive is fairly easy, however you will have to download a copy of windows 7 ISO file.

Instructions to create a Bootable Windows 7 USB Flash Drive 

  • Step 1: Download rufus on your computer and run it .
  • Step 2: Plug in your USB flash drive into your computer .
  • Step 3: From Rufu’s settings, Choose NTFS as the file system.
  • Step 4: Check ” Quick format ” and ” Create extended label and icon files “
  • Step 5: Check ” Create a bootable disk using ” and click the drive icon beside it to select the windows 7 ISO file .
  • Step 6: Now click on start to create a bootable window 7 USB flash drive .

After a few minutes your Windows 7 bootable  USB flash drive will be  ready for installation. Reboot your PC and set the bootable flash drive as a first boot priority in the bios settings. Save the bios settings and reboot once again to continue with the windows 7 installation process .
 Note: You have to allow booting from USB devices in your BIOS settings in order to proceed further with the windows 7 installation .


Bootstrap Responsive GridView for Mobile Phone, Tablet in ASP.Net.

How we make Responsive grid view in asp.net using bootstrap.

<asp:GridView ID="GridViewCustomer " CssClass="footable" runat="server" AutoGenerateColumns="false"
    Style="max-width: 500px">
    <Columns>
        <asp:BoundField DataField="Id" HeaderText="Customer Id" />
        <asp:BoundField DataField="name" HeaderText="Customer name" />
        <asp:BoundField DataField="address" HeaderText="Country" />
    </Columns>
</asp:GridView>

Binding the GridView 
The GridViewCustomer is populated using some dummy records using DataTable, you can populate it from database too.
After the GridView is populated with data you will need add the following attributes to each Header Column of GridView depending on its significance in different displays.
1. data-class = “expand” – You need to specify this attribute to the first column so that it shows the expand collapse button which will be used to show or hide the hidden column fields in Mobile Phone or Tablet.
2. data-hide = “phone” – You need to specify this attribute for all the columns that you want to hide in smaller displays like Mobile Phone or Tablet. The below table displays the possible values.
protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        DataTable dt = new DataTable();
        dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id"), new         DataColumn("Name"), new DataColumn("Country") });
        dt.Rows.Add(1, "John Hammond", "United States");
        dt.Rows.Add(2, "Mudassar Khan", "India");
        dt.Rows.Add(3, "Suzanne Mathews", "France");
        dt.Rows.Add(4, "Robert Schidner", "Russia");
        GridView1.DataSource = dt;
        GridView1.DataBind();
        //Attribute to show the Plus Minus Button.
        GridView1.HeaderRow.Cells[0].Attributes["data-class"] = "expand";
        //Attribute to hide column in Phone.
        GridView1.HeaderRow.Cells[2].Attributes["data-hide"] = "phone";
        GridView1.HeaderRow.Cells[3].Attributes["data-hide"] = "phone";
        //Adds THEAD and TBODY to GridView.
        GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
    }
}

<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/0.1.0/css/footable.min.css"
    rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/0.1.0/js/footable.min.js"></script>
<script type="text/javascript">
    $(function () {
        $('[id*=GridViewCustomer ]').footable();
    });
</script>