Click here to Skip to main content
15,887,405 members
Home / Discussions / C#
   

C#

 
QuestionHow to run multiple audio files Pin
itsmitm31-Aug-09 23:01
itsmitm31-Aug-09 23:01 
Questionspecial characters Pin
248912831-Aug-09 22:29
248912831-Aug-09 22:29 
AnswerRe: special characters Pin
OriginalGriff31-Aug-09 22:48
mveOriginalGriff31-Aug-09 22:48 
QuestionQuery execution problen in C# program Pin
Kunle Oladimeji31-Aug-09 22:24
Kunle Oladimeji31-Aug-09 22:24 
AnswerRe: Query execution problen in C# program Pin
dan!sh 31-Aug-09 22:33
professional dan!sh 31-Aug-09 22:33 
AnswerRe: Query execution problen in C# program Pin
Tamimi - Code31-Aug-09 22:39
Tamimi - Code31-Aug-09 22:39 
AnswerRe: Query execution problen in C# program Pin
Jacobb Michael31-Aug-09 23:17
Jacobb Michael31-Aug-09 23:17 
AnswerRe: Query execution problen in C# program Pin
seoamitk1-Sep-09 23:37
seoamitk1-Sep-09 23:37 
you have read just inserting code on particular event

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;

namespace HotelProject
{
public partial class NewEmployee : Form
{
SqlConnection con;
SqlCommandBuilder cmdb;
SqlDataAdapter da;
DataSet ds;
public NewEmployee()
{
con = new SqlConnection("Data source=JBB-F906306D8CC\\SQLEXPRESS;Initial Catalog=Hotel;Integrated Security=SSPI");
InitializeComponent();
}

private void btnBrowseImagePath_Click(object sender, EventArgs e)
{
OpenFileDialog op = new OpenFileDialog();
if (op.ShowDialog() == DialogResult.OK)
{
txtBrowseImagePath.Text = op.FileName;
}
}

private void btnSubmitRecord_Click(object sender, EventArgs e)
{
con.Open();
da = new SqlDataAdapter("Select * From EmployeeDetails", con);
cmdb = new SqlCommandBuilder(da);
ds = new DataSet("EmployeeDetails");

if (txtBrowseImagePath.Text != "")
{
FileStream fs = new FileStream(txtBrowseImagePath.Text, FileMode.OpenOrCreate, FileAccess.Read);
byte[] rawdata = new byte[fs.Length];
fs.Read(rawdata, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
da.Fill(ds, "EmployeeDetails");
DataRow dr = ds.Tables["EmployeeDetails"].NewRow();
dr["FullName"] = txtFullName.Text;
dr["FatherName"] = txtFatherName.Text;
dr["DateOfBirth"] = maskedTxtDateofBirth.Text;
dr["Gender"] = cmbgender.SelectedItem.ToString();
dr["Address"] = txtAddress.Text;
dr["City"] = txtCity.Text;
dr["Country"] = cmbCountry.SelectedItem.ToString();
dr["PhoneNo"] = txtPhone.Text;
dr["EMailID"] = txtEMailId.Text;
dr["LicenceNo"] = txtLicence.Text;
dr["EmployeeHotelId"] = txtEhotelid.Text;
dr["DepartmentName"] = cmbDepartmentName.SelectedItem.ToString();
dr["Designation"] = cmbDesignation.SelectedItem.ToString();
dr["Qualification"] = cmbQualification.SelectedItem.ToString();
dr["SalaryPerMonth"] = txtSalary.Text;
dr["HireDate"] = maskedtxtHireDate.Text;
dr["UserName"] = txtUserName.Text;
dr["Password"] = txtPassword.Text;
dr["Picture"] = rawdata;

ds.Tables["EmployeeDetails"].Rows.Add(dr);
da.Update(ds, "EmployeeDetails");
con.Close();
MessageBox.Show("Inserted");
}
else
{
MessageBox.Show("Not Inserted");
}
}

private void btnReset_Click(object sender, EventArgs e)
{
txtFullName.Text = "";
txtFatherName.Text= "";
maskedTxtDateofBirth.Text= "";
cmbgender.Text= "";
txtAddress.Text= "";
txtCity.Text= "";
cmbCountry.Text= "";
txtPhone.Text= "";
txtEMailId.Text = "";
txtLicence.Text = "";
txtEhotelid.Text= "";
cmbDepartmentName.Text= "";
cmbDesignation.Text = "";
cmbQualification.Text = "";
txtSalary.Text= "";
maskedtxtHireDate.Text= "";
txtUserName.Text= "";
txtPassword.Text= "";
txtBrowseImagePath.Text = "";
}

private void btnUpdate_Click(object sender, EventArgs e)
{

}

private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}

private void NewEmployee_Load(object sender, EventArgs e)
{
txtBrowseImagePath.Enabled = false;
txtFullName.Focus();
}

private void txtFullName_Validating(object sender, CancelEventArgs e)
{
if (txtFullName.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtFullName.Focus();
}
else
{
txtFatherName.Focus();
}
}

private void txtFullName_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsDigit(e.KeyChar) == true)
{
MessageBox.Show("Insert character only");
txtFullName.Text = "";
}
}

private void txtFatherName_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsDigit(e.KeyChar) == true)
{
MessageBox.Show("Insert character only");
txtFatherName.Text = "";
}
}

private void txtFatherName_Validating(object sender, CancelEventArgs e)
{
if (txtFatherName.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtFatherName.Focus();
}
else
{
maskedTxtDateofBirth.Focus();
}
}

private void maskedTxtDateofBirth_Validating(object sender, CancelEventArgs e)
{
if (maskedTxtDateofBirth.Text == "")
{
MessageBox.Show("You cannot leave it blank");
maskedTxtDateofBirth.Focus();
}
else
{
cmbgender.Focus();
}
}

private void cmbgender_Validating(object sender, CancelEventArgs e)
{
if (cmbgender.SelectedItem==null)
{
MessageBox.Show("You cannot leave it blank");
cmbgender.Focus();
}
else
{
txtAddress.Focus();
}
}

private void txtAddress_Validating(object sender, CancelEventArgs e)
{
if (txtAddress.Text=="")
{
MessageBox.Show("You cannot leave it blank");
txtAddress.Focus();
}
else
{
txtCity.Focus();
}
}

private void txtCity_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsDigit(e.KeyChar) == true)
{
MessageBox.Show("Insert character only");
txtCity.Focus();
}
}

private void txtCity_Validating(object sender, CancelEventArgs e)
{
if (txtCity.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtCity.Focus();
}
else
{
cmbCountry.Focus();
}
}

private void cmbCountry_Validating(object sender, CancelEventArgs e)
{
if (cmbCountry.SelectedItem==null)
{
MessageBox.Show("You cannot leave it blank");
cmbCountry.Focus();
}
else
{
txtPhone.Focus();
}
}

private void txtPhone_Validating(object sender, CancelEventArgs e)
{
if (txtPhone.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtPhone.Focus();
}
else
{
txtEMailId.Focus();
}
}

private void txtPhone_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsLetter(e.KeyChar) == true)
{
MessageBox.Show("Insert Integer only");
txtPhone.Focus();
}

}

private void txtEMailId_Validating(object sender, CancelEventArgs e)
{
if (txtEMailId.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtEMailId.Focus();
}
else
{
txtLicence.Focus();
}
}

private void txtLicence_Validating(object sender, CancelEventArgs e)
{
if (txtLicence.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtLicence.Focus();
}
else
{
txtEhotelid.Focus();
}
}

private void txtEhotelid_Validating(object sender, CancelEventArgs e)
{
cmbDepartmentName.Focus();
}

private void cmbDepartmentName_Validating(object sender, CancelEventArgs e)
{
cmbDesignation.Focus();
}

private void cmbDesignation_Validating(object sender, CancelEventArgs e)
{
cmbQualification.Focus();
}

private void cmbQualification_Validating(object sender, CancelEventArgs e)
{
txtSalary.Focus();
}

private void txtSalary_Validating(object sender, CancelEventArgs e)
{
if (txtSalary.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtSalary.Focus();
}
else
{
maskedtxtHireDate.Focus();
}
}

private void txtSalary_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsLetter(e.KeyChar) == true)
{
MessageBox.Show("Insert Integer only");
txtSalary.Focus();
}
}

private void maskedtxtHireDate_Validating(object sender, CancelEventArgs e)
{
if (maskedtxtHireDate.Text == "")
{
MessageBox.Show("You cannot leave it blank");
maskedtxtHireDate.Focus();
}
else
{
txtUserName.Focus();
}

}

private void txtUserName_Validating(object sender, CancelEventArgs e)
{
if (txtUserName.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtUserName.Focus();
}
else
{
txtPassword.Focus();
}
}

private void txtPassword_Validating(object sender, CancelEventArgs e)
{
if (txtPassword.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtPassword.Focus();
}
else
{
btnBrowseImagePath.Focus();
}
}


}
}
QuestionHow to connect to remote sql server 2000 in Windows Services created in C# Pin
Rajesh Koriya31-Aug-09 21:56
Rajesh Koriya31-Aug-09 21:56 
AnswerRe: How to connect to remote sql server 2000 in Windows Services created in C# Pin
Tamer Oz31-Aug-09 22:31
Tamer Oz31-Aug-09 22:31 
AnswerRe: How to connect to remote sql server 2000 in Windows Services created in C# Pin
mbhosle31-Aug-09 23:08
mbhosle31-Aug-09 23:08 
QuestionStart a Service after install it ? Pin
Mohammad Dayyan31-Aug-09 21:36
Mohammad Dayyan31-Aug-09 21:36 
AnswerRe: Start a Service after install it ? Pin
Tamer Oz31-Aug-09 22:41
Tamer Oz31-Aug-09 22:41 
GeneralRe: Start a Service after install it ? Pin
Mohammad Dayyan1-Sep-09 0:46
Mohammad Dayyan1-Sep-09 0:46 
QuestionHow to stop code generator in designer in this case Pin
vql31-Aug-09 21:28
vql31-Aug-09 21:28 
QuestionHow to show a form from windows service? Pin
Tridip Bhattacharjee31-Aug-09 21:28
professionalTridip Bhattacharjee31-Aug-09 21:28 
AnswerRe: How to show a form from windows service? Pin
Vimalsoft(Pty) Ltd31-Aug-09 21:31
professionalVimalsoft(Pty) Ltd31-Aug-09 21:31 
AnswerRe: How to show a form from windows service? Pin
Hristo-Bojilov31-Aug-09 22:04
Hristo-Bojilov31-Aug-09 22:04 
AnswerRe: How to show a form from windows service? Pin
Tamer Oz31-Aug-09 22:05
Tamer Oz31-Aug-09 22:05 
QuestionCheck Box Click Event Pin
Saiyed Alam31-Aug-09 20:20
Saiyed Alam31-Aug-09 20:20 
AnswerRe: Check Box Click Event Pin
dan!sh 31-Aug-09 22:31
professional dan!sh 31-Aug-09 22:31 
Questioncreating word document using c# Pin
Swetha Srinivasan31-Aug-09 20:16
Swetha Srinivasan31-Aug-09 20:16 
AnswerRe: creating word document using c# Pin
Christian Graus31-Aug-09 20:36
protectorChristian Graus31-Aug-09 20:36 
GeneralRe: creating word document using c# Pin
Swetha Srinivasan31-Aug-09 23:20
Swetha Srinivasan31-Aug-09 23:20 
AnswerRe: creating word document using c# Pin
stancrm31-Aug-09 20:38
stancrm31-Aug-09 20:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.