예제 #1
0
        public void initializeData()
        {
            try
            {
                conn.Open();
                MySqlCommand     comm = new MySqlCommand("SELECT * FROM room WHERE id =" + roomId, conn);
                MySqlDataAdapter adp  = new MySqlDataAdapter(comm);
                DataTable        dt   = new DataTable();
                adp.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    txtRoomNumber.Text = dt.Rows[0]["roomNumber"].ToString();
                    roomTypeId         = dt.Rows[0]["roomTypeId"].ToString();
                    cmbFloor.Text      = dt.Rows[0]["floorLevel"].ToString();
                    txtDesc.Text       = dt.Rows[0]["description"].ToString();
                }

                conn.Close();
            }
            catch (Exception ee)
            {
                MessageBox.Show("Nah!" + ee);
                conn.Close();
            }
            RoomDataService myRoomDataServ = new RoomDataService();

            RoomTypeInfo lesbian = new RoomTypeInfo();

            MessageBox.Show(roomTypeId.ToString());
            //string why =
            lesbian = myRoomDataServ.getRoomTypeByInt(Convert.ToInt32(roomTypeId));
            MessageBox.Show(lesbian.TypeName);
            cmbRoomType.Text = lesbian.TypeName;
        }
예제 #2
0
        private void cmbRoomTypes_SelectedIndexChanged(object sender, EventArgs e)
        {
            RoomDataService myRoomDataService = new RoomDataService();
            RoomTypeInfo    myRoomTypeInfo    = new RoomTypeInfo();

            myRoomTypeInfo = myRoomDataService.getRoomTypeByName(cmbRoomTypes.Text);
            TypeId         = myRoomTypeInfo.TypeId;
        }
예제 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            RoomDataService testRoom = new RoomDataService();

            testRoom.AddRoomRate(TypeId, txtRoomRate.Text);
            referencefrm1.LoadComboRoomRates();
            this.Close();
        }
예제 #4
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            EditRoom        addRoom    = new EditRoom();
            RoomDataService roomData   = new RoomDataService();
            RoomInfo        myRoomInfo = new RoomInfo();

            addRoom.RoomId = RoomId;
            //myRoomInfo = roomData.getRoomInfoById(RoomId);
            //addRoom.SettingRoomInfo(myRoomInfo);
            addRoom.referenceViewRoomList = this;
            addRoom.Show();
            this.Hide();
        }
예제 #5
0
        public int verifyCustomerInfoAndCreateReservation(CustomerInfo Customer, ReservationInfo ResNow, ReservationCalendarForm calendar)
        {
            string query = "SELECT * FROM customer WHERE name=@name";

            using (MySqlCommand cmd = new MySqlCommand(query, conn))
            {
                // Execute Scalar returns the first column of the first row
                cmd.Parameters.AddWithValue("@name", Customer.Name);
                conn.Open();
                int CustomerExists = Convert.ToInt32(cmd.ExecuteScalar());
                if (CustomerExists > 0)
                {
                    MessageBox.Show("customer with the same name exist please choose " +
                                    "another name");
                }
                else
                {
                    // user clicked no
                    try
                    {
                        CustomerDataService customerData = new CustomerDataService();
                        //insert into customer

                        long lastInsertedCustomer = customerData.InsertIntoCustomer(Customer.Name, Customer.Company, Customer.Address, Customer.Phone, Customer.Email, Customer.Passport, Customer.Nationality, Customer.Gender, Customer.BirthDate, Customer.BirthPlace, Customer.Comment);
                        ResNow.CustomerId = Convert.ToInt32(lastInsertedCustomer);
                        long lastInsertReservation = AddReservation(Convert.ToInt32(ResNow.RoomId), ResNow.CustomerId, ResNow.Desc, ResNow.StartDate, ResNow.EndDate, 0, ResNow.TotalPrice, ResNow.LenghtOfStay, ResNow.RoomRate);
                        if ((ResNow.StartDate.Year == ResNow.EndDate.Year) && (ResNow.StartDate.Month == ResNow.EndDate.Month))
                        {
                            //ReservationCalendarForm calendar = new ReservationCalendarForm();
                            RoomDataService roomDataService = new RoomDataService();
                            RoomInfo        selectedRoom    = new RoomInfo();


                            selectedRoom = roomDataService.getRoomInfoById(Convert.ToInt32(ResNow.RoomId));
                            string myRoomId = selectedRoom.RoomId;
                            calendar.findFirstcell(ResNow.StartDate, ResNow.EndDate, lastInsertReservation, ResNow.RoomId);
                            //calendar.createb(
                        }
                        MessageBox.Show(lastInsertReservation.ToString() + "last inserted");
                        return(Convert.ToInt32(lastInsertReservation));
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                MessageBox.Show("not good");
                return(0);
            }
        }
예제 #6
0
        private void LoadRoomTypeCombo()
        {
            //get combo box items
            // filter by type
            //ComboBox hello = elementHOs
            List <string> myRooms = new List <string>();

            RoomDataService myRoomDataService = new RoomDataService();

            myRooms = myRoomDataService.getRoomTypes();
            foreach (var item in myRooms)
            {
                cmbRoomTypes.Items.Add(item);
            }
            //RoomDataService
        }
예제 #7
0
파일: AddRoom.cs 프로젝트: ainzbedo1/SAD-2
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (CheckingFields() == false)
            {
                RoomDataService testRoom = new RoomDataService();
                testRoom.AddRoom(txtRoomNumber.Text, RoomTypeId, cmbFloor.Text, txtDesc.Text);
                referenceViewRoomList.Refresh();

                referenceViewRoomList.refreshing();
                referenceViewRoomList.DisableButtons();
                referenceViewRoomList.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("There are missing fields please fill them up");
            }
        }
예제 #8
0
        // private ReservationCalendarForm _formtriggrer;


        public ReservationDataPresenter(AddReservationView form, RoomDataService roomService)
        {
            _form = form;
            //_formtriggrer = form;C:\Users\Jarrod\Documents\dumpsC:\Users\Jarrod\Documents\dumps
            //_form.OnShowReservationInfo += View_OnShowReservationInfo;

            _service = roomService;
            var info = _service.getRoomInfoByRoomNumber(_form.myRoomNum);

            if (info == null)
            {
                MessageBox.Show("Could not find an account for specified number.");
                return;
            }

            _form.RoomNumber = info.RoomNumber;
            _form.RoomType   = info.RoomType;
            _form.RoomId     = info.RoomId;
        }
예제 #9
0
        public DataTable Occupancy(DateTime startOnDgv, DateTime endOnDgv)
        {
            ReservationDataService reservationDataService = new ReservationDataService();
            List <ReservationInfo> myReservationList      = reservationDataService.ShowAllRes(startOnDgv, endOnDgv);
            ReservationInfo        me = myReservationList[1];
            RoomDataService        myRoomDataService = new RoomDataService();
            int amtOfRooms      = myRoomDataService.GetAmtRooms();
            int days            = DateTime.DaysInMonth(endOnDgv.Year, endOnDgv.Month);
            int potentialNights = amtOfRooms * days;
            //MessageBox.Show("My amount of rooms" + amtOfRooms.ToString());
            // THe feilds we want a  room.roomNumber, totalRoomNIghts of all, potentialNights
            // totalRoom nights of all is equal to filter running total of calc days
            // potentailnights is equal to daysInMonth * amtOfRooms
            // amtOfrooms is to mysql count(*)
            //
            string query = "SELECT id, roomNumber from sad2_db.room";

            DataTable dt = new DataTable();

            using (MySqlCommand cmd = new MySqlCommand(query, conn))
            {
                cmd.Parameters.AddWithValue("@end", endOnDgv);
                cmd.Parameters.AddWithValue("@start", startOnDgv);
                try
                {
                    conn.Open();
                    using (MySqlDataAdapter sda = new MySqlDataAdapter(cmd))
                    {
                        sda.Fill(dt);
                        dt.Columns.Add("TotRoomNights", typeof(Int32));
                        dt.Columns.Add("PotentNights", typeof(Int32));
                        dt.Columns.Add("OccPer", typeof(String));



                        int roomNightsMonth = 0;
                        //dt.Columns.Add("CalcDays", typeof(Int32));
                        int theHell = 0;
                        for (int i = 0; i < amtOfRooms; i++)
                        {
                            for (int x = 0; x < myReservationList.Count; x++)
                            {
                                dt.Columns["TotRoomNights"].DefaultValue = 0;
                                //dt.Columns["Occupancy"].
                                List <string> computeValues = FilterResForMsr(myReservationList[x], startOnDgv, endOnDgv);
                                if (Convert.ToInt32(computeValues[2]) == Convert.ToInt32(dt.Rows[i][0]))
                                {
                                    dt.Columns["TotRoomNights"].DefaultValue = 0;

                                    //Convert.ToInt32(dt.Rows[0]["field_name"]);

                                    theHell += Convert.ToInt32(computeValues[0]);
                                    dt.Rows[i]["TotRoomNights"] = theHell;
                                    //dt.Rows[i]["TotRoomNights"] = Convert.ToInt32(computeValues[0]) + Convert.ToInt32(dt.Rows[i]["TotRoomNights"]);
                                }
                            }
                            theHell = 0;
                            dt.Rows[i]["PotentNights"] = potentialNights;

                            /*
                             * roomNightsMonth += Convert.ToInt32(computeValues[0]);
                             * MessageBox.Show(roomNightsMonth.ToString());
                             */
                        }
                        foreach (DataRow items in dt.Rows)
                        {
                            if (items[2] == DBNull.Value)
                            {
                                items[2] = 0;
                            }
                        }
                        foreach (DataRow items in dt.Rows)
                        {
                            decimal roomNights = Math.Round(((Convert.ToDecimal(items["TotRoomNights"]) / potentialNights) * 100), 2);
                            string  format     = roomNights.ToString() + (" %");
                            //MessageBox.Show((Convert.ToDouble(items["TotRoomNights"]) / potentialNights).ToString());

                            items["OccPer"] = format;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString() + "Filter reservations failed");
                    return(null);
                }
            }
            return(dt);
        }