예제 #1
0
        private Boolean Save()
        {
            GlobalFunctions.resetError();

            if (checkFields())
            {
                fillEntity();

                SynapseCore.Database.DBFunction.StartTransaction();
                try
                {
                    _entity.save();

                    SynapseCore.Database.DBFunction.CommitTransaction();

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                    return(true);
                }
                catch (Exception ex)
                {
                    SynapseCore.Database.DBFunction.RollbackTransaction();
                    GlobalFunctions.showMessage("ERR", "RoomPicker.Err.9999", ex.Message);
                    return(false);
                }
            }
            else
            {
                GlobalFunctions.showError();
                return(false);
            }
        }
예제 #2
0
        //-------------------------------------------------------------------
        // Get the ID of the encoded Room or create a new one if it does not exists
        //-------------------------------------------------------------------
        public Int64 GetRoomID()
        {
            string Code = txRoom.Text.Trim().ToUpper();

            if (Code != string.Empty && cbBuilding.SelectedItem != null && ((RoomPicker_Building)cbBuilding.SelectedItem).ID != 0)
            {
                RoomPicker_Building _bd = (RoomPicker_Building)cbBuilding.SelectedItem;
                RoomPicker_Room     _rm = RoomPicker_Room.Load("WHERE UPPER(CODE)='" + Code + "' AND FK_BUILDING=" + _bd.ID).FirstOrDefault();
                if (_rm == null || _rm.ID == 0)
                {
                    if (_AllowNewRoom)
                    {
                        SynapseCore.Database.DBFunction.StartTransaction();
                        try
                        {
                            RoomPicker_Room newRoom = new RoomPicker_Room();
                            newRoom.CODE        = Code;
                            newRoom.NAME        = _bd.CODE + Code;
                            newRoom.FK_BUILDING = _bd.ID;
                            newRoom.AVAILABLE   = true;
                            newRoom.FK_MODULE   = _ModuleID;
                            newRoom.SITE        = _SiteCode;

                            newRoom.save();

                            SynapseCore.Database.DBFunction.CommitTransaction();

                            return(newRoom.ID);
                        }
                        catch (Exception ex)
                        {
                            SynapseCore.Database.DBFunction.RollbackTransaction();
                            GlobalFunctions.showMessage("ERR", "Err.9999", ex.Message);
                            return(0);
                        }
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    return(_rm.ID);
                }
            }
            else
            {
                return(0);
            }
        }