Example #1
0
        void UpdateDgv()
        {
            //get all stuff
            GetCities();
            GetShipments();
            GetSenders();
            GetPayments();
            GetRecipients();
            GetShipmentTypes();
            GetPaymentTypes();
            GetUsers();
            GetRequests();

            DataTable dt = new DataTable();

            dt.TableName = "Список клиентов";
            dt.Columns.Add("Ф.И.О. отправителя");
            dt.Columns.Add("Город отправления");
            dt.Columns.Add("Тип доставки");
            dt.Columns.Add("Тип отправления");
            dt.Columns.Add("Ф.И.О. получателя");
            dt.Columns.Add("Город получателя");
            dt.Columns.Add("№ заявки");

            Sender       s;
            ShipmentType st;
            Payment      p;

            for (int i = 0; i < requests.Count; i++)
            {
                s  = new Sender();
                p  = new Payment();
                st = new ShipmentType();

                p  = payments.Find(x1 => x1.id == shipments.Find(x2 => x2.id == requests[i].idS).idP);
                s  = senders.Find(x => x.id == requests[i].idC);
                st = shTypes.Find(x => x.id == p.idSt);
                dt.Rows.Add(new object[]
                {
                    s.name,
                    s.city,
                    st.type,
                    shipments.Find(x => x.idP == p.id).type,
                    recipients.Find(x => x.id == requests[i].idR).name,
                    recipients.Find(x => x.id == requests[i].idR).city,
                    requests[i].id
                });
            }

            //bind
            dgv_clients.DataSource = dt;
        }
Example #2
0
        void GetShipmentTypes()
        {
            shTypes.Clear();
            ShipmentType t;

            cmd.CommandText = "select * from type";

            Open();
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                t      = new ShipmentType();
                t.id   = (int)reader[0];
                t.type = reader[1].ToString();

                shTypes.Add(t);
            }
            reader.Close();

            c.Close();
        }