Property is Smart Method.
below given property example.
below given property example.
ASP.NET CSharpe ADO.NET and Sql Server and Javascript and jquery Example that is help to programmer
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Exception handling { class Program { static void Main(string[] args) { int i; int j; int k; Console.WriteLine("Enter 1st No: "); i = int.Parse(Console.ReadLine()); Console.WriteLine("Enter 2nd No: "); j = int.Parse(Console.ReadLine()); try { if (j == 0) { throw new DivideByZeroException(); } k = i / j; Console.WriteLine("Ans is " + k); } catch (DivideByZeroException) { Console.WriteLine("Divide By Zero Not Possible.."); } finally { Console.ReadLine(); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Ass_45 { class Program { static void Main(string[] args) { int[] name = new int[3]; Console.WriteLine("Enter Array Value:"); try { for (int i = 0; i <= 3; i++) { name[i] = Convert.ToInt32(Console.ReadLine()); } for (int i = 0; i <= 3; i++) { Console.WriteLine("Array" + name[i]); } } catch (IndexOutOfRangeException) { Console.WriteLine("Array Out of Index Ha Ha Ha"); } finally { Console.ReadLine(); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Generics { public class Test{ public T EmpID { set; get; } public void show(T t,N n) { if (typeof(T) == typeof(int) && typeof(N) == typeof(int)) { int x = Convert.ToInt32(t); int y = Convert.ToInt32(n); Console.WriteLine(x + y); } else if (typeof(T) == typeof(string) && typeof(N) == typeof(int)) { Console.WriteLine("The " + t + "'s Age is " + n); } } } class Program { static void Main(string[] args) { Test ob = new Test (); ob.EmpID = 10; ob.show(10, 20); Test ob1 = new Test (); ob1.show("Rajesh",20); } } }
Insert Store ProcedureALTER PROCEDURE dbo.sp_InserttblEmp @Name varchar(50), @depid int, @Salary int, @status int output AS insert into tblemp VALUES(@Name,@depid,@Salary); select @status=@@ERROR RETURN @status
public Boolean insert_tblemp(LogicLayer objLogicLayer) { int status; string Sp = "sp_InserttblEmp"; objCmd = new SqlCommand(Sp,objCn); objCmd.CommandType = CommandType.StoredProcedure; objCmd.Parameters.Add("@Name",objLogicLayer.Name); objCmd.Parameters.Add("@depid", objLogicLayer.Sid); objCmd.Parameters.Add("@Salary", objLogicLayer.Salary); objCmd.Parameters.Add("@status", SqlDbType.Int).Value=1; objCmd.Parameters["@status"].Direction = ParameterDirection.InputOutput; objCn.Open(); objCmd.ExecuteNonQuery(); status = (int)objCmd.Parameters["@status"].Value; objCn.Close(); if (status == 0) { return true; } else { return false; } }
public class public class LogicLayer { { DataLayer objLogicLayer=new LogicLayer (); public int Sid { set; get; } public string Name { set; get; } public int Salary { set; get; } public Boolean insert_tblemp(DataLayer objDataLayer) { return objLogicLayer.insert_tblemp(objDataLayer); } }
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="insert.aspx.cs" Inherits="insert" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> </head> <body> <form id="form1" runat="server"> <div> <table> <tr> <td> Name </td> <td> <asp:TextBox ID="txtName" runat="server"></asp:TextBox> </td> </tr> <tr> <td> depid </td> <td> <asp:TextBox ID="txtdepid" runat="server"></asp:TextBox> </td> </tr> <tr> <td> Salary </td> <td> <asp:TextBox ID="txtSalary" runat="server"></asp:TextBox> </td> </tr> <tr> <td> <asp:Label ID="lblMsg" runat="server" ForeColor="Red" Text="Label"></asp:Label> </td> <td> <asp:Button ID="btnSave" runat="server" Text="Save" onclick="btnSave_Click" /> </td> </tr> </table> </div> </form> </body> </html>
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class insert : System.Web.UI.Page { LogicLayer objLogicLayer = new LogicLayer(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { } } protected void btnSave_Click(object sender, EventArgs e) { bool status; objLogicLayer.Sid = Convert.ToInt32(txtdepid.Text); objLogicLayer.Name = txtName.Text; objLogicLayer.Salary = Convert.ToInt32(txtSalary.Text); status = objLogicLayer.insert_tblemp(objLogicLayer); if (status == true) { lblMsg.Text = "Save Successfully"; } else { lblMsg.Text = "Error"; } } }
<asp:textbox id="txtdate" runat="server"></asp:textbox> <asp:regularexpressionvalidator controltovalidate="txtdate" errormessage="RegularExpressionValidator"
id="RegularExpressionValidator1" runat="server"
validationexpression=
"(0[1-9]|[1 2][0-9]|3[0 1]|)[-/.](0[1-9]|1[0 1 2])[-/.](19/20)\d\d ">
</asp:regularexpressionvalidator>
EmpID | Name | Salary | DepID |
---|---|---|---|
1 | Sachin | 1000 | 1 |
2 | Mahora | 2000 | 2 |
3 | Afridi | 3000 | 1 |
DepID | DepName |
---|---|
1 | D1 |
2 | D2 |