Exemplo n.º 1
0
        public List <MemberWithShoping> GetShopingList(string date)
        {
            connection = new SqlConnection(connectionString);
            connection.Open();
            query =
                "SELECT Shoping.ShopingId,Shoping.Cost, CONVERT(date, Shoping.Date) as Date , Shoping.MemberId,Members.Name FROM Shoping join Members on Members.MemberId=Shoping.MemberId where MONTH(date)='" + date + "' order by Shoping.Date";
            command = new SqlCommand(query, connection);
            reader  = command.ExecuteReader();
            List <MemberWithShoping> shopingList = new List <MemberWithShoping>();

            while (reader.Read())
            {
                MemberWithShoping memberWithShoping = new MemberWithShoping();
                memberWithShoping.ShopingId  = (int)reader["ShopingId"];
                memberWithShoping.Cost       = (int)reader["Cost"];
                memberWithShoping.Date       = (DateTime)reader["Date"];
                memberWithShoping.MemberId   = (int)reader["MemberId"];
                memberWithShoping.MemberName = (string)reader["Name"];

                shopingList.Add(memberWithShoping);
            }

            reader.Close();
            connection.Close();
            return(shopingList);
        }
Exemplo n.º 2
0
        private void shopingListView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ListViewItem shopingListSelected = shopingListView.SelectedItems[0];

            MemberWithShoping memberWithShoping = (MemberWithShoping)shopingListSelected.Tag;

            nameComboBox.Text          = memberWithShoping.MemberName;
            shopingDateTimePicker.Text = memberWithShoping.Date.ToString();
            costTextBox.Text           = memberWithShoping.Cost.ToString();

            saveButton.Text      = "Update";
            removeButton.Enabled = true;
        }