private bool SaveDetails()
{
//validation for textbox not empty
bool Check;
Check = true;
if (txt_Faccode.Text.Trim().Length == 0)
{
Check = false;
MessageBox.Show("Please enter the Faculty code","Not Enter the details",MessageBoxButtons.OK,MessageBoxIcon.Information);
return Check;
}
if (Txt_Facname.Text.Trim().Length == 0)
{
Check = false;
MessageBox.Show("Please enter the Faculty Name","Not Enter the details",MessageBoxButtons.OK,MessageBoxIcon.Information);
return Check;
}
if (txt_Hrs.Text.Trim().Length == 0)
{
Check = false;
MessageBox.Show("Please enter the allocated hours","Not Enter the details",MessageBoxButtons.OK,MessageBoxIcon.Information);
return Check;
}
//insert code for update to the DataBase
this.Cursor = Cursors.WaitCursor;
try
{
sql = "insert into Tb_SCH_Faculty_Details ([Faculty_Code], [Faculty_Name],[Allocated_Hours]) " + " values('" + txt_Faccode.Text + "','" + Txt_Facname.Text + "', " + txt_Hrs.Text + ")";
int temp = 0;
if (!int.TryParse(txt_Hrs.Text.Trim(), out temp))
{
Check = false;
this.Cursor = Cursors.Arrow;
MessageBox.Show("Enter Numbers only in allocated hours", "Characters Not Allowed", MessageBoxButtons.OK, MessageBoxIcon.Error);
return Check;
}
GFun.Error = "";
GFun.InsertAccessData(sql);
if (GFun.Error.ToString() != "")
{
Check = false;
MessageBox.Show(GFun.Error.ToString(), "Error");
this.Cursor = Cursors.Arrow;
return Check;
}
GFun.OleDbCon.Close();
}
catch (Exception ex)
{
Check = false;
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Cursor = Cursors.Arrow;
return Check;
}
this.Cursor = Cursors.Arrow;
return Check;
}
private void Btn_Save_Click(object sender, EventArgs e)
{
if (SaveDetails() == true)
MessageBox.Show("Record Inserted Successfully", "Records Inserted", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
run mode as follows;
Faculty code textbox
Faculty name textbox
Alloated hrs textbox
when i enter all the details and click the save button, the above three items records should be displayed in datagridview.
for that how can i do using csharp.