示例#1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            ForceValidation();
            if (Validation.GetHasError(txtRegNo) || Validation.GetHasError(txtColor) ||
                Validation.GetHasError(txtCompany) || Validation.GetHasError(txtModel))
            {
                MessageBox.Show("Error Some Data is Missing", "ERROR");
                return;
            }

            Car_Table obj = new Car_Table();

            obj.CA_RegNo   = txtRegNo.Text.Trim();
            obj.CA_Color   = txtColor.Text.Trim();
            obj.CA_Company = txtCompany.Text.Trim();
            obj.CA_Model   = int.Parse(txtModel.Text);
            obj.CA_Status  = true;
            CarFactory CFobj = new CarFactory();

            if (CFobj.insert(obj))
            {
                MessageBox.Show("Car is Added Successfully", "Data Saved");
            }
            else
            {
                MessageBox.Show("Data Is not Added", "Error");
            }
            txtRegNo.Text = " ";
        }
        public bool ChangeStatus(int id, bool status)
        {
            Car_Table std = obj.Car_Table.Where(x => x.CA_ID == id).FirstOrDefault();

            if (std != null)
            {
                std.CA_Status = status;
            }
            return(obj.SaveChanges() > 0);
        }
        public bool Delete(string Regno)
        {
            Car_Table std = obj.Car_Table.Where(x => x.CA_RegNo == Regno).FirstOrDefault();

            if (std != null)
            {
                obj.Car_Table.Remove(std);
            }
            return(obj.SaveChanges() > 0);
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            CarFactory obj  = new CarFactory();
            Car_Table  Cobj = obj.GetAllCarT(CarId);

            _vm.CA_RegNo     = Cobj.CA_RegNo;
            _vm.CA_Color     = Cobj.CA_Color;
            _vm.CA_Company   = Cobj.CA_Company;
            _vm.CA_Model     = Cobj.CA_Model;
            _vm              = new CarViewModel();
            this.DataContext = _vm;
        }
        public bool Update(Car_Table CTobj)
        {
            Car_Table std = obj.Car_Table.Where(x => x.CA_ID == CTobj.CA_ID).FirstOrDefault();

            if (std != null)
            {
                std.CA_ID      = CTobj.CA_ID;
                std.CA_Model   = CTobj.CA_Model;
                std.CA_RegNo   = CTobj.CA_RegNo;
                std.CA_Company = CTobj.CA_Company;
                std.CA_Color   = CTobj.CA_Color;
            }
            return(obj.SaveChanges() > 0);
        }
示例#6
0
        public void AddClient(string mobile_, string pass_, string email_, string food_, string lastName_, string firstName_)
        {
            //Добавление клиента в БД
            using (context = new ClientContext())
            {
                Mobile_Table mobile = new Mobile_Table();
                mobile.Nuber = mobile_;
                context.Mobiles.Add(mobile);
                context.SaveChanges();

                Password_Table pass   = new Password_Table();
                byte[]         data   = Encoding.Default.GetBytes(pass_);
                var            result = new SHA256Managed().ComputeHash(data);
                pass.Pass = Encoding.Default.GetString(result);
                context.Passwords.Add(pass);
                context.SaveChanges();


                Email_Table Email = new Email_Table();
                Email.Info_Email = email_;
                context.Emails.Add(Email);
                context.SaveChanges();


                Car_Table Car = new Car_Table();
                Car.Info_Car = true;
                context.Cars.Add(Car);
                context.SaveChanges();

                Food_Table food = new Food_Table();
                food.Info_Food = food_;
                context.Foods.Add(food);
                context.SaveChanges();

                Client_Tenant Client_Tenant = new Client_Tenant();
                Client_Tenant.LastName  = lastName_;
                Client_Tenant.FirstName = firstName_;

                Client_Tenant.Mobile = mobile;
                Client_Tenant.Car    = Car;
                Client_Tenant.Email  = Email;
                Client_Tenant.Food   = food;
                Client_Tenant.Passw  = pass;
                context.Client_Tenants.Add(Client_Tenant);
                context.SaveChanges();
            }
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            CarFactory Facobj = new CarFactory();
            Car_Table  CTobj  = new Car_Table();

            CTobj.CA_ID      = CarId;
            CTobj.CA_RegNo   = txtRegNo.Text;
            CTobj.CA_Color   = txtColor.Text;
            CTobj.CA_Company = txtCompany.Text;
            CTobj.CA_Model   = int.Parse(txtModel.Text.ToString());
            if (Facobj.Update(CTobj))
            {
                MessageBox.Show("Data is Saved Successfully", "Saved");
            }
            else
            {
                MessageBox.Show("Data is Not Saved", "Error!");
            }
        }
示例#8
0
        protected override void Seed(Hotel.DataModel.ClientContext context)
        {
            Mobile_Table mobile = new Mobile_Table();

            mobile.Nuber = "+380-93-37-20-606";
            context.Mobiles.Add(mobile);
            context.SaveChanges();

            Password_Table pass    = new Password_Table();
            string         pas_sha = "+380-93-37-20-606";

            byte[] data   = Encoding.Default.GetBytes(pas_sha);
            var    result = new SHA256Managed().ComputeHash(data);

            pass.Pass = Encoding.Default.GetString(result);
            context.Passwords.Add(pass);
            context.SaveChanges();


            Email_Table Email = new Email_Table();

            Email.Info_Email = "*****@*****.**";
            context.Emails.Add(Email);
            context.SaveChanges();


            Car_Table Car = new Car_Table();

            Car.Info_Car = true;
            context.Cars.Add(Car);
            context.SaveChanges();

            Food_Table food = new Food_Table();

            food.Info_Food = "Нужен завтрак и ужен";
            context.Foods.Add(food);
            context.SaveChanges();

            Client_Tenant Client_Tenant = new Client_Tenant();

            Client_Tenant.LastName  = "Владимир";
            Client_Tenant.FirstName = "Петров";

            Client_Tenant.Mobile = mobile;
            Client_Tenant.Car    = Car;
            Client_Tenant.Email  = Email;
            Client_Tenant.Food   = food;
            Client_Tenant.Passw  = pass;
            context.Client_Tenants.Add(Client_Tenant);
            context.SaveChanges();



            //////////////////////////////1 комната////////////////////////
            Room_Table Room_Table = new Room_Table();

            Room_Table.Images          = File.ReadAllBytes(Path.Combine(directoryInfo.FullName, @"Image\1.jpg"));
            Room_Table.Info_Room       = "2 кровати(двухспальные), 2 тумбочки, отдельный санузел кондиционер, холодилькник, телевизор, WI-FI";
            Room_Table.col_peopls_Room = 3;
            context.Rooms.Add(Room_Table);
            context.SaveChanges();

            Time_Arrival Time_Arrival = new Time_Arrival();

            Time_Arrival.Room_ID = 1;
            DateTime date = new DateTime(2018, 6, 5);

            Time_Arrival.Time_Arri_begin = date;
            date = new DateTime(2018, 6, 22);
            Time_Arrival.Time_Arri_end = date;
            context.Time_Ar.Add(Time_Arrival);
            context.SaveChanges();
            //////////////////////////////2 комната////////////////////////

            Room_Table                 = new Room_Table();
            Room_Table.Images          = File.ReadAllBytes(Path.Combine(directoryInfo.FullName, @"Image\2.jpg"));
            Room_Table.Info_Room       = "2 кровати(1 двухспальная, 1 односпальная), 2 тумбочки, кондиционер, холодилькник, телевизор, WI-FI";
            Room_Table.col_peopls_Room = 5;
            context.Rooms.Add(Room_Table);
            context.SaveChanges();

            Time_Arrival         = new Time_Arrival();
            Time_Arrival.Room_ID = 2;
            date = new DateTime(2018, 12, 15);
            Time_Arrival.Time_Arri_begin = date;
            date = new DateTime(2018, 12, 20);
            Time_Arrival.Time_Arri_end = date;
            context.Time_Ar.Add(Time_Arrival);
            context.SaveChanges();
            //////////////////////////////3 комната////////////////////////
            Room_Table                 = new Room_Table();
            Room_Table.Images          = File.ReadAllBytes(Path.Combine(directoryInfo.FullName, @"Image\3.jpg"));
            Room_Table.Info_Room       = "22 кровати(1 двухспальная, 1 односпальная), 2 тумбочки, кондиционер, холодилькник, телевизор, WI-FI";
            Room_Table.col_peopls_Room = 5;
            context.Rooms.Add(Room_Table);
            context.SaveChanges();

            Time_Arrival         = new Time_Arrival();
            Time_Arrival.Room_ID = 3;
            date = new DateTime(2018, 6, 22);
            Time_Arrival.Time_Arri_begin = date;
            date = new DateTime(2018, 6, 22);
            Time_Arrival.Time_Arri_end = date;
            context.Time_Ar.Add(Time_Arrival);
            context.SaveChanges();
            ////////////////////////////4 комната////////////////////////
            Room_Table                 = new Room_Table();
            Room_Table.Images          = File.ReadAllBytes(Path.Combine(directoryInfo.FullName, @"Image\4.jpg"));
            Room_Table.Info_Room       = "3 кровати(1 двухспальная,2 односпальная), 2 тумбочки, кондиционер, холодилькник, телевизор, WI-FI";
            Room_Table.col_peopls_Room = 3;
            context.Rooms.Add(Room_Table);
            context.SaveChanges();

            Time_Arrival         = new Time_Arrival();
            Time_Arrival.Room_ID = 4;
            date = new DateTime(2018, 6, 12);
            Time_Arrival.Time_Arri_begin = date;
            date = new DateTime(2018, 6, 19);
            Time_Arrival.Time_Arri_end = date;
            context.Time_Ar.Add(Time_Arrival);
            context.SaveChanges();
            ////////////////////////////5 комната////////////////////////
            Room_Table                 = new Room_Table();
            Room_Table.Images          = File.ReadAllBytes(Path.Combine(directoryInfo.FullName, @"Image\5.jpg"));
            Room_Table.Info_Room       = "4 кровати(4 односпальных), 2 тумбочки, кондиционер, холодилькник, телевизор, WI-FI";
            Room_Table.col_peopls_Room = 5;
            context.Rooms.Add(Room_Table);
            context.SaveChanges();

            Time_Arrival         = new Time_Arrival();
            Time_Arrival.Room_ID = 5;
            date = new DateTime(2018, 6, 22);
            Time_Arrival.Time_Arri_begin = date;
            date = new DateTime(2018, 6, 22);
            Time_Arrival.Time_Arri_end = date;
            context.Time_Ar.Add(Time_Arrival);
            context.SaveChanges();
            //////////////////////////////6 комната////////////////////////

            Room_Table                 = new Room_Table();
            Room_Table.Images          = File.ReadAllBytes(Path.Combine(directoryInfo.FullName, @"Image\6.jpg"));
            Room_Table.Info_Room       = "25 кровати(1 двухспальная, 1 односпальная), 2 тумбочки, кондиционер, холодилькник, телевизор, WI-FI";
            Room_Table.col_peopls_Room = 5;
            context.Rooms.Add(Room_Table);
            context.SaveChanges();

            Time_Arrival         = new Time_Arrival();
            Time_Arrival.Room_ID = 6;
            date = new DateTime(2018, 6, 22);
            Time_Arrival.Time_Arri_begin = date;
            date = new DateTime(2018, 6, 22);
            Time_Arrival.Time_Arri_end = date;
            context.Time_Ar.Add(Time_Arrival);
            context.SaveChanges();
            //////////////////////////////7 комната////////////////////////
            Room_Table                 = new Room_Table();
            Room_Table.Images          = File.ReadAllBytes(Path.Combine(directoryInfo.FullName, @"Image\7.jpg"));
            Room_Table.Info_Room       = "26 кровати(1 двухспальная, 1 односпальная), 2 тумбочки, кондиционер, холодилькник, телевизор, WI-FI";
            Room_Table.col_peopls_Room = 5;
            context.Rooms.Add(Room_Table);
            context.SaveChanges();

            Time_Arrival         = new Time_Arrival();
            Time_Arrival.Room_ID = 7;
            date = new DateTime(2018, 6, 22);
            Time_Arrival.Time_Arri_begin = date;
            date = new DateTime(2018, 6, 22);
            Time_Arrival.Time_Arri_end = date;
            context.Time_Ar.Add(Time_Arrival);
            context.SaveChanges();
        }
 public bool Insert(Car_Table cobj)
 {
     obj.Car_Table.Add(cobj);
     return(obj.SaveChanges() > 0);
 }