コード例 #1
0
        //Show Flow layout with orders
        private void btnServiceFind_Click(object sender, EventArgs e)
        {
            var services = new List <Service>();

            flwServicesList.Controls.Clear();

            using (SqlConnection connection = new SqlConnection(@"Data Source=GSZWEDPC\SQLEXPRESS;Initial Catalog=WeddingManagmentDB;Integrated Security=True"))
            {
                connection.Open();
                var            command   = @"SELECT Name FROM ServiceTable";
                SqlDataAdapter adapter   = new SqlDataAdapter(command, connection);
                DataTable      dataTable = new DataTable();
                connection.Close();
                adapter.Fill(dataTable);
                if (dataTable.Rows.Count > 0)
                {
                    foreach (DataRow row in dataTable.Rows)
                    {
                        services.Add(new Service((string)row[0]));
                    }
                }
            }

            var amount = services.Count;

            CntrlService[] cntrls = new CntrlService[amount];
            for (int i = 0; i < cntrls.Length; i++)
            {
                cntrls[i] = TransformServiceToCntrl(new CntrlService(employee.GetPermission()), services[i]);
            }
            flwServicesList.Controls.AddRange(cntrls);
            DashboardPanels[2].BringToFront();
        }
コード例 #2
0
 //Transform Object Service to Cntrl
 private CntrlService TransformServiceToCntrl(CntrlService cntrl, Service service)
 {
     if (cntrl != null && service != null)
     {
         cntrl.Nazwa         = service.GetName();
         cntrl.Kategoria     = service.GetCategory();
         cntrl.Cena          = service.GetPrize();
         cntrl.Kolor         = Color.White;
         cntrl.Identyfikator = service.GetId();
         cntrl.StanProduktu  = service.GetAmount();
         cntrl.StanKrytyczny = service.GetCriticalAmount();
         //dodac funkcje zmieniajaca kolor ilosci pozostalych uslug
         return(cntrl);
     }
     else
     {
         return(null);
     }
 }