NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class RegistationFrom : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=REDDY-PC;Initial Catalog=demo;User ID=sa;Password=admin123");
protected void Page_Load(object sender, EventArgs e)
{
Details();
Details11();
}

protected void Button1_Click(object sender, EventArgs e)
{
int i;

int Id = 0;
string name = txtEName.Text;
string email = txtemail.Text;
string mob = txtMobile.Text;

double sal =Convert.ToDouble( txtsalary.Text);
string gender;
if (RadioButton1.Checked == true)
{
gender = "M";
}
else
{
gender="F";
}
string type = Ddltype.SelectedItem.Text;

string chk="";
if (CheckBox1.Checked == true)
{
chk ="ABC";
}
if (CheckBox2.Checked == true)
{
if (chk == "")
chk = "DEF";
else
chk = chk + "," + "DEF";
}
else
{
chk = "";
}
DateTime a =Convert.ToDateTime( Request.Form[txtdob.UniqueID]);

string dt = a.ToString("dd/MM/yyyy");

if (Button1.Text == "Save")
{

SqlCommand cmd = new SqlCommand("insert into Employee(EmpName,Mail,mobile,salary,gender,Emptype,chekbox,dob) values('" + name + "','" + email + "','" + mob + "','" + sal + "','" + gender + "','" + type + "','" + chk + "','"+dt+"')", con);
con.Open();
i = cmd.ExecuteNonQuery();
con.Close();
}
else
{
int id1=Convert.ToInt32(txtEmpId.Text);
SqlCommand cmd = new SqlCommand("update employee set empname='" + name + "',Mail='" + email + "',Mobile='" + mob + "',salary='" + sal + "',gender='" + gender + "',emptype='" + type + "',chekbox='" + chk + "',dob='"+dt+"' where empid='"+id1+"'", con);
con.Open();
i = cmd.ExecuteNonQuery();
con.Close();
Button1.Text = "Save";
}
if (i == 1)
{
Label9.Text = "Sucess";
Details();
clearfilds();
}
else
{
Label9.Text = "Fail";
}

}
public void Details()
{
//SqlDataAdapter da = new SqlDataAdapter("select EmpId,EmpName,Mail,mobile,dob from employee", con);
//DataSet ds = new DataSet();
//da.Fill(ds);
//GridView1.DataSource = ds;
//GridView1.DataBind();

}

public void Details11()
{
SqlDataAdapter da = new SqlDataAdapter("select sno,sname,smail,gender,phno,dob from stable", con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView2.DataSource = ds;
GridView2.DataBind();


}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{

string s = ((Label)GridView1.Rows[e.RowIndex].FindControl("lblCustomerID")).Text;
int id = Convert.ToInt32(s);

SqlCommand cmd = new SqlCommand("delete from employee where EmpId="+id+"",con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Details();

}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
string a = ((Label)GridView1.Rows[e.NewEditIndex].FindControl("lblCustomerID")).Text;
//string b = ((Label)GridView1.Rows[e.NewEditIndex].FindControl("")).Text;

int id = Convert.ToInt32(a);
SqlDataAdapter da = new SqlDataAdapter("select EmpName,Mail,mobile,salary,gender,Emptype,chekbox,dob from Employee where empId='" + id + "'", con);
DataSet ds = new DataSet();
da.Fill(ds);

DataTable dt = new DataTable();
da.Fill(dt);

txtEName.Text=ds.Tables[0].Rows[0]["EmpName"].ToString();
txtMobile.Text = ds.Tables[0].Rows[0]["mobile"].ToString();
txtemail.Text = ds.Tables[0].Rows[0]["Mail"].ToString();
txtsalary.Text = ds.Tables[0].Rows[0]["salary"].ToString();
string g = ds.Tables[0].Rows[0]["gender"].ToString();
if (g == "M")
RadioButton1.Checked = true;
else
RadioButton2.Checked = true;
//Ddltype.SelectedItem.Text = ds.Tables[0].Rows[0]["Emptype"].ToString();

Ddltype.SelectedItem.Value = Ddltype.Items.FindByText(ds.Tables[0].Rows[0]["Emptype"].ToString()).ToString();


string chk = ds.Tables[0].Rows[0]["chekbox"].ToString();
if (chk == "ABC")
{
CheckBox1.Checked = true;
}
if (chk == "ABC,DEF")
{
CheckBox1.Checked = true;
CheckBox2.Checked = true;
}
else
{
chk = "";
}
txtdob.Text = ds.Tables[0].Rows[0]["dob"].ToString();
txtEmpId.Text = a;
Button1.Text = "Update";


}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{

}
private void clearfilds()
{
txtemail.Text = "";
txtEmpId.Text = "";
txtEName.Text = "";
txtMobile.Text = "";
txtsalary.Text = "";
CheckBox1.Checked = false;
CheckBox2.Checked = false;
txtdob.Text = "";
}

protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
{

}
protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
{
string a = ((Label)GridView1.Rows[e.NewEditIndex].FindControl("Label1")).Text;
int no = Convert.ToInt32(a);

SqlDataAdapter da = new SqlDataAdapter("select sno, sname, smail, gender, phno, dob from stable where sno='" + no + "' ", con);
DataSet ds = new DataSet();
da.Fill(ds);
txtEName.Text = ds.Tables[0].Rows[0]["sname"].ToString();
txtemail.Text = ds.Tables[0].Rows[0]["smail"].ToString();


Button1.Text = "Update";
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.