Four Fields as follows in run mode;
Course Code textbox
Course Name textbox
course duration textbox
Allocated hours textbox
Threee button as follows;
Save Search Update
1. Save code as follows;
private Globalfunction GFun = new Globalfunction();
private string sql;
private void Btn_Save_Click(object sender, EventArgs e)
{
sql = "insert into Tb_course_Details ([Course_Code],[Course_Name],[Course_Duration],[Allocated_Hours]) " + " values( ' " + txt_coursecode.Text + "','" + txt_coursename.Text + "', " + txt_courseduration.Text + "," + txt_Allochrs.Text + ")";
try
{
GFun.error = "";
GFun.InsertAccessData(sql);
if (GFun.error.ToString() != "")
{
MessageBox.Show(GFun.error.ToString(), "Error");
return;
}
GFun.OleDbcon.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
2. Search code as follows;
private void Btn_Search_Click(object sender, EventArgs e)
{
try
{
GFun.BindAccessConn();
sql = "select * from Tb_course_Details order by Course_Code";
OleDbDataAdapter da = new OleDbDataAdapter(sql, GFun.OleDbcon);
DataTable dt = new DataTable();
da.Fill(dt);
DGVCourseDetails.DataSource = dt;
}
catch (Exception ex1)
{
MessageBox.Show(ex1.ToString(), "Error", MessageBoxButtons.OK);
return;
}
}
3. datagridviewcell click code as follows;
private void DGVCourseDetails_CellClick(object sender, DataGridViewCellEventArgs e)
{
txt_coursecode.ReadOnly = true;
txt_coursecode.Text = DGVCourseDetails.Rows[e.RowIndex].Cells[0].Value.ToString();
txt_coursename.Text = DGVCourseDetails.Rows[e.RowIndex].Cells[1].Value.ToString();
txt_courseduration.Text = DGVCourseDetails.Rows[e.RowIndex].Cells[2].Value.ToString();
txt_Allochrs.Text = DGVCourseDetails.Rows[e.RowIndex].Cells[3].Value.ToString();
}
when i click the datagridveiw,the respective entries will be displayed in the textbox.
that is working fine.
i want to update the course duration and Allocated hours.
for that in the update button how can i do using c sharp.
Update Button.
private void Btn_Update_Click(object sender, EventArgs e)
{
In Update Button how can i write the code to update course duration and Allocated hours.
}
please help me.
how can i write the code to update the course duration and allocated hours.
Regards and Thanks.
Narasiman P.