Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (id == 0)
            {
                var isExist = db.Customers
                              .Any(x => x.Plaque.ToUpper() == txtPlaque.Text.ToUpper() && !x.Deleted);

                if (isExist)
                {
                    MessageBox.Show("Plaka ile daha önce kayıt mevcuttur", "Hata!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var add = new Customer();
                    add.Plaque      = txtPlaque.Text;
                    add.NameSurname = txtNameSurname.Text;
                    add.Telephone   = txtTelephone.Text;
                    add.BrandId     = (int)cmbBrand.SelectedValue;
                    add.SerieId     = (int)cmbSerie.SelectedValue;
                    add.Year        = txtYear.Text;
                    add.Color       = txtColor.Text;
                    add.Comment     = txtComment.Text;
                    db.Customers.Add(add);

                    db.SaveChanges();

                    MessageBox.Show("Ekleme işlemi başarılı", "Kayıt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    btnClean.PerformClick();
                }
            }
            else
            {
                var customer = db.Customers
                               .FirstOrDefault(x => x.Id == id);

                if (customer != null)
                {
                    customer.Plaque      = txtPlaque.Text;
                    customer.NameSurname = txtNameSurname.Text;
                    customer.Telephone   = txtTelephone.Text;
                    customer.BrandId     = (int)cmbBrand.SelectedValue;
                    customer.SerieId     = (int)cmbSerie.SelectedValue;
                    customer.Year        = txtYear.Text;
                    customer.Color       = txtColor.Text;
                    customer.Comment     = txtComment.Text;

                    db.SaveChanges();

                    MessageBox.Show("Güncelleme işlemi başarılı", "Kayıt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    btnClean.PerformClick();
                }
                else
                {
                    MessageBox.Show("Müşteri bulunamadı.", "Hata!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            FrmCustomerList.frmCustomerList.GridFill();
            this.Close();
        }
Ejemplo n.º 2
0
        public ServiceResult Post(Brand brand)
        {
            var result = new ServiceResult {
                IsSuccess = true
            };

            context.Brands.Add(brand);
            context.SaveChanges();
            return(result);
        }
Ejemplo n.º 3
0
        public ServiceResult Post(Tariff tariff)
        {
            var result = new ServiceResult {
                IsSuccess = true
            };

            context.Tariffs.Add(tariff);
            context.SaveChanges();
            return(result);
        }
Ejemplo n.º 4
0
        public ServiceResult Post(CarParkingSpace model)
        {
            var result = new ServiceResult {
                IsSuccess = true
            };

            model.Status = false;
            context.CarParkingSpaces.Add(model);
            context.SaveChanges();
            return(result);
        }
Ejemplo n.º 5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var tbl = new Brand();

            tbl.BrandName = txtBrandName.Text;
            db.Brands.Add(tbl);
            db.SaveChanges();
            MessageBox.Show("Araç markası eklendi", "Kayıt", MessageBoxButtons.OK, MessageBoxIcon.Information);
            BrandList();
            Clean();
        }
Ejemplo n.º 6
0
        public ServiceResult Post(SerieModel model)
        {
            var result = new ServiceResult {
                IsSuccess = true
            };
            var serie = new Serie
            {
                BrandId   = model.BrandId,
                SerieName = model.SerieName
            };

            context.Series.Add(serie);
            context.SaveChanges();
            return(result);
        }
Ejemplo n.º 7
0
        private void btnPay_Click(object sender, EventArgs e)
        {
            var customer = db.Customers
                           .Include(x => x.CarParkingSpaces)
                           .FirstOrDefault(x => x.Plaque == cmbPlaque.Text);

            if (customer != null)
            {
                if (tariff != null)
                {
                    var sell = new Sell
                    {
                        Amount            = tariff.Amount,
                        CarParkingSpaceId = customer.CarParkingSpaceId.Value,
                        CustomerId        = customer.Id,
                        EntryDate         = customer.EntryDate.Value,
                        ExitDate          = DateTime.Now,
                        Time = (decimal)hour
                    };
                    db.Sells.Add(sell);
                }

                customer.CarParkingSpaceId       = null;
                customer.EntryDate               = null;
                customer.CarParkingSpaces.Status = false;
                db.SaveChanges();

                PlaqueLoad();

                MessageBox.Show("Ödeme işlemi başarılı", "Ödeme", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 8
0
        private void btnProcess_Click(object sender, EventArgs e)
        {
            var emptyParking = db.CarParkingSpaces
                               .FirstOrDefault(x => x.ParkingSpaces == cmbParkSpace.Text);

            emptyParking.Status = true;

            var customer = db.Customers
                           .Include(x => x.CarParkingSpaces)
                           .FirstOrDefault(x => x.Id == id);

            // mevcutta otoparkta başka bir yerde ise yeri değiştiriliyor
            if (customer.CarParkingSpaceId != null)
            {
                customer.CarParkingSpaces.Status = false;
            }

            if (customer != null)
            {
                customer.EntryDate         = DateTime.Now;
                customer.CarParkingSpaceId = (int)cmbParkSpace.SelectedValue;
            }

            db.SaveChanges();
            this.Close();
            FrmCustomerList.frmCustomerList.GridFill();
            MessageBox.Show("Park yeri kaydedildi", "Kayıt", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Ejemplo n.º 9
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult dialog = new DialogResult();

            dialog = MessageBox.Show("Silmek istiyor musunuz?", "Silme Onayı", MessageBoxButtons.YesNo);
            if (dialog == DialogResult.Yes)
            {
                using (CarParkDbContext db = new CarParkDbContext())
                {
                    int id = int.Parse(dataGridCustomerList.CurrentRow.Cells[0].Value.ToString());

                    var customer = db.Customers
                                   .Include(x => x.CarParkingSpaces)
                                   .FirstOrDefault(x => x.Id == id);

                    if (customer != null)
                    {
                        customer.Deleted = true;
                        customer.CarParkingSpaces.Status = false;

                        db.SaveChanges();
                        MessageBox.Show("Kayıt silindi", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Clean();
                        GridFill();
                    }
                    else
                    {
                        MessageBox.Show("Müşteri bulunamadı", "Hata!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public ServiceResult Delete(int id)
        {
            var result = new ServiceResult {
                IsSuccess = false
            };
            var customer = context.Customers
                           .Include(x => x.CarParkingSpaces)
                           .FirstOrDefault(x => x.Id == id);

            if (customer != null)
            {
                customer.Deleted = true;
                if (customer.CarParkingSpaces != null)
                {
                    customer.CarParkingSpaces.Status = false;
                }
                context.SaveChanges();
                result.IsSuccess = true;
            }
            return(result);
        }
Ejemplo n.º 11
0
        public ServiceResult MyAccountEdit(UserProfileModel model)
        {
            var result = new ServiceResult {
                IsSuccess = false
            };
            var data = context.Users.Find(model.Id);

            if (data != null)
            {
                data.NameSurname = model.NameSurname;
                data.BirthDate   = model.BirthDate;
                data.Gender      = model.Gender;
                context.SaveChanges();
                result.IsSuccess = true;
            }
            return(result);
        }
Ejemplo n.º 12
0
        public ServiceResult Post(SellModel sell)
        {
            var result = new ServiceResult {
                IsSuccess = false
            };
            var customer = context.Customers
                           .Include(x => x.CarParkingSpaces)
                           .FirstOrDefault(x => x.Id == sell.CustomerId);

            if (customer != null)
            {
                if (sell != null)
                {
                    var model = new Sell
                    {
                        Amount            = sell.Amount,
                        CarParkingSpaceId = customer.CarParkingSpaceId.Value,
                        CustomerId        = customer.Id,
                        EntryDate         = customer.EntryDate.Value,
                        ExitDate          = DateTime.Now,
                        Time = (decimal)sell.Hour
                    };
                    context.Sells.Add(model);

                    customer.CarParkingSpaceId       = null;
                    customer.EntryDate               = null;
                    customer.CarParkingSpaces.Status = false;
                    context.SaveChanges();
                    result.IsSuccess = true;
                }
            }
            else
            {
                result.Message = "Müşteri Bulunamadı!";
            }
            return(result);
        }