Esempio n. 1
0
        private void getCheckoutLog()
        {
            try {
                dbClass db = new dbClass();
                System.Data.DataTable dt = db.dbSelect("SELECT name, checkoutdate as 'checkout date', owner, email, phone, days, balance, reference FROM reservelog WHERE state='checkout' ORDER BY id DESC");
                dataGridView3.DataSource = dt;
                dataGridView3.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView3.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView3.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView3.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView3.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView3.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView3.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView3.Columns[7].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                //dataGridView3.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                dataGridView3.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
                dataGridView3.Columns[0].ReadOnly = true;
                dataGridView3.Columns[1].ReadOnly = true;
                dataGridView3.Columns[2].ReadOnly = true;
                dataGridView3.Columns[3].ReadOnly = true;
                dataGridView3.Columns[4].ReadOnly = true;
                dataGridView3.Columns[5].ReadOnly = true;
                dataGridView3.Columns[6].ReadOnly = true;
                dataGridView3.Columns[7].ReadOnly = true;
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private void getBalance()
        {
            dbClass db = new dbClass();

            System.Data.DataTable dt = db.dbSelect("SELECT balance from reservelog");
            this.balance = dt;
        }
Esempio n. 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            dbClass db = new dbClass();

            db.dbUpdate("UPDATE security SET email = '" + txtEmail.Text + "', password = '******', usertype = '" + cmbType.Text + "', fullname = '" + txtFullName.Text + "' WHERE id = " + this.userid);
            this.Hide();
            MessageBox.Show("User Updated!");
        }
Esempio n. 4
0
        private void btnReg_Click(object sender, EventArgs e)
        {
            dbClass db = new dbClass();

            db.dbInsert("INSERT INTO security (email, password, usertype, fullname) VALUES('" + txtEmail.Text + "', '" + txtPassword.Text + "', '" + cmbType.Text + "', '" + txtFullName.Text + "')");
            this.Hide();
            MessageBox.Show("User Added!");
        }
Esempio n. 5
0
        private void button3_Click(object sender, EventArgs e)
        {
            dbClass db = new dbClass();

            db.dbDelete("DELETE FROM security WHERE id=" + this.userid);
            this.Hide();
            MessageBox.Show("User " + txtFullName.Text + " deleted!");
        }
Esempio n. 6
0
        public System.Data.DataTable getRoomState()
        {
            System.Data.DataTable dt;
            dbClass room = new dbClass();

            dt = room.dbSelect("SELECT * FROM room");
            return(dt);
        }
Esempio n. 7
0
        private void btnPaid_Click(object sender, EventArgs e)
        {
            dbClass db = new dbClass();

            db.dbUpdate("UPDATE room SET state='occupied' WHERE id='" + txtRoomId.Text + "'");
            showHide("client", false);
            showHide("menu", true);
            setRoomState();
            getCheckoutLog();
            MessageBox.Show("Success!");
        }
Esempio n. 8
0
        private void getRoomsCount()
        {
            dbClass db = new dbClass();

            System.Data.DataTable res   = db.dbSelect("SELECT * FROM room WHERE state='occupied'");
            System.Data.DataTable avail = db.dbSelect("SELECT * FROM room WHERE state='available'");
            System.Data.DataTable pen   = db.dbSelect("SELECT * FROM room WHERE state='reserved'");
            System.Data.DataTable t_res = db.dbSelect("SELECT * FROM room_ind");
            labelReservedRooms.Text  = res.Rows.Count.ToString();
            labelAvailableRooms.Text = avail.Rows.Count.ToString();
            labelPending.Text        = pen.Rows.Count.ToString();
            labelt_res.Text          = t_res.Rows.Count.ToString();
        }
Esempio n. 9
0
        private void getRoomInd()
        {
            dbClass db = new dbClass();

            System.Data.DataTable dt = db.dbSelect("SELECT reference,name,owner,reserveddate as 'date',email,phone,days FROM room_ind ORDER BY id DESC");
            dataGridView5.DataSource = dt;
            dataGridView5.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView5.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView5.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView5.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView5.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView5.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView5.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
        }
Esempio n. 10
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (txtEmail.Text.Contains('@'))
     {
         dbClass db = new dbClass();
         if (txtRoomOwner.Text == "" || txtEmail.Text == "")
         {
             MessageBox.Show("Fill up all forms!");
         }
         else
         {
             if (checkDateIfExist() == false)
             {
                 System.Data.DataTable owner = db.dbSelect("SELECT * FROM client WHERE name='" + txtRoomOwner.Text + "'");
                 if (owner.Rows.Count == 0)
                 {
                     db.dbInsert("INSERT INTO client (name, email, phone) VALUES('" + txtRoomOwner.Text + "', '" + txtEmail.Text + "', '" + txtMobile.Text + "')");
                 }
                 else
                 {
                     db.dbUpdate("UPDATE client SET name = '" + txtRoomOwner.Text + "', email='" + txtEmail.Text + "', phone='" + txtMobile.Text + "' WHERE name='" + txtRoomOwner.Text + "'");
                 }
                 decimal percent = (decimal)0.70;
                 double  formula = Convert.ToDouble((noOfDays.Value * 2000) - (((noOfDays.Value * 2000) * percent)));
                 db.dbInsert("INSERT INTO room_ind (name, owner, reserveddate, email, phone, days, reference) VALUES('Room " + txtRoomId.Text + "', '" + txtRoomOwner.Text + "', '" + dateTimeFrom.Text + "', '" + txtEmail.Text + "', '" + txtMobile.Text + "', '" + noOfDays.Value + "', '" + this.reference + "')");
                 db.dbInsert("INSERT INTO reservelog (name, owner, reserveddate, email, phone, days, balance, reference) VALUES('Room " + txtRoomId.Text + "', '" + txtRoomOwner.Text + "', '" + dateTimeFrom.Text + "', '" + txtEmail.Text + "', '" + txtMobile.Text + "', '" + noOfDays.Value + "', '" + formula + "', '" + this.reference + "')");
                 showHide("client", false);
                 showHide("menu", true);
                 setRoomState();
                 getRoomsCount();
                 getCheckoutLog();
                 sendMail(txtRoomOwner.Text, txtEmail.Text, txtRoomId.Text, dateTimeFrom.Text, noOfDays.Value);
                 RecentCheckOutTab.Hide();
                 RecentCheckOutTab.Show();
                 MessageBox.Show("Room Reserved to " + txtRoomOwner.Text);
                 clearFields();
                 genReference();
             }
             else
             {
                 MessageBox.Show("Reservation date exist!");
             }
         }
     }
     else
     {
         MessageBox.Show("Enter valid email address!");
     }
 }
Esempio n. 11
0
        private void fetchClientInfo(int id)
        {
            dbClass db = new dbClass();

            this.clientInfo   = db.dbSelect("SELECT * FROM room WHERE id=" + id);
            dateTimeFrom.Text = this.clientInfo.Rows[0][4].ToString();
            txtRoomOwner.Text = this.clientInfo.Rows[0][2].ToString();
            txtEmail.Text     = this.clientInfo.Rows[0][5].ToString();
            txtMobile.Text    = this.clientInfo.Rows[0][6].ToString();
            labelRef.Text     = this.clientInfo.Rows[0]["reference"].ToString();
            try {
                noOfDays.Value = Convert.ToInt32(this.clientInfo.Rows[0][7]);
            } catch (InvalidCastException) {
                noOfDays.Value = 1;
            }
        }
Esempio n. 12
0
        private void getClientList()
        {
            try {
                dbClass db = new dbClass();
                System.Data.DataTable dt = db.dbSelect("SELECT name, email, phone FROM client ORDER BY id DESC");
                dataGridView1.DataSource = dt;
                dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView1.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                dataGridView1.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
                dataGridView1.Columns[0].ReadOnly = true;
                dataGridView1.Columns[1].ReadOnly = true;
                dataGridView1.Columns[2].ReadOnly = true;
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 13
0
        private bool checkDateIfExist()
        {
            dbClass db = new dbClass();

            System.Data.DataTable dt = db.dbSelect("SELECT reserveddate,name FROM room_ind");
            for (int x = 0; x < dt.Rows.Count; x++)
            {
                var date    = dt.Rows[x][0].ToString().Split(' ');
                var resdate = dateTimeFrom.Text.Split(' ');
                if (dt.Rows[x][1].ToString() == "Room " + txtRoomId.Text)
                {
                    if (date[1] == resdate[1])
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 14
0
        private void getLoginLog()
        {
            try {
                dbClass db = new dbClass();
                System.Data.DataTable dt = db.dbSelect("SELECT email, date, usertype FROM loginlog ORDER BY id DESC");
                dataGridView4.DataSource = dt;

                dataGridView4.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView4.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView4.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                dataGridView4.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
                dataGridView4.Columns[0].ReadOnly = true;
                dataGridView4.Columns[1].ReadOnly = true;
                dataGridView4.Columns[2].ReadOnly = true;
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 15
0
 private void User_Load(object sender, EventArgs e)
 {
     btnReg.Visible    = false;
     btnUpdate.Visible = false;
     btnDelete.Visible = false;
     if (this.edit == true)
     {
         btnUpdate.Visible = true;
         btnDelete.Visible = true;
         dbClass db = new dbClass();
         System.Data.DataTable user = db.dbSelect("SELECT * FROM security WHERE id=" + this.userid);
         txtFullName.Text = user.Rows[0][5].ToString();
         txtEmail.Text    = user.Rows[0][1].ToString();
         txtPassword.Text = user.Rows[0][2].ToString();
         cmbType.Text     = user.Rows[0][3].ToString();
     }
     else
     {
         btnReg.Visible = true;
     }
 }
Esempio n. 16
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Cancel", "Confirm", MessageBoxDefaultButton.Button1, MessageBoxIcon.Information);

            if (result.Equals(DialogResult.OK))
            {
                dbClass db = new dbClass();
                db.dbUpdate("UPDATE room SET owner = '', state='available', reserveddate='', email='', phone='', days=1 WHERE id=" + txtRoomId.Text);
                showHide("menu", true);
                showHide("client", false);
                setRoomState();
                getRoomsCount();
                getCheckoutLog();
                RecentCheckOutTab.Hide();
                RecentCheckOutTab.Show();
                MessageBox.Show("Room " + txtRoomId.Text + " is now available!");
            }
            else
            {
            }
        }
Esempio n. 17
0
        private void btnAvailable_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Checkout", "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (result.Equals(DialogResult.OK))
            {
                dbClass db = new dbClass();
                db.dbUpdate("UPDATE room SET owner = '', state='available', reserveddate='', email='', phone='', days=1, reference='' WHERE id=" + txtRoomId.Text);
                db.dbUpdate("UPDATE reservelog SET state='checkout', checkoutdate='" + getDateTime() + "' WHERE reference='" + labelRef.Text + "'");
                showHide("menu", true);
                showHide("client", false);
                setRoomState();
                getRoomsCount();
                getCheckoutLog();
                RecentCheckOutTab.Hide();
                RecentCheckOutTab.Show();
                MessageBox.Show("Room " + txtRoomId.Text + " is now available!");
            }
            else
            {
            }
        }
Esempio n. 18
0
        private void UserGridView_Load(object sender, EventArgs e)
        {
            try {
                dbClass db = new dbClass();
                System.Data.DataTable dt = db.dbSelect("SELECT id, fullname, email, password, usertype FROM security");
                dataGridView1.DataSource = dt;
                dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView1.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView1.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView1.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                dataGridView1.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
                dataGridView1.Columns[0].ReadOnly = true;
                dataGridView1.Columns[1].ReadOnly = true;
                dataGridView1.Columns[2].ReadOnly = true;
                dataGridView1.Columns[3].ReadOnly = true;
                dataGridView1.Columns[4].ReadOnly = true;
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }