Esempio n. 1
0
        private void AllData_Load(object sender, EventArgs e)
        {
            dbContext.GetAllUserCars(userCar.GetType());
            table = dbContext.usCars;

            foreach (UserCar user in table)
            {
                users.Add(user);
            }
            if (page == null)
            {
                page = 1;
            }

            int skip   = ((int)page - 1) * 3;
            var users1 = users.Skip(skip).Take(3).ToList();

            TotalPage = Math.Ceiling(users.Count / 3.0);
            WievPage  = page;

            double totaPage = TotalPage;
            int    x        = 1;
            int    y        = 5;

            for (int i = 1; i <= totaPage; i++)
            {
                Button button = new Button();
                button.Name   = "Total";
                button.Size   = new Size(30, 30);
                button.Text   = i.ToString();
                button.Click += DataElm;
                Controls.Add(button);
                if (x % totaPage * 0 != 0)
                {
                    y = y + 10;
                    x = 0;
                }
                button.Location = new Point(x * 30 + 30, 400);
                x++;
            }
            int a = 0;
            int b = 45;

            foreach (UserCar car in users1)
            {
                string      fullpath = ConfigurationManager.AppSettings["Path"].ToString();
                string      FullPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\", fullpath, car.Photo));
                FileManager manager  = new FileManager();
                byte[]      array    = manager.ReadFromFile(FullPath);
                CreatedToolBox(array, car.Model, car.Marka, car.Year, car.Prize, car.Currency, ref a, b);
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                FileInfo fileInfo = new FileInfo(openFile.FileName);
                UserCar  userCar  = new UserCar();
                userCar.Marka        = cmbx_marka.Text;
                userCar.Model        = cmbx_model.Text;
                userCar.City         = cmbx_city.Text;
                userCar.Year         = cmbx_year.Text;
                userCar.Desicription = txbx_desc.Text;
                userCar.Prize        = txbx_prize.Text;
                userCar.Photo        = fileInfo.Name;
                userCar.Currency     = valyuta;
                userCar.UserId       = DbExtensions.UserId(dbContext, users, label8.Text);


                string photoPath = ConfigurationManager.AppSettings["Path"].ToString();
                string fullPath  = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\", photoPath, userCar.Photo));
                byte[] array     = null;
                using (FileStream fileStream = File.Open(openFile.FileName, FileMode.Open))
                {
                    array = new byte[fileStream.Length];
                    fileStream.Read(array, 0, array.Length);
                }

                using (FileStream fileStream = File.Create(fullPath))
                {
                    fileStream.Write(array, 0, array.Length);
                }

                dbContext.InsertCommandUserCars(userCar.GetType(), userCar.Marka, userCar.Model, userCar.City, userCar.Year, userCar.Desicription, userCar.Prize, userCar.Photo, userCar.UserId, userCar.Currency);
                txbx_excPhoto.Text = "Elaniniz Ugurla Yerlesdirildi";
            }
            catch (Exception ex)
            {
                txbx_excPhoto.Text = ex.Source = "Zehmet Olmasa Photonu Secin";
                string str = ex.Message;
            }
        }