예제 #1
0
        private void _setMode(string mode, bool save)
        {
            if (save && _current != null)
            {
                _current.Name       = textName.Text;
                _current.RoomTypeId = textRoomCode.Text;

                try
                {
                    _current.DirsId = Int32.Parse(textDirsID.Text);
                }
                catch
                {
                    textDirsID.Text = "Fehler: " + textDirsID.Text;
                }

                try
                {
                    _current.DirsIdPrice = Int32.Parse(textDirsIdPrice.Text);
                }
                catch
                {
                    textDirsIdPrice.Text = "Fehler: " + textDirsIdPrice.Text;
                }

                try
                {
                    _current.DefaultPersons = Int32.Parse(textPersons.Text);
                }
                catch
                {
                    textPersons.Text = "Fehler: " + textPersons.Text;
                }

                if (_mode == "new")
                {
                    _rooms.Add(_current);
                }

                _createList();
            }

            _mode = mode;
            bool enable = false;

            switch (_mode)
            {
            case "idle":
                enable = false;
                break;

            case "new":
                _current = new RoomType();
                enable   = true;
                break;

            case "edit":
                if (listRooms.SelectedItems.Count > 0)
                {
                    _current = (RoomType)listRooms.SelectedItems[0].Tag;
                }

                if (_current != null)
                {
                    enable = true;
                }
                break;
            }

            groupEdit.Enabled = enable;
            cmdNew.Enabled    = !enable;
            cmdEdit.Enabled   = !enable;
            listRooms.Enabled = !enable;

            if (_current != null)
            {
                textName.Text        = _current.Name;
                textRoomCode.Text    = _current.RoomTypeId;
                textDirsID.Text      = _current.DirsId.ToString();
                textDirsIdPrice.Text = _current.DirsIdPrice.ToString();
                textPersons.Text     = _current.DefaultPersons.ToString();
            }
        }
예제 #2
0
        public static void RunReset()
        {
            try
            {
                StatusInfo.StatusRunning  = true;
                StatusInfo.StatusGroup    = "Daten zurücksetzen...";
                StatusInfo.StatusLabel    = "Datenbank leeren.";
                StatusInfo.StatusProgress = -1;

                DayAva.SaveAll(
                    new Dictionary <string, DayAva>()
                    );
                OnlineBooking.LastUpdate = DateTime.MinValue;

                DataTable table = Program.AddIn.Query(
                    String.Format(@"
                                SELECT
                                    price.KP_PREIS as price,
                                    price.KP_FROM as date_from,
                                    price.KP_TO as date_to,
                                    roomtype.ZT_KURZ as roomtype_id,
                                    roomtype.ZT_BEZ as roomtype_name
                                FROM
                                    o_zimmertyp as roomtype,
                                    o_katgoriepreis as price
                                WHERE
                                    roomtype.rowid = KP_ZIMMERTYP AND
                                    (CASE
                                        {0}
                                    END)",
                                  String.Join(
                                      "\n",
                                      RoomType.ReadAll().Select(
                                          t => String.Format(
                                              "WHEN roomtype.ZT_KURZ = '{0}' THEN price.KP_PERSON_FROM = {1}",
                                              t.RoomTypeId,
                                              t.DefaultPersons
                                              )
                                          ).ToArray()
                                      )
                                  )
                    );

                int    i      = 0;
                int    c      = table.Rows.Count;
                int    knr    = Settings.GetSetting <int>("dirs21.knr");
                string pwd    = Settings.GetSetting <string>("dirs21.pwd");
                var    dirs21 = new HotelAddInApp.dirs21.DIRS21PMSInterface();

                foreach (DataRow row in table.Rows)
                {
                    StatusInfo.StatusLabel    = row["roomtype_name"].ToString() + " wird zurückgesetzt.";
                    StatusInfo.StatusProgress = (int)((100.0f / c) * i);

                    try
                    {
                        RoomType type  = RoomType.ReadAll().First(t => t.RoomTypeId == (string)row["roomtype_id"]);
                        double   price = ((double)row["price"] + Settings.GetSetting <double>("dirs21.breakfast")) * type.DefaultPersons;

                        dirs21.WriteAvailabilitiesPricesMinstay(
                            knr,
                            pwd,
                            type.DirsIdPrice,
                            ((DateTime)row["date_from"]).ToString("dd.MM.yyyy"),
                            ((DateTime)row["date_to"]).ToString("dd.MM.yyyy"),
                            RoomCount.GetCount(type.DirsId),
                            (float)price,
                            1
                            );
                    }
                    catch (Exception ex)
                    {
                        StatusInfo.WriteLine("Zimmertype konnte nicht zurückgesetzt werden.\n\nFehler: " + ex.Message);
                    }

                    i++;
                }

                dirs21.Dispose();

                StatusInfo.StatusRunning = false;
                StatusInfo.WriteLine("Daten zurückgesetzt");
            }
            finally
            {
                _thread = null;

                RunThreadWriteAsk();
            }
        }
예제 #3
0
 private void formConfigRooms_FormClosing(object sender, FormClosingEventArgs e)
 {
     RoomType.SaveAll(_rooms);
 }