Exemple #1
0
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            CalculaPacote();

            try
            {
                MonitoramentoModel mm = new MonitoramentoModel();
                mm.Descricao    = txtdescricao.Text;
                mm.NomeCli      = txtnome.Text;
                mm.Qtd_camera   = Convert.ToInt32(txtqtd_camera.Text);
                mm.Valor_pacote = Convert.ToDecimal(txtvalor_pacote.Text);
                mm.Plano        = txtplano.Text;
                mm.Fidelidade   = chckfidelidade.Checked;

                new ControleMonitoramento().Insert(mm);
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Registro Salvo Com Sucesso')", true);
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + ex.Message + "')", true);
            }

            Dispose();
            carregaGrid();
        }
        public bool Insert(MonitoramentoModel mm)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "Proc_Inserir_MM";
            cmd.Parameters.Add(new SqlParameter("@descricao", mm.Descricao));
            cmd.Parameters.Add(new SqlParameter("@qtd_cameras", mm.Qtd_camera));
            cmd.Parameters.Add(new SqlParameter("@nomeCli", mm.NomeCli));
            cmd.Parameters.Add(new SqlParameter("@valorPacote", mm.Valor_pacote));
            cmd.Parameters.Add(new SqlParameter("@fidelidade", mm.Fidelidade));
            cmd.Parameters.Add(new SqlParameter("@plano", mm.Plano));


            con.Open();
            cmd.Connection = con;
            cmd.ExecuteNonQuery();


            return(true);
        }