0% found this document useful (0 votes)
12 views2 pages

Student

This C# code defines a student form class that interacts with a SQL database to insert customer records. It contains methods to bind dropdown lists to retrieve room numbers from the database, to populate form fields with data from a selected room record, and an event handler method for a button click that inserts a new customer record into the database table.

Uploaded by

Rajpara jeel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Student

This C# code defines a student form class that interacts with a SQL database to insert customer records. It contains methods to bind dropdown lists to retrieve room numbers from the database, to populate form fields with data from a selected room record, and an event handler method for a button click that inserts a new customer record into the database table.

Uploaded by

Rajpara jeel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

student

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;
//using System.Data;
using System.Data.SqlClient;

namespace HOTELMANAGEMENT
{
public partial class student : Form
{
public student()
{
InitializeComponent();
}

SqlConnection conn = new SqlConnection(@"");


SqlCommand cmd = new SqlCommand();

private void button1_Click(object sender, EventArgs e)


{
txtprice.Enabled = true;
txtlname.Enabled = true;
txtRoomtype.Enabled = true;
binddata();
conn.Close();
String s="";
if (btnmale.Checked == true)
s = "Male";
else s = "Female";

cmd=new SqlCommand("insert into tblcustomer


values('"+txtid.Text+"',"+txtcontact.Text+",'"+s+"','"+txtDOB.Text+"','"+txtfname.T
ext+"','"+txtaddress.Text+"',"+txtRoomno+");", conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("Record inserted .......");
}
private void binroomno()
{
DataTable dt = new DataTable();
SqlDataAdapter da=new SqlDataAdapter();
conn.Close();
da=new SqlDataAdapter("select * from tblrooms;",conn);
conn.Open();
da.Fill(dt);
conn.Close();
txtRoomno.DataSource = dt;
txtRoomno.ValueMember = "RoomNO";
txtRoomno.DisplayMember = "RoomNo";
}
private void binddata()
{
conn.Close();
cmd = new SqlCommand("select * from tblrooms where RoomNo=102",conn);
SqlDataReader dr;
conn.Open();
dr = cmd.ExecuteReader();
if (dr.HasRows) {
dr.Read();
txtlname.Text=dr.GetValue(2).ToString();
txtRoomtype.Text=dr.GetValue(1).ToString();
txtprice.Text=dr.GetValue(3).ToString();
}
}

private void customer_Load(object sender, EventArgs e)


{
binroomno();
txtlname.Enabled = false;
txtRoomtype.Enabled = false;
txtprice.Enabled = false;
}

private void txtDOB_ValueChanged(object sender, EventArgs e)


{

private void label1_Click(object sender, EventArgs e)


{

private void label10_Click(object sender, EventArgs e)


{

private void txtprice_TextChanged(object sender, EventArgs e)


{

private void txtRoomno_SelectedIndexChanged(object sender, EventArgs e)


{

}
}
}

You might also like