Wednesday, 20 September 2017

Database Application # 3 (Store Procedure of Data Insertion )

Store Procedure of Data Insertion in student Table



Create proc [dbo].[insert_student]
(
@std_name nvarchar(20),
@std_fname nvarchar(20),
@std_gender nvarchar(6),
@std_address nvarchar(100),
@std_admissiondate nvarchar(20),
@std_ad_fk_id int

)
as

begin

insert into student(std_name,std_fname,std_gender,std_address,std_admissiondate,std_ad_fk_id)
values(@std_name,@std_fname,@std_gender,@std_address,@std_admissiondate,@std_ad_fk_id)

end

Anchor Tag /Hyper Link in HTML-5

Anchor Tag /Hyper Link


Guide:
1-Make a folder on desktop named as "Anchor Tag"
2-In "Anchor Tag" folder make 4 folders named as  img, js, pages and css
3-Open your code Editor , copy the below html and paste it , and save the file named as index.html in "Anchor Tag" folder
4-Now Create another html page , name it as "aboutus.html" & save it in pages folder.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Anchor tag</title>
</head>

<body>

<h1> Index Page</h1>


<UL>

<LI>
<a target="_blank"  href="pages/ABOUTUS.html"> About Us page ( using blank  attribute )</a>
</Li>

<LI>
<a target="_self"  href="pages/ABOUTUS.html"> About Us page ( using self  attribute )</a>
</Li>


<LI>
<a target="_top"  href="pages/ABOUTUS.html"> About Us page ( using top  attribute )</a>
</Li>





</UL>




</body>
</html>

WEB PAGE LAYOUT USING HTML & CSS (css-code)




Css Code:

@charset "utf-8";
/* CSS Document */
body
{ margin:0 auto;
  padding:0px;
  background-color:#9CF;
}
#wrapper
{
margin:0 auto;
width:80%;
height:1000px;
background-color:#906;

}
header
{
width:100%;
height:200px;
background-color:#0F0;

}
nav
{
width:100%;
height:50px;
background-color:#FC9;

}
nav ul
{ margin:0;
list-style-type:none;
}
nav ul li
{
float:left;
margin-top:10px;


}
nav ul li a
{ text-decoration:none;
font-size:26px;
padding:10px;
color:#FFF;
}
a:hover
{
color:#00C;
background-color:#FFF;

}
#content
{
width:100%;
height:600px;
background-color:#099;
}
#foot
{
width:100%;
height:200px;
background-color:#333;

}

WEB PAGE LAYOUT USING HTML & CSS (html code)


HTML CODE:

copy and paste the code in code editor

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>layout</title>

<link href="css/style.css" type="text/css" rel="stylesheet">
</head>

<body>
<div id="wrapper">
<header>
<img src="img/logo.png" style="width:200px;height:150px;margin-left:10px;margin-top:20px;"/>
</header>
<nav>
<ul>
<li><a href="index.html">Home</a> </li>
<li><a href="pages/admission.html">Admission</a> </li>
<li><a href="pages/aboutus.html">About Us</a> </li>
<li><a href="pages/contactus.html">Contact Us</a> </li>


</ul>
</nav>
<div id="content">



</div>







<div id="foot">

</div>
</div>
</body>
</html>

Monday, 18 September 2017

Database Application # 4 (insert form)

Student Class Properties:

  class student

    {

        public int s_id { get; set; }

        public string sname { get; set; }

        public string sfname { get; set; }

        public string sgender { get; set; }

        public string saddress { get; set; }

        public string sdate { get; set; }

        public string sfk { get; set; }

    }

Method of Data Insertion





public string insert_srecord(student s)
        {
            string msg = " ";
            SqlConnection conn = new SqlConnection(connstring);

            try
            {
                SqlCommand cmd = new SqlCommand("insert_student", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@std_name", SqlDbType.NVarChar, 20).Value = s.sname;
                cmd.Parameters.Add("@std_fname", SqlDbType.NVarChar, 20).Value = s.sfname;
                cmd.Parameters.Add("@std_gender", SqlDbType.NVarChar, 20).Value = s.sgender;
                cmd.Parameters.Add("@std_address", SqlDbType.NVarChar, 100).Value = s.saddress;
                cmd.Parameters.Add("@std_admissiondate", SqlDbType.NVarChar, 20).Value = s.sdate;
                cmd.Parameters.Add("@std_ad_fk_id", SqlDbType.NVarChar, 20).Value = s.sfk;


                conn.Open();
                cmd.ExecuteNonQuery();

                msg = "data successfully inserted!";

             


            }
            catch (Exception)
            {


                msg = "data is not successfully inserted!";

            }


            finally
            {
                conn.Close();
            }



            return msg;




        } //method end......................

Database Application # 2 (login C#)

LOGIN FORM CODE C#





string user = textBox1.Text;
            string password = textBox2.Text;
            string userdb,passworddb;

            returnclass rc = new returnclass();
            userdb = rc.scalarReturn("select count(ad_id) from administator where ad_name='" + user + "'");
       

        if (userdb.Equals("0"))
 {
      MessageBox.Show("Invalid user name!");
 }
        else
     {
            passworddb = rc.scalarReturn("select ad_password from administator where ad_name='" + user + "'");

     if (passworddb.Equals(password))
{
       fk_ad= rc.scalarReturn("select ad_id from administator where ad_name='" + user + "'");
       
Form2 f=new Form2();
         f.Show();

}
            else
{
    MessageBox.Show("Invalid Password!");
}

   
    }

Sunday, 17 September 2017

Notepad In C#

How to change color: 


ColorDialog dlg = new ColorDialog();
            
            if (dlg.ShowDialog() == DialogResult.OK)
            {
               
                richTextBox1.SelectionColor = dlg.Color;
            }



How to change font: 

FontDialog dlg = new FontDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                richTextBox1.SelectionFont = new Font(dlg.Font.Name, dlg.Font.Size, FontStyle.Bold);
            }


How to open new file:



OpenFileDialog dlg = new OpenFileDialog();
           

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string fileName;
                fileName = dlg.FileName;
                if (File.Exists(fileName)==true)
                {
                    StreamReader objreader=new StreamReader(fileName);
                    richTextBox1.Text = objreader.ReadToEnd();
                    objreader.Close();

                }



            }



How to Save  a new file:


SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            saveFileDialog1.FilterIndex = 2;
            saveFileDialog1.RestoreDirectory = true;



            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
               
                string path = saveFileDialog1.FileName;                
                byte[] plainDataArray = ASCIIEncoding.ASCII.GetBytes(richTextBox1.Text);
                using (var fileStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    fileStream.Write(plainDataArray, 0, plainDataArray.GetLength(0));

                }
            }

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...