Beispiel #1
0
        private void Exit_Click(object sender, RoutedEventArgs e)
        {
            Director director = new Director(IdUser);

            director.Show();
            this.Close();
        }
Beispiel #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string nameIn   = @in.Text;
            string nameFrom = from.Content.ToString();
            double kf       = 0;

            switch (nameFrom)
            {
            case "мм":
                switch (nameIn)
                {
                case "м":
                    kf = 1000;
                    break;

                case "см":
                    kf = 10;
                    break;

                case "дм":
                    kf = 100;
                    break;
                }
                break;

            case "см":
                switch (nameIn)
                {
                case "м":
                    kf = 100;
                    break;

                case "мм":
                    kf = 0.1;
                    break;

                case "дм":
                    kf = 10;
                    break;
                }
                break;

            case "дм":
                switch (nameIn)
                {
                case "м":
                    kf = 10;
                    break;

                case "см":
                    kf = 0.1;
                    break;

                case "мм":
                    kf = 0.01;
                    break;
                }
                break;

            case "м":
                switch (nameIn)
                {
                case "мм":
                    kf = 0.001;
                    break;

                case "см":
                    kf = 0.1;
                    break;

                case "дм":
                    kf = 0.01;
                    break;
                }
                break;
            }
            var kladFurniture = db.kladFurniture;

            if (kladFurniture.Count() != 0)
            {
                foreach (kladFurniture klFur in kladFurniture)
                {
                    klFur.length *= kf;
                    klFur.width  *= kf;
                    db.kladFurniture.Create();
                }
            }
            var Furniture = db.furniture;

            if (Furniture.Count() != 0)
            {
                foreach (Furniture Fur in Furniture)
                {
                    Fur.length *= kf;
                    Fur.width  *= kf;
                    Fur.weigth *= kf;
                    db.furniture.Create();
                }
            }
            var kladCloth = db.kladCloth;

            if (kladCloth.Count() != 0)
            {
                foreach (kladCloth klCloth in kladCloth)
                {
                    klCloth.length *= kf;
                    klCloth.width  *= kf;
                    db.kladCloth.Create();
                }
            }
            var Cloth = db.cloth;

            if (Cloth.Count() != 0)
            {
                foreach (Cloth cloth in Cloth)
                {
                    cloth.length *= kf;
                    cloth.width  *= kf;
                    db.cloth.Create();
                }
            }
            var InvItem = db.inventoryItem;

            if (InvItem.Count() != 0)
            {
                foreach (var Item in InvItem)
                {
                    Item.length *= kf;
                    Item.width  *= kf;
                    db.inventoryItem.Create();
                }
            }
            var Product = db.Product;

            if (Product.Count() != 0)
            {
                foreach (var prod in Product)
                {
                    prod.length *= kf;
                    prod.width  *= kf;
                    db.Product.Create();
                }
            }
            var UnitFrom = db.Units.Where(un => un.UnitName == nameFrom);
            var UnitIn   = db.Units.Where(un => un.UnitName == nameIn);

            UnitFrom.FirstOrDefault().currentUnit = 0;
            UnitIn.FirstOrDefault().currentUnit   = 1;



            db.SaveChanges();
            MessageBox.Show("Единица измерения успешно изменена");
            Director director = new Director(IdUser);

            director.Show();
            this.Close();
        }
Beispiel #3
0
        private void Inp_Click(object sender, RoutedEventArgs e)
        {
            if (login.Text == "" || password.Text == "")
            {
                MessageBox.Show("Вы заполнили не все поля");
                if (login.Text == "")
                {
                    login.BorderBrush = System.Windows.Media.Brushes.Red;
                }
                if (password.Text == "")
                {
                    password.BorderBrush = System.Windows.Media.Brushes.Red;
                }
            }
            else
            {
                using (UserContext db = new UserContext())
                {
                    try
                    {
                        var select = db.Users.Where(u => u.login == login.Text || u.password == password.Text);
                        IdUser = select.FirstOrDefault().Id;
                        string rol = select.FirstOrDefault().rolles;
                        switch (rol)
                        {
                        case "Директор":
                            Director dir = new Director(IdUser);
                            dir.Show();
                            this.Close();
                            break;

                        case "Заказчик":
                            Client cl = new Client(IdUser);
                            cl.Show();
                            this.Close();
                            break;

                        case "Менеджер":
                            Manager mngr = new Manager(IdUser);
                            mngr.Show();
                            this.Close();
                            break;

                        case "Кладовщик":
                            klad kld = new klad(IdUser);
                            kld.Show();
                            this.Close();
                            break;
                        }
                    }
                    catch
                    {
                        var select = db.Users.Where(u => u.login == login.Text);
                        try
                        {
                            string passw = select.FirstOrDefault().password;
                            if (passw != password.Text)
                            {
                                MessageBox.Show("Неверно введен пароль!");
                            }
                        }
                        catch
                        {
                            MessageBox.Show("Такого пользователя не существует");
                        }
                    }
                }
            }
        }