Exemplo n.º 1
0
        protected void DropDownListDays_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Convert.ToInt32(DropDownListDays.SelectedIndex) != 0)
            {
                GridViewRes.Visible    = false;
                GridViewPerson.Visible = false;
                GridViewDays.Visible   = true;
                LabelMessage.Text      = TextBoxP_id.Text;

                try
                {
                    conn.Open();

                    cmd             = conn.CreateCommand();
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "SelectResByDay";

                    SqlParameter in1 = cmd.Parameters.Add("@Date", SqlDbType.DateTime);
                    in1.Direction = ParameterDirection.Input;
                    in1.Value     = Convert.ToDateTime(DropDownListDays.SelectedValue.ToString());



                    rdr = cmd.ExecuteReader();

                    GridViewDays.DataSource = rdr;
                    GridViewDays.DataBind();
                }
                catch (Exception ex)
                {
                    LabelMessage.Text = ex.Message + ex.StackTrace;
                }
                finally
                {
                    conn.Close();
                }
            }
        }
Exemplo n.º 2
0
        protected void ButtonUpdate_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(@"data source = .\sqlexpress; integrated security = true; database = Dentist");
            SqlCommand    cmd  = null;

            try
            {
                conn.Open();

                cmd             = conn.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "UpdateReservation";



                SqlParameter in1 = cmd.Parameters.Add("@Date", SqlDbType.DateTime);
                SqlParameter in2 = cmd.Parameters.Add("@P_Id", SqlDbType.Int);
                SqlParameter in3 = cmd.Parameters.Add("@D_Id", SqlDbType.Int);
                SqlParameter in4 = cmd.Parameters.Add("@T_Id", SqlDbType.Int);
                SqlParameter in5 = cmd.Parameters.Add("@R_Id", SqlDbType.Int);

                in1.Direction = ParameterDirection.Input;
                in1.Value     = DateTime.Parse(TextBoxDate.Text);
                in2.Direction = ParameterDirection.Input;
                in2.Value     = TextBoxP_id.Text;
                in3.Direction = ParameterDirection.Input;
                in3.Value     = TextBoxD_id.Text;

                in4.Direction = ParameterDirection.Input;
                in4.Value     = TextBoxT_id.Text;

                in5.Direction = ParameterDirection.Input;
                in5.Value     = Convert.ToInt32(LabelMessage.Text);



                cmd.ExecuteNonQuery();

                LabelMessage.Text = "Reservation has been updated";
            }
            catch (Exception ex)
            {
                LabelMessage.Text = ex.Message + ex.StackTrace;
            }
            finally
            {
                conn.Close();
            }

            if (Session["PatientName"] != null)
            {
                UpdateGridview();
            }
            else if (Session["DentistName"] != null)
            {
                UpdateGridviewDentist();
            }

            try
            {
                conn.Open();

                cmd             = conn.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "SelectAllRes";

                SqlParameter in1 = cmd.Parameters.Add("@P_id", SqlDbType.Int);
                in1.Direction = ParameterDirection.Input;
                in1.Value     = Convert.ToInt32(TextBoxP_id.Text);



                rdr = cmd.ExecuteReader();

                GridViewPerson.DataSource = rdr;
                GridViewPerson.DataBind();
            }
            catch (Exception ex)
            {
                LabelMessage.Text = ex.Message + ex.StackTrace;
            }
            finally
            {
                conn.Close();
            }

            try
            {
                conn.Open();

                cmd             = conn.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "SelectResByDay";

                SqlParameter in1 = cmd.Parameters.Add("@Date", SqlDbType.DateTime);
                in1.Direction = ParameterDirection.Input;
                in1.Value     = Convert.ToDateTime(TextBoxDate.Text);



                rdr = cmd.ExecuteReader();

                GridViewDays.DataSource = rdr;
                GridViewDays.DataBind();
            }
            catch (Exception ex)
            {
                LabelMessage.Text = ex.Message + ex.StackTrace;
            }
            finally
            {
                conn.Close();
            }
        }