private void MainCheckoutButton_Click(object sender, EventArgs e) { string query1 = "select *,CONVERT(varchar,cindate,23) from current_book where room=" + room1; string query2 = " "; if (Program.con.State == ConnectionState.Closed) { Program.con.Open(); } SqlCommand cmd1 = new SqlCommand(query1, Program.con); SqlDataReader sdr1 = cmd1.ExecuteReader(); if (sdr1.Read()) { string date1 = DateTime.Now.ToString("yyyy-MM-dd"); string time1 = DateTime.Now.ToString("HH:mm"); query2 = "insert into history values(" + room1 + ",'" + sdr1[2] + "', '" + sdr1[3] + "', '" + sdr1[4] + "', '" + sdr1[5] + "', '" + sdr1[6] + "', '" + sdr1[12] + "','" + time1 + "' , '" + date1 + "', " + sdr1[9] + "," + totallabel.Text + ",'Checkout','" + sdr1[10] + "','" + sdr1[11] + "')"; } cmd1.Dispose(); sdr1.Close(); string query = "update current_book set fname = null,lname = null ,email = null ,address = null,cintime = null,cindate = null ,coutdate = null,no_pep = null,cinstate=null,regid=null where room = " + room1 + "; " + query2; if (Program.con.State == ConnectionState.Closed) { Program.con.Open(); } SqlCommand cmd = new SqlCommand(query, Program.con); cmd.ExecuteNonQuery(); cmd.Dispose(); messageboxcs mb = new messageboxcs(); mb.bunifuCustomLabel1.Text = "room no " + room1 + " is checked out"; mb.Show(); }
private void bunifuThinButton21_Click(object sender, EventArgs e) { try { if (Program.con.State == ConnectionState.Closed) { Program.con.Open(); } string date1 = monthCalendar1.SelectionRange.Start.ToString("yyyy-MM-dd"); string date2 = monthCalendar2.SelectionRange.Start.ToString("yyyy-MM-dd"); string query = "insert into pre_book values(" + room + ",'" + fnametextbox.Text + "','" + lnametextbox.Text + "','" + emailtextbox.Text + "','" + addresstextbox.Text + "', CONVERT(TIME, GETDATE()),'" + date1 + "', '" + date2 + "'," + peopleselect.selectedValue + ",replace(replace(replace(convert(varchar,getdate(),20),' ',''),':',''),'-',''))"; SqlCommand cmd = new SqlCommand(query, Program.con); cmd.ExecuteNonQuery(); messageboxcs mb = new messageboxcs(); mb.Show(); this.Visible = false; mb.bunifuCustomLabel1.Text = "room no " + room + " is booked"; } catch (Exception) { messageboxcs mb = new messageboxcs(); mb.Show(); mb.bunifuCustomLabel1.Text = "fill all the textboxes"; } }
private void findsearchbutton_Click(object sender, EventArgs e) { string tablename = ""; switch (tableselect.selectedIndex) { case 0: tablename = "current_book"; break; case 1: tablename = "pre_book"; break; case 2: tablename = "history"; break; default: tablename = "current_book"; break; } string query = ""; if (findtextbox.Text != "") { if (findtextbox.Text.All(char.IsDigit)) { if (Convert.ToInt32(findtextbox.Text) < 26) { query = "select room as Room,regid as Regid ,concat(fname,' ',lname)as Name,email as Email,cindate as 'Check In Date',coutdate as 'Checkout Date' ,address as Address from " + tablename + " where room = " + findtextbox.Text + " and fname is not null"; } else { messageboxcs mb = new messageboxcs(); //mb.cases = 'e'; mb.bunifuCustomLabel1.Text = "Select room no. from 1-25"; mb.Show(); } } else { query = "select room as Room,regid as Regid ,concat(fname,' ',lname)as Name,email as Email,cindate as 'CheckIn Date',coutdate as 'Checkout Date' ,address as Address from " + tablename + " where fname like '%" + findtextbox.Text + "%' or lname like '%" + findtextbox.Text + "%'"; } SqlDataAdapter sd = new SqlDataAdapter(query, Program.con); DataTable ds = new DataTable(); sd.Fill(ds); findView2.DataSource = ds; findView2.ClearSelection(); //findView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; } }
private void loginbutton_Click(object sender, EventArgs e) { if (Program.con.State == ConnectionState.Closed) { Program.con.Open(); } String query = "select * from login where id='" + logintxt.Text + "'"; SqlCommand cmd = new SqlCommand(query, Program.con); SqlDataReader sdr = cmd.ExecuteReader(); if (sdr.Read()) { if (sdr[1].ToString() == passtxt.Text) { Program.inf.id = logintxt.Text; this.Dispose(); if (sdr[2].ToString() == "m") { Program.onclick1(); sdr.Close(); cmd.Dispose(); } else { if (sdr[2].ToString() == "o") { Program.onclick(); sdr.Close(); } else { label1.Text = "invalid user"; sdr.Close(); } } } else { sdr.Close(); messageboxcs mb = new messageboxcs(); mb.Show(); mb.bunifuCustomLabel1.Text = "wrong password"; } } else { sdr.Close(); messageboxcs mb = new messageboxcs(); mb.Show(); mb.bunifuCustomLabel1.Text = "wrong username"; } }
private void RemoveEmpButton_Click(object sender, EventArgs e) { string query = "delete from login where id ='" + EmpName.selectedValue + "' and post != 'm'"; SqlCommand cmd = new SqlCommand(query, Program.con); cmd.ExecuteNonQuery(); messageboxcs mb = new messageboxcs(); mb.bunifuCustomLabel1.Text = "Employee Removed"; mb.Show(); load(); }
private void AddEmpButton_Click(object sender, EventArgs e) { string query = "insert into login values('" + idtextbox.Text + "','" + passtextbox.Text + "','o','" + emailtextbox.Text + "','" + fullnametextbox.Text + "','" + addrestextbox.Text + "','" + monthCalendar1.SelectionRange.Start.ToString("yyyy-MM-dd") + "','" + date1 + "')"; SqlCommand cmd = new SqlCommand(query, Program.con); cmd.ExecuteNonQuery(); messageboxcs mb = new messageboxcs(); mb.bunifuCustomLabel1.Text = "Employee Added"; mb.Show(); load(); }
private void datevalidation(MonthCalendar d1, MonthCalendar d2) { if (d1.TodayDate > d1.SelectionRange.Start) { messageboxcs mb = new messageboxcs(); mb.bunifuCustomLabel1.Text = "select todays date or above"; mb.Show(); refreshbutton.Visible = true; return; } if (d1.SelectionRange.Start > d2.SelectionRange.Start) { messageboxcs mb = new messageboxcs(); mb.Show(); mb.bunifuCustomLabel1.Text = "end date"; refreshbutton.Visible = true; return; } }
private void getpass_Click(object sender, EventArgs e) { if (Program.con.State == ConnectionState.Closed) { Program.con.Open(); } String query = "select pass from login where id='" + logintxt.Text + "' and email = '" + emailtext.Text + "'"; SqlCommand cmd = new SqlCommand(query, Program.con); SqlDataReader sdr = cmd.ExecuteReader(); if (sdr.Read()) { messageboxcs mb = new messageboxcs(); mb.Show(); mb.bunifuCustomLabel1.Text = "" + sdr[0]; } else { messageboxcs mb = new messageboxcs(); mb.Show(); mb.bunifuCustomLabel1.Text = "invaliid details"; } }
private void Roomnobutton_Click(object sender, EventArgs e) { //refresh room button state refreshbutton_Click(null, null); //cheking bool istoday = (hometabcal1.SelectionRange.Start == hometabcal1.TodayDate); bool isbuttonred = (((BunifuThinButton2)sender).IdleLineColor == Color.Red); bool isgreen = (((BunifuThinButton2)sender).IdleForecolor == Color.Red); bool islabelred = (GetlabelByName("label" + (((BunifuThinButton2)sender).ButtonText)).ForeColor == Color.Red); //witch window will appre on button click decider //prebooked room chek in if (isgreen) { //get button text string room = ((BunifuThinButton2)sender).ButtonText; //query string query = "Select * from pre_book where room = " + ((BunifuThinButton2)sender).ButtonText; SqlCommand cmd = new SqlCommand(query, Program.con); SqlDataReader sdr = cmd.ExecuteReader(); if (sdr.Read()) { query = "delete from pre_book where room = " + ((BunifuThinButton2)sender).ButtonText + "; "; query += "update current_book set fname='" + sdr[1] + "',lname='" + sdr[2] + "',email='" + sdr[3] + "',address='" + sdr[4] + "',cintime=CONVERT(TIME, GETDATE()),cindate=CONVERT(date, GETDATE()),coutdate='" + sdr[7] + "',no_pep=" + sdr[8] + ",cinstate='prebook',regid=replace(replace(replace(convert(varchar,getdate(),20),' ',''),':',''),'-','') where room = " + ((BunifuThinButton2)sender).ButtonText; SqlCommand cmd1 = new SqlCommand(query, Program.con); cmd1.ExecuteNonQuery(); cmd1.Dispose(); } cmd.Dispose(); sdr.Close(); //message box show messageboxcs mb = new messageboxcs(); mb.Show(); mb.bunifuCustomLabel1.Text = "room no " + room + " is bookd"; } //other else { //get room no Program.inf.room = ((BunifuThinButton2)sender).ButtonText; //decider if (istoday) { if (isbuttonred) { filledroomwin rfw = new filledroomwin(); rfw.room = Program.inf.room; if (islabelred) { rfw.servicesbutton.Dispose(); rfw.checkoutbutton.Dispose(); rfw.namel.Dispose(); rfw.namelab.Dispose(); rfw.Show(); } else { rfw.canclebutton.Dispose(); rfw.Show(); } } else { current_book1.label5.Text = "Room No : " + Program.inf.room; current_book1.room = ((BunifuThinButton2)sender).ButtonText; current_book1.BringToFront(); current_book1.Visible = true; current_book1.monthCalendar1.SelectionRange = hometabcal2.SelectionRange; } } else { if (isbuttonred) { filledroomwin rfw = new filledroomwin(); rfw.room = Program.inf.room; if (islabelred) { rfw.servicesbutton.Dispose(); rfw.checkoutbutton.Dispose(); rfw.namel.Dispose(); rfw.namelab.Dispose(); rfw.Show(); } else { rfw.canclebutton.Dispose(); rfw.Show(); } } else { pre_book1.label5.Text = "Room No : " + Program.inf.room; pre_book1.room = ((BunifuThinButton2)sender).ButtonText; pre_book1.BringToFront(); pre_book1.Visible = true; pre_book1.monthCalendar1.SelectionRange = hometabcal1.SelectionRange; pre_book1.monthCalendar2.SelectionRange = hometabcal2.SelectionRange; } } } }