Exemple #1
0
 protected void BtnAddpy_Click(object sender, EventArgs e)
 {
     try
     {
         if (RadioPresentdb.Checked)
         {
             S_Attendance = "Present";
         }
         else if (RadioAbsentdb.Checked)
         {
             S_Attendance = "Absent";
         }
         var query = "Insert into DBMS_Table values('" + TxtRegnodb.Text + "','" + TxtSnamedb.Text + "','" + S_Attendance + "')";
         using (var conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='|DataDirectory|\Classes.mdf';Integrated Security=True"))
         {
             var comm = new SqlCommand(query, conn);
             conn.Open();
             comm.ExecuteNonQuery();
             conn.Close();
             LblMessagedb.Text = "Student added successfully";
             TxtSnamedb.Text   = TxtRegnodb.Text = S_Attendance = "";
             GvDBMS.DataBind();
         }
     }
     catch (Exception ex)
     {
         LblMessagedb.Text = ex.Message;
     }
     RefreshPage();
 }
Exemple #2
0
 private void RefreshPage()
 {
     BtnEditdb.Visible   = false;
     BtnAdddb.Visible    = true;
     BtnDeletedb.Visible = false;
     TxtSnamedb.Text     = TxtRegnodb.Text = S_Attendance = "";
     GvDBMS.DataBind();
     ListDBMS.DataBind();
 }