Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (DialogResult.Yes == MessageBox.Show("Tem certeza que deseja apagar o registro?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
                {
                    buscar f = new buscar();

                    dados dc = new dados();
                    conex cx = new conex(dc.ConectarX);

                    BLLAnimal animal = new BLLAnimal(cx);
                    animal.Deletar(guardar);
                    MessageBox.Show("Registro apagado com sucesso", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    f.Refresh();
                    this.Close();
                }
            }
            catch (MySqlException a)
            {
                MessageBox.Show("Não foi possivel se conectar ao servidor " + a.Message);
            }
            catch (Exception a)
            {
                MessageBox.Show("Erro: " + a.Message);
            }
        }
Exemple #2
0
        private void Alterar_Click(object sender, EventArgs e)
        {
            try
            {
                dados  dc = new dados();
                conex  cx = new conex(dc.ConectarX);
                buscar f  = new buscar();

                BLLAnimal   animal = new BLLAnimal(cx);
                MODELAnimal a      = new MODELAnimal();
                a.Id           = guardar;
                a.Proprietario = textBox1.Text;
                a.Animal       = textBox2.Text;
                a.Telefone     = maskedTextBox1.Text;
                a.DataConsulta = Convert.ToDateTime(maskedTextBox2.Text);
                a.Anaminese    = textBox3.Text;
                a.Medicacao    = textBox4.Text;

                if (DialogResult.Yes == MessageBox.Show("Tem certeza que deseja alterar o registro?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
                {
                    animal.Atualizar(a);
                    MessageBox.Show("Registro alterado com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    this.Close();
                }
            }
            catch (MySqlException a)
            {
                MessageBox.Show("Falha ao conectar ao servidor: " + a.Message);
            }
            catch (Exception a)
            {
                MessageBox.Show("Falha ao alterar : " + a.Message);
            }
        }
Exemple #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                dados dc = new dados();
                conex cx = new conex(dc.ConectarX);

                BLLAnimal animal = new BLLAnimal(cx);

                MODELAnimal modeloanimal = new MODELAnimal();
                modeloanimal.Proprietario = textBox1.Text;
                modeloanimal.Animal       = textBox2.Text;
                modeloanimal.Telefone     = maskedTextBox1.Text;
                modeloanimal.DataConsulta = Convert.ToDateTime(maskedTextBox2.Text);
                modeloanimal.Anaminese    = textBox3.Text;
                modeloanimal.Medicacao    = textBox4.Text;

                animal.Incluir(modeloanimal);

                MessageBox.Show("Cadastro realizado com sucesso", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                limpar();
            }
            catch (MySqlException a)
            {
                MessageBox.Show("Falha ao conectar ao servidor: " + a.Message);
            }
            catch (Exception a)
            {
                MessageBox.Show("Falha ao cadastrar : " + a.Message);
            }
        }
Exemple #4
0
    private bool IsValidUsr()
    {
        string str = "";

        try
        {
            int IdApp = 0, IdUsr = 0;

            IdApp = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings.Get("idApp"));

            tokenHandle = IntPtr.Zero;
            bool returnValue = LogonUser(

                this.txtLogin.Text,

                cbodom.SelectedValue,

                this.txtPassword.Text,

                LOGON32_LOGON_NETWORK,

                LOGON32_PROVIDER_DEFAULT,

                ref tokenHandle);

            /*
             * bool returnValue =  LogonUser(
             *
             *                  this.txtLogin.Text,
             *
             *                  txtDom.SelectedValue,
             *
             *                  this.txtPassword.Text,
             *
             *                  LOGON32_LOGON_NETWORK,
             *
             *                  LOGON32_PROVIDER_DEFAULT,
             *
             *                  ref tokenHandle);
             *
             *
             */
            /*this.txtLogin.Text,
             * //System.Configuration.ConfigurationManager.AppSettings.Get("dominio"),
             * "amer.pfizer.com",
             * this.txtPassword.Text,
             * 3,//LOGON32_LOGON_INTERACTIVE
             * LOGON32_PROVIDER_DEFAULT,
             * ref tokenHandle);
             */

            if (returnValue == true)
            {
                string strSQL;

                /* SqlCommand cmd;
                 * SqlDataAdapter da;
                 * DataSet ds = new DataSet("app_usr");
                 */
                LoginUsr = true;

                //llamo al SP que devuelve los valores para un combo determinado
                strSQL  = System.Configuration.ConfigurationManager.AppSettings.Get("dbsecurity").ToString() + "..sp_getAplicacionesUsuarios ";//SEGURIDAD..sp_getAplicacionesUsuarios ";
                strSQL += IdApp.ToString() + ",null,";
                // strSQL += "7,null,";
                strSQL += this.txtLogin.Text.Trim();

/*
 *              cmd = new SqlCommand();
 *              cmd.CommandText = strSQL;
 *              cmd.CommandType = CommandType.Text;
 *              clsConexion db = new clsConexion();
 *              cmd.Connection = db.DBConnection;
 *              //cmd.Connection
 *              da = new SqlDataAdapter(cmd);
 *              da.Fill(ds, "app_usr_table");*/
                DataTable DT = new DataTable();
                cn = new conex();
                DT = cn.ejecutaQuerydatosSQL(strSQL, System.Configuration.ConfigurationManager.AppSettings.Get("csql").ToString());//"Data Source=POMAMRAPP01;Initial Catalog=GRS;Persist Security Info=True;User ID=sqladmin;Password=sqladmin123");
                if (DT.Rows.Count == 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }

                /*
                 * if (ds != null && ds.Tables[0].Rows.Count > 0)
                 * {
                 *  IdApp = Convert.ToInt32(ds.Tables[0].Rows[0]["idApp"]);
                 *  IdUsr = Convert.ToInt32(ds.Tables[0].Rows[0]["idUsr"]);
                 *
                 *  if (IdApp != 0 && IdUsr != 0)
                 *  {
                 *      // Login OK y con ACCESO a la aplicacion
                 *      Session["ID_USUARIO"] = Convert.ToInt32(ds.Tables[0].Rows[0]["idUsr"]);
                 *      Session["ID_APP"] = Convert.ToInt32(ds.Tables[0].Rows[0]["idApp"]);
                 *      Session["NOMBRE"] = Convert.ToString(ds.Tables[0].Rows[0]["nombre"]);
                 *      Session["LOGIN"] = ds.Tables[0].Rows[0]["login"].ToString();
                 *      default_page = ds.Tables[0].Rows[0]["defaultPage"].ToString();
                 *      //
                 *      FormsAuthentication.Initialize();
                 *      FormsAuthentication.SetAuthCookie((string)Session["nombre"], false);
                 *  }
                 * }
                 * */
            }
            return(IdApp != 0 && IdUsr != 0); // paola
        }
        catch (Exception ex)
        {
            str = ex.ToString();
            return(false);
        }
    }
Exemple #5
0
 public BLLAnimal(conex cx)
 {
     DAref = new referencia(cx);
 }