Ejemplo n.º 1
0
        public void OK_Click(System.Object sender, System.EventArgs e)
        {
            if (UsernameTextBox.Text.Trim() == "" || PasswordTextBox.Text.Trim() == "")
            {
                Interaction.MsgBox("Por favor, llene ambos campos!", Constants.vbInformation, "Nota");
            }
            else
            {
                Modulo1.con.Open();
                var sql = "SELECT * FROM tblUser WHERE username = \'" + Modulo1.SafeSqlLiteral(UsernameTextBox.Text, 2) + "\' AND password = \'" + Modulo1.SafeSqlLiteral(PasswordTextBox.Text, 2) + "\'";

                var             cmd = new OleDbCommand(sql, Modulo1.con);
                OleDbDataReader dr  = cmd.ExecuteReader();

                try
                {
                    if (dr.Read() == false)
                    {
                        Interaction.MsgBox("Inicio de sesión fallida  ¬¬", Constants.vbCritical, "Nota");
                    }
                    else
                    {
                        Interaction.MsgBox("¡Bienvenido!  ツ", Constants.vbInformation, "Nota");
                        frmMain.Default.status.Items[0].Text = "Logueado como : " + UsernameTextBox.Text.Trim();
                        DateTime datenow = DateTime.Now;
                        frmMain.Default.status.Items[2].Text = "Fecha y Hora : " + datenow.ToString("MMMM dd, yyyy") + " " + DateAndTime.TimeOfDay;
                        Modulo1.con.Close();
                        UsernameTextBox.Clear(); PasswordTextBox.Clear(); UsernameTextBox.Focus();
                        this.Hide();
                        frmMain.Default.ShowDialog();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                Modulo1.con.Close();
            }
        }
Ejemplo n.º 2
0
        public void bttnSave_Click(System.Object sender, System.EventArgs e)
        {
            Modulo1.con.Open();
            string num       = txtID.Text.Trim();
            string type      = txtRoomType.Text.Trim();
            string rate      = txtRoomRate.Text.Trim();
            string occupancy = txtNoOfOccupancy.Text.Trim();
            string stat      = "Disponible";

            if (type == null || rate == null || occupancy == null)
            {
                Interaction.MsgBox("Por favor llene todos los campos", Constants.vbInformation, "Nota");
            }
            else
            {
                if (bttnSave.Text == "&Guardar")
                {
                    var sql = "SELECT * FROM tblRoom WHERE RoomNumber = " + Modulo1.SafeSqlLiteral(num, 2) + "";

                    var             cmd = new OleDbCommand(sql, Modulo1.con);
                    OleDbDataReader dr  = cmd.ExecuteReader();

                    try
                    {
                        if (dr.Read() == false)
                        {
                            OleDbCommand add_room = new OleDbCommand("INSERT INTO tblRoom(RoomNumber,RoomType,RoomRate,NoOfOccupancy,Status) values (\'" +
                                                                     Modulo1.SafeSqlLiteral(num, 2) + "\',\'" +
                                                                     Modulo1.SafeSqlLiteral(type, 2) + "\',\'" +
                                                                     Modulo1.SafeSqlLiteral(rate, 2) + "\',\'" +
                                                                     Modulo1.SafeSqlLiteral(occupancy, 2) + "\',\'" +
                                                                     stat + "\')", Modulo1.con);
                            add_room.ExecuteNonQuery();
                            add_room.Dispose();
                            Interaction.MsgBox("Habitación Agregada!", Constants.vbInformation, "Nota");
                            txtID.Clear();
                            txtRoomType.Clear();
                            txtRoomRate.Clear();
                            txtNoOfOccupancy.Clear();
                        }
                        else
                        {
                            Interaction.MsgBox("Número de Habitación Existente!", Constants.vbExclamation, "Nota");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    OleDbCommand update_room = new OleDbCommand("UPDATE tblRoom SET RoomNumber= \'" + Modulo1.SafeSqlLiteral(num, 2) + "\',RoomType = \'" + Modulo1.SafeSqlLiteral(type, 2) + "\',RoomRate = \'" + Modulo1.SafeSqlLiteral(rate, 2) + "\',NoOfOccupancy = \'" + Modulo1.SafeSqlLiteral(occupancy, 2) + "\' WHERE ID = " + id.ToString() + "", Modulo1.con);
                    update_room.ExecuteNonQuery();
                    update_room.Dispose();
                    Interaction.MsgBox("Habitación Guardada!", Constants.vbInformation, "Nota");
                    bttnSave.Text = "&Guardar";
                    txtID.Clear();
                    txtRoomType.Clear();
                    txtRoomRate.Clear();
                    txtNoOfOccupancy.Clear();
                }
            }
            Modulo1.con.Close();
            display_room();
        }