コード例 #1
0
    /** MODIFICAR */
    protected void btnModificarH_Click(object sender, EventArgs e)
    {
        try
        {
            foreach (Control txtBox in listOfCtrls())
            {
                if (txtBox is TextBox && String.IsNullOrEmpty(((TextBox)txtBox).Text))
                {
                    throw new Exception("Existen campos vacíos");
                }
            }
            string rutaImg = txtFotoH.FileName != "" ? "imagenes/hoteles/" + txtFotoH.FileName : imgFotoH.ImageUrl;

            Session["hotel"] = new Hotel(txtHotel.Text, txtCalleH.Text, Convert.ToInt32(txtNumeroH.Text), txtCuidadH.Text,
                                         Convert.ToInt32(txtCategoriaH.Text), txtTelH.Text, txtFaxH.Text, rutaImg,
                                         chkPlayaH.Checked, chkPiscinaH.Checked);

            LogicaHotel.Modificar(((Hotel)Session["hotel"]));

            if (txtFotoH.FileName != "")
            {
                txtFotoH.SaveAs(Server.MapPath(rutaImg));
            }

            lblMsj.Text = "Hotel modificado correctamente";
            limpiarFomulario();
        }
        catch (Exception ex)
        { lblMsj.Text = ex.Message; }
    }
コード例 #2
0
    /** MODIFICAR */
    protected void btnModificarH_Click(object sender, EventArgs e)
    {
        try
        {
            foreach (Control txtBox in listOfTxtBox())
            {
                if (String.IsNullOrEmpty(((TextBox)txtBox).Text))
                {
                    throw new Exception("Existen campos vacíos");
                }
            }
            string rutaImg = "~/imagenes/hoteles/" + txtFotoH.FileName;

            Hotel hotel = new Hotel(txtHotel.Text, txtCalleH.Text, Convert.ToInt32(txtNumeroH.Text), txtCuidadH.Text,
                                    Convert.ToInt32(txtCategoriaH.Text), txtTelH.Text, txtFaxH.Text, rutaImg,
                                    chkPlayaH.Checked, chkPiscinaH.Checked);

            LogicaHotel.Modificar(hotel);
            txtFotoH.SaveAs(Server.MapPath(rutaImg));
            lblMsj.Text = "Hotel modificado correctamente";
            // TO DO limpiar campos
        }
        catch (Exception ex)
        { lblMsj.Text = ex.Message; }
    }