コード例 #1
0
        private void PeopleTable_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var serv = new PeopleService();

            switch (e.CommandName)
            {
            case "update":
                var updatedPeople = serv.GetPeople(Convert.ToInt32(e.CommandArgument));
                NameBox.Text   = Convert.ToString(updatedPeople.Name);
                HeightBox.Text = Convert.ToString(updatedPeople.Height);
                WeightBox.Text = Convert.ToString(updatedPeople.Weight);
                IdBox.Text     = Convert.ToString(updatedPeople.Id);
                break;

            case "delete":
                serv.DelPeople(Convert.ToInt32(e.CommandArgument));
                break;

            default:
                break;
            }

            //Refresh data
            PeopleTable.DataSource = serv.GetPeoples();
            PeopleTable.DataBind();
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: pijuskri/StockExchangeRivised
        public void UpdateUI()
        {
            var timeNow = DateTime.Now;

            if ((DateTime.Now - previousTime).Milliseconds <= 50)
            {
                return;
            }

            synchronizationContext.Post(new SendOrPostCallback(o =>
            {
                PopulateCompanyTable();
                PopulateResourceTable();

                PeopleTable.RowCount = ic.AIList.Count + 1;
                PeopleTable.Invalidate();

                if (ShareSaleTable.Visible)
                {
                    PopulateShareSaleTable();
                }

                BankTable.RowCount = ic.bankList.Count + 1;
                BankTable.Invalidate();

                UpdateChart();

                LabourCost.Text = "" + Math.Round(ic.population.labourCost, 3);
                Population.Text = "" + ic.population.people;
                PrintToConsole();
            }), value);

            previousTime = timeNow;
        }
コード例 #3
0
        public List <T> GetPersonByName(PeopleTable profession, string lastName, string firstname)
        {
            if (lastName == null)
            {
                Log.MakeLog(LoggerOperations.Error, "ArgumentNullException");
                throw new ArgumentNullException(nameof(lastName));
            }

            if (firstname == null)
            {
                Log.MakeLog(LoggerOperations.Error, "ArgumentNullException");
                throw new ArgumentNullException(nameof(firstname));
            }
            using (IDbConnection connection = new SqlConnection(GetConnectionString()))
            {
                string prefix = profession == PeopleTable.Students ? "St_" : "Le_";

                var p = new DynamicParameters();
                p.Add("@FirstName", firstname);
                p.Add("@LastName", lastName);

                string queryLastName        = $"select * from dbo.{profession} where {prefix}Last_Name = @LastName";
                string queryNameAndLastName = $"select * from dbo.{profession} where {prefix}First_Name = @FirstName and {prefix}Last_Name = @LastName";

                string query = (lastName != null && firstname != null) ? queryNameAndLastName : queryLastName;

                var output = connection.Query <T>(query, p).ToList();
                return(output);
            }
        }
コード例 #4
0
        protected void PageLoad(object sender, EventArgs e)
        {
            var serv   = new PeopleService();
            var people = serv.GetPeoples();

            PeopleTable.DataSource = people;
            PeopleTable.DataBind();
        }
コード例 #5
0
        protected void CreateOrUpdateMethod(object sender, EventArgs e)
        {
            var serv = new PeopleService();

            if (string.IsNullOrEmpty(IdBox.Text))
            {
                serv.AddPeople(NameBox.Text, Convert.ToInt32(WeightBox.Text), Convert.ToInt32(HeightBox.Text));
            }
            else
            {
                serv.SetPeople(Convert.ToInt32(IdBox.Text), NameBox.Text, Convert.ToInt32(WeightBox.Text), Convert.ToInt32(HeightBox.Text));
            }

            NameBox.Text   = string.Empty;
            WeightBox.Text = string.Empty;
            HeightBox.Text = string.Empty;
            IdBox.Text     = string.Empty;

            //Refresh data
            PeopleTable.DataSource = serv.GetPeoples();
            PeopleTable.DataBind();
        }
コード例 #6
0
 public PersonRepository(PeopleTable table) : base((Tables)table)
 {
 }