Exemple #1
0
    public static void ShowInfo(int num)
    {
        province.text   = "Province: " + GameController.tile[num].Name;
        type.text       = "Type: " + GameController.tile[num].Type;
        production.text = "Production: " + GameController.tile[num].ProvinceProduction.ToString();
        numshown        = num;

        if (GameController.tile[num].City != null)
        {
            settlementName.text     = "City: " + GameController.tile[num].City.Name;
            settlementPeople.text   = "People: " + GameController.tile[num].City.People["All"];
            buildings.active        = true;
            createsettlement.active = false;
        }
        else
        {
            settlementName.text     = "";
            settlementPeople.text   = "";
            buildings.active        = false;
            createsettlement.active = true;
            if (GameController.tile[num].Travellers < Constants.PeopleToSettle)
            {
                createsettlement.GetComponent <Button>().interactable = false;
            }
            else
            {
                createsettlement.GetComponent <Button>().interactable = true;
            }
        }


        GameController.UpdateInfo();
        Travellers.Upd();
    }
Exemple #2
0
        public async Task <Travellers> FindByIdAsync(params object[] values)
        {
            Travellers entity = new Travellers();

            try
            {
                SqlConnection con = Open();
                SqlCommand    cmd = con.CreateCommand();
                cmd.CommandText = $"SELECT * FROM {TABLE} WHERE ID_Travellers = {values[0]};";
                var dr = await cmd.ExecuteReaderAsync();

                while (dr.Read())
                {
                    entity = GetEntityFromDataReader(dr);
                }
                dr.Close();
                cmd.Dispose();
                Close(con);
                return(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
0
        public async Task <Travellers> UpdateAsync(Travellers entity, params object[] Id)
        {
            try
            {
                var con = await OpenAsync();

                SqlCommand cmd = con.CreateCommand();
                cmd.CommandText = $"UPDATE {TABLE} SET TX_FirstName = '{entity.TX_FirstName}', TX_SecondName = '{entity.TX_SecondName}', " +
                                  $"TX_LastName = '{entity.TX_LastName}',  TX_SecondLastName = '{entity.TX_SecondLastName}', TX_Phone = '{entity.TX_Phone}', " +
                                  $"TX_IdentificationCard = '{entity.TX_IdentificationCard}', TX_Address = '{entity.TX_Address}' " +
                                  $"WHERE ID_Travellers = { entity.ID_Travellers }";
                await cmd.ExecuteNonQueryAsync();

                Close(con);
                return(entity);
            }
            catch (SqlException ex) when(ex.Number == 2627)
            {
                throw new UniqueKeyException($"{TAG}: {ex.Message}");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #4
0
        public BookFlightRQBody Clone()
        {
            var result = new BookFlightRQBody();

            result.FlightID = FlightID;

            if (Travellers != null)
            {
                result.Travellers = new TravellerList(Travellers.Select(t => t.Copy()));
            }

            if (DataItems != null)
            {
                result.DataItems = new PNRDataItemList(DataItems.Select(di => di.Copy()));
            }

            result.AdditionalActions = AdditionalActions?.Copy();
            result.PricingOptions    = PricingOptions?.Clone();

            if (AncillaryServices != null)
            {
                result.AncillaryServices = new AncillaryServices <AncillaryServiceRQ>(AncillaryServices.Select(s => s.Copy()));
            }

            if (RequestorTags != null)
            {
                result.RequestorTags = new TagList(RequestorTags);
            }

            result.RefererID = RefererID;

            return(result);
        }
Exemple #5
0
        protected void btnSignup_Click(object sender, EventArgs e)
        {
            //string hashPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordTB.Text, "MD5");
            string name       = nameTb.Text;
            string email      = EmailTB.Text;
            string password   = PasswordTB.Text;
            string cfmPasswod = cfmPasswordTB.Text;

            lblalert.Text = String.Empty;

            if (name == "")
            {
                lblalert.Text     += "Name is required <br>";
                lblalert.ForeColor = Color.Red;
            }
            if (email == "")
            {
                lblalert.Text     += "Email is required <br>";
                lblalert.ForeColor = Color.Red;
            }
            if (password == "")
            {
                lblalert.Text     += "Password is required <br>";
                lblalert.ForeColor = Color.Red;
            }
            if (cfmPasswod == "")
            {
                lblalert.Text     += "Confirm Password is required <br>";
                lblalert.ForeColor = Color.Red;
            }
            else
            {
                if (cfmPasswod != password)
                {
                    lblalert.Text       = "Password does not match!";
                    lblalert.ForeColor  = Color.Red;
                    alertDanger.Visible = true;
                }
                else
                {
                    Travellers user   = new Travellers(name, password, email);
                    int        result = user.AddNewUser();
                    if (result == 1)
                    {
                        lblSuccess.Text      = "User created";
                        lblSuccess.ForeColor = Color.Green;
                        alertSuccess.Visible = true;

                        Response.Redirect("Login.aspx");
                    }
                    else
                    {
                        lblalert.Text       = "Unable to create a user";
                        lblalert.ForeColor  = Color.Red;
                        alertDanger.Visible = true;
                    }
                }
            }
        }
 public static void NewTurn()
 {
     turn++;
     UpdatePeople();
     ResourcesAdd();
     Travellers.Move();
     DecisionHandler();
     if (currentproject == null)//WTFFFFFF
     {
         currentproject.Contribute();
     }
     UpdateInfo();
 }
        public async Task Delete(int id)
        {
            try
            {
                Travellers entity = await TravellersRepository.FindByIdAsync(id);

                TravellersRepository.Remove(entity);
            }
            catch (DeleteWithRelationshipException ex)
            {
                throw new Exception("The record you are trying to delete is related to another");
            }
            catch (Exception ex)
            {
                throw new Exception("Have ocurred an error to delete");
            }
        }
Exemple #8
0
 public void Remove(Travellers entity)
 {
     try
     {
         var        con = Open();
         SqlCommand cmd = con.CreateCommand();
         cmd.CommandText = $"DELETE FROM {TABLE} WHERE ID_Travellers = {entity.ID_Travellers};";
         cmd.ExecuteNonQuery();
         Close(con);
     }
     catch (SqlException ex) when(ex.Number == 1451)
     {
         throw new DeleteWithRelationshipException($"{TAG}: {ex.Message}");
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public async Task Save(Travellers entity)
 {
     try
     {
         if (entity.ID_Travellers == 0)
         {
             await TravellersRepository.Add(entity);
         }
         else
         {
             await TravellersRepository.UpdateAsync(entity);
         }
     }
     catch (UniqueKeyException ex)
     {
         throw new Exception("Cannot insert or update a value duplicate" + ex);
     }
     catch (Exception ex)
     {
         throw new Exception("Cannot add a register" + ex);
     }
 }
Exemple #10
0
        public async Task Add(Travellers entity)
        {
            try
            {
                var con = await OpenAsync();

                SqlCommand cmd = con.CreateCommand();
                cmd.CommandText = $"INSERT INTO {TABLE} (TX_FirstName, TX_SecondName, TX_LastName, TX_SecondLastName, TX_Phone, TX_IdentificationCard,TX_Address) " +
                                  $"VALUES ('{entity.TX_FirstName}','{entity.TX_SecondName}', '{entity.TX_LastName}', '{entity.TX_SecondLastName}', '{entity.TX_Phone}', '{entity.TX_IdentificationCard}', '{entity.TX_Address}');";
                await cmd.ExecuteNonQueryAsync();

                Close(con);
            }
            catch (SqlException ex) when(ex.Number == 2627)
            {
                throw new UniqueKeyException($"{TAG}: {ex.Message}");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #11
0
        public int Insert(Travellers u)
        {
            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            string sqlStmt = "INSERT INTO Travellers (Username,Password,Email) " +
                             "VALUES (@paraName,@paraPassword, @paraEmail)";

            int        result = 0; // Execute NonQuery return an integer value
            SqlCommand sqlCmd = new SqlCommand(sqlStmt, myConn);

            sqlCmd.Parameters.AddWithValue("@paraName", u.Name);
            sqlCmd.Parameters.AddWithValue("@paraPassword", u.Password);
            sqlCmd.Parameters.AddWithValue("@paraEmail", u.Email);


            myConn.Open();
            result = sqlCmd.ExecuteNonQuery();

            myConn.Close();

            return(result);
        }
    public static void Upd()
    {
        corpus = GameController.tile[TileInfo.numshown].City.Buildings;
        crew   = GameController.tile[TileInfo.numshown].City.People;

        bool[] clickablebutton = new bool[] { true, true, true, true, true, true, true, true, true, true };

        if (crew.Idle == 0)
        {
            clickablebutton[0] = false;
            clickablebutton[3] = false;
            clickablebutton[6] = false;
        }


        if (corpus.WorkedSawmill == corpus.SawmillWorkPlaces)
        {
            clickablebutton[0] = false;
        }
        if (corpus.WorkedMine == corpus.MineWorkPlaces)
        {
            clickablebutton[3] = false;
        }
        if (corpus.WorkedHuntHouse == corpus.HuntHouseWorkPlaces)
        {
            clickablebutton[6] = false;
        }

        if (corpus.WorkedSawmill == 0)
        {
            clickablebutton[1] = false;
        }

        if (corpus.WorkedMine == 0)
        {
            clickablebutton[4] = false;
        }

        if (corpus.WorkedHuntHouse == 0)
        {
            clickablebutton[7] = false;
        }

        if (!(GameController.resources > Constants.Cost("Sawmill")))
        {
            clickablebutton[2] = false;
        }

        if (!(GameController.resources > Constants.Cost("Mine")))
        {
            clickablebutton[5] = false;
        }

        if (!(GameController.resources > Constants.Cost("HuntHouse")))
        {
            clickablebutton[8] = false;
        }

        if (!(GameController.resources > Constants.Cost("House")))
        {
            clickablebutton[9] = false;
        }


        GameObject.Find("Sawmill/AddWorker").GetComponent <Button>().interactable      = clickablebutton[0]; //0
        GameObject.Find("Sawmill/RemoveWorker").GetComponent <Button>().interactable   = clickablebutton[1]; //1
        GameObject.Find("Sawmill/AddBuilding").GetComponent <Button>().interactable    = clickablebutton[2]; //2
        GameObject.Find("Mine/AddWorker").GetComponent <Button>().interactable         = clickablebutton[3]; //3
        GameObject.Find("Mine/RemoveWorker").GetComponent <Button>().interactable      = clickablebutton[4]; //4
        GameObject.Find("Mine/AddBuilding").GetComponent <Button>().interactable       = clickablebutton[5]; //5
        GameObject.Find("HuntHouse/AddWorker").GetComponent <Button>().interactable    = clickablebutton[6]; //6
        GameObject.Find("HuntHouse/RemoveWorker").GetComponent <Button>().interactable = clickablebutton[7]; //7
        GameObject.Find("HuntHouse/AddBuilding").GetComponent <Button>().interactable  = clickablebutton[8]; //8
        GameObject.Find("House/AddBuilding").GetComponent <Button>().interactable      = clickablebutton[9]; //9

        SetShownInfo("House");
        SetShownInfo("Sawmill");
        SetShownInfo("Mine");
        SetShownInfo("HuntHouse");

        Travellers.Upd();
    }