Esempio n. 1
0
        public ActionResult profile()
        {
            string username          = User.Identity.Name;
            library_globalContext db = new library_globalContext();
            // Fetch the userprofile
            Клиенты user = db.Клиенты.FirstOrDefault(u => u.Login.Equals(username));

            // Construct the viewmodel
            Клиенты model = new Клиенты();

            model.Фамилия    = user.Фамилия;
            model.Имя        = user.Имя;
            model.Отчество   = user.Отчество;
            model.Age        = user.Age;
            model.Адрес      = user.Адрес;
            model.BooksBack  = user.BooksBack;
            model.BooksReads = user.BooksReads;
            model.Comments   = user.Comments;
            model.IdКлиента  = user.IdКлиента;
            model.Login      = user.Login;
            model.Avatar     = user.Avatar;


            return(View(model));
        }
Esempio n. 2
0
        public ActionResult edit_profile(Клиенты userprofile)
        {
            if (ModelState.IsValid)
            {
                library_globalContext db = new library_globalContext();
                string username          = User.Identity.Name;

                Клиенты user = db.Клиенты.FirstOrDefault(u => u.Login.Equals(username));


                string filename  = Path.GetFileNameWithoutExtension(userprofile.ImageFile.FileName);
                string extension = Path.GetExtension(userprofile.ImageFile.FileName);
                user.Имя           = userprofile.Имя;
                user.Фамилия       = userprofile.Фамилия;
                user.Отчество      = userprofile.Отчество;
                user.Age           = userprofile.Age;
                user.Адрес         = userprofile.Адрес;
                user.Password      = userprofile.Password;
                filename           = filename + DateTime.Now.ToString("ttmmssfff") + extension;
                userprofile.Avatar = "~/img/avatars/" + filename;
                user.Avatar        = filename;
                filename           = Path.Combine(Server.MapPath("~/img/avatars"), filename);
                userprofile.ImageFile.SaveAs(filename);

                db.Клиенты.Update(user);
                db.SaveChanges();


                return(RedirectToAction("profile", "account"));
            }

            return(View(userprofile));
        }
 private void btAdd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (tbLastName.Text == "" || tbFirstName.Text == "" || tbPatronymic.Text == "" || tbPatronymic.Text == "" || tbAddress.Text == "")
         {
             MessageBox.Show("Заполните все необходимые для заполнения поля!", "Предупреждения");
         }
         else
         {
             db.Клиенты.Load();
             Клиенты client = new Клиенты()
             {
                 Фамилия  = Convert.ToString(tbLastName.Text),
                 Имя      = Convert.ToString(tbFirstName.Text),
                 Отчество = Convert.ToString(tbPatronymic.Text),
                 Телефон  = Convert.ToString(tbPhone.Text),
                 Адрес    = Convert.ToString(tbAddress.Text),
                 Email    = Convert.ToString(tbEmail.Text)
             };
             db.Клиенты.Add(client);
             db.SaveChanges();
         }
     }
     catch
     {
         MessageBox.Show("Ошибка ввода данных", "Ошибка");
     }
 }
        public async Task <ActionResult> Create([Bind(Include = "Код_клиента,Тип,ФИО_Название_клуба,Паспортные_данные_Реквизиты,Город,Адрес,Основной_контакт,Дополнительные_контакты,Примечания")] Клиенты клиенты)
        {
            if (ModelState.IsValid)
            {
                db.Клиенты.Add(клиенты);

                try
                {
                    await db.SaveChangesAsync();
                }
                catch (DbEntityValidationException ex)
                {
                    foreach (DbEntityValidationResult validationError in ex.EntityValidationErrors)
                    {
                        Response.Write("Object: " + validationError.Entry.Entity.ToString());
                        Response.Write("                ");
                        foreach (DbValidationError err in validationError.ValidationErrors)
                        {
                            Response.Write(err.ErrorMessage + "           ");
                        }
                    }
                }

                return(RedirectToAction("Index"));
            }

            return(View(клиенты));
        }
Esempio n. 5
0
        public ActionResult NewOrder(string passport, string fio, string phone, string room_num, string order_type, string begin_date, string end_date, string emp)
        {
            try
            {
                using (HotelDBEntities db = new HotelDBEntities())
                {
                    Клиенты client = new Клиенты();
                    client.Паспорт = passport;
                    client.ФИО     = fio;
                    client.Телефон = phone;
                    db.Клиенты.Add(client);
                    db.SaveChanges();
                    var  clinet_id = db.Клиенты.Where(x => x.Паспорт == passport).Select(x => x.ID_клиента).FirstOrDefault();
                    Учет record    = new Учет();
                    record.ID_Клиента  = clinet_id;
                    record.ID_Номера   = Convert.ToInt32(room_num) + 1;
                    record.Операция    = Convert.ToInt32(order_type);
                    record.Дата_въезда = Convert.ToDateTime(begin_date);
                    record.Дата_выезда = Convert.ToDateTime(end_date);
                    var emp_id = db.Сотрудники.Where(x => x.Имя == emp).Select(x => x.ID_сотрудника).FirstOrDefault();
                    record.Сотрудник = emp_id;
                    int room_id    = Convert.ToInt32(room_num) + 1;
                    var room_price = db.Номера.Where(x => x.ID == room_id).Select(x => x.Цена).FirstOrDefault();
                    record.Цена = Convert.ToDateTime(end_date).Subtract(Convert.ToDateTime(begin_date)).Days *room_price;
                    db.Учет.Add(record);
                    db.SaveChanges();
                }
            }
            catch
            {
                return(RedirectToAction("Index"));
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 6
0
        private void button6_Click(object sender, EventArgs e)
        {
            Клиенты s = new Клиенты();

            s.Show();
            s.Owner         = this;
            button6.Visible = false;
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Клиенты клиенты = db.Клиенты.Find(id);

            db.Клиенты.Remove(клиенты);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID_Клиент,Фамилия,Имя,Отчество,Дата_рождения")] Клиенты клиенты)
 {
     if (ModelState.IsValid)
     {
         db.Entry(клиенты).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(клиенты));
 }
        public ActionResult Create([Bind(Include = "ID_Клиент,Фамилия,Имя,Отчество,Дата_рождения")] Клиенты клиенты)
        {
            if (ModelState.IsValid)
            {
                db.Клиенты.Add(клиенты);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(клиенты));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Код_клиента,Тип,ФИО_Название_клуба,Паспортные_данные_Реквизиты,Город,Адрес,Основной_контакт,Дополнительные_контакты,Примечания")] Клиенты клиенты)
        {
            if (ModelState.IsValid)
            {
                db.Entry(клиенты).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(клиенты));
        }
 public void CreateClient(int codClient, string clientName, int numberUNP, string Adres, string Status)
 {
     Клиенты client = new Клиенты
     {
         Код_клиента = codClient,
         Наименование = clientName,
         УНП = numberUNP,
         Адрес = Adres,
         Статус = Status
     };
     SaveClient(client);
 }
Esempio n. 12
0
        public async Task <ActionResult> AddClient([Bind(Include = "Телефон,Адрес,ФИО")] Клиенты клиент)
        {
            if (ModelState.IsValid)
            {
                db.Клиенты.Add(клиент);
                await db.SaveChangesAsync();

                return(RedirectToAction("Create"));
            }
            ViewBag.Телефон = new SelectList(db.Клиенты, "Телефон", "Телефон", клиент.Телефон);
            ViewBag.Адрес   = new SelectList(db.Клиенты, "Адрес", "Адрес", клиент.Адрес);
            ViewBag.ФИО     = new SelectList(db.Клиенты, "ФИО", "ФИО", клиент.ФИО);
            return(View(клиент));
        }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Клиенты клиенты = db.Клиенты.Find(id);

            if (клиенты == null)
            {
                return(HttpNotFound());
            }
            return(View(клиенты));
        }
        // GET: Клиенты/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Клиенты клиенты = await db.Клиенты.FindAsync(id);

            if (клиенты == null)
            {
                return(HttpNotFound());
            }
            return(View(клиенты));
        }
        private void button9_Click(object sender, EventArgs e)
        {
            Клиенты d = new Клиенты();

            bool result = d.CliDel(dataGridView1, numericUpDown2.Value);

            if (result)
            {
                MessageBox.Show("Запись удалена.", "Успех!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                MessageBox.Show("Клиент не найден!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 16
0
 private void btDeleteClient_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         db.Клиенты.Load();
         Клиенты клиент = dgClients.SelectedItem as Клиенты;
         db.Клиенты.Attach(клиент);
         db.Клиенты.Remove(клиент);
         db.SaveChanges();
     }
     catch
     {
         MessageBox.Show("Ошибка удаления записи", "Предупреждение");
     }
 }
Esempio n. 17
0
        public ActionResult user_profile_edit(int IdКлиента)
        {
            Клиенты user = db.Клиенты.FirstOrDefault(u => u.IdКлиента.Equals(IdКлиента));

            Клиенты model = new Клиенты();

            model.Фамилия  = user.Фамилия;
            model.Имя      = user.Имя;
            model.Отчество = user.Отчество;
            model.Age      = user.Age;
            model.Адрес    = user.Адрес;
            model.Password = user.Password;
            model.Avatar   = user.Avatar;

            return(View(model));
        }
        private void СпискиКлиентов_Load(object sender, EventArgs e)
        {
            textBox4.Enabled  = false;
            textBox5.Enabled  = false;
            textBox6.Enabled  = false;
            textBox7.Enabled  = false;
            textBox8.Enabled  = false;
            textBox9.Enabled  = false;
            label18.Text      = "Выберите клиента";
            label18.ForeColor = Color.Red;
            groupBox1.Visible = false;
            groupBox2.Visible = false;
            groupBox3.Visible = false;
            Клиенты d = new Клиенты();

            d.CliLoad(dataGridView1);
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Клиенты клиенты = await db.Клиенты.FindAsync(id);

            try
            {
                db.Клиенты.Remove(клиенты);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch
            {
                ModelState.AddModelError("ErrorMessage", "Данную запись нельзя удалить, т.к. на неё имеются ссылки в других таблицах. Удалите ссылки в других таблицах и повторите удаление записи");
                return(View(клиенты));
            }
        }
        public void SaveClient(Клиенты client)
        {
            if (client.Код_клиента == 0)
            {
                context.Клиенты.Add(client);
            }
            else
            {
                Контактное_лицо con =
                    context.Контактное_лицо.Where(x => x.Код_клиента == client.Код_клиента).FirstOrDefault();
                context.Контактное_лицо.Remove(con);

                context.Клиенты.Remove(context.Клиенты.Where(x=>x.Код_клиента==client.Код_клиента).FirstOrDefault());
                context.Клиенты.Add(client);

            }
            context.SaveChanges();
        }
Esempio n. 21
0
        public ActionResult edit_profile()
        {
            string username          = User.Identity.Name;
            library_globalContext db = new library_globalContext();
            // Fetch the userprofile
            Клиенты user = db.Клиенты.FirstOrDefault(u => u.Login.Equals(username));

            // Construct the viewmodel
            Клиенты model = new Клиенты();

            model.Фамилия  = user.Фамилия;
            model.Имя      = user.Имя;
            model.Отчество = user.Отчество;
            model.Age      = user.Age;
            model.Адрес    = user.Адрес;
            model.Password = user.Password;
            model.Avatar   = user.Avatar;

            return(View(model));
        }
Esempio n. 22
0
        public ActionResult user_profile(int i)
        {
            Клиенты user = db.Клиенты.FirstOrDefault(u => u.IdКлиента.Equals(i));

            Клиенты model = new Клиенты();

            model.Фамилия    = user.Фамилия;
            model.Имя        = user.Имя;
            model.Отчество   = user.Отчество;
            model.Age        = user.Age;
            model.Адрес      = user.Адрес;
            model.BooksBack  = user.BooksBack;
            model.BooksReads = user.BooksReads;
            model.Comments   = user.Comments;
            model.IdКлиента  = user.IdКлиента;
            model.Login      = user.Login;
            model.Avatar     = user.Avatar;


            return(View(model));
        }
        private void button5_Click(object sender, EventArgs e)
        {
            Клиенты d = new Клиенты();

            bool result = d.CliRedVB(dataGridView1, numericUpDown1.Value, textBox4, textBox5, textBox6, textBox8, textBox9, textBox7);

            if (result)
            {
                label18.Text      = "Клиент выбран";
                label18.ForeColor = Color.Green;

                textBox4.Enabled = true;
                textBox5.Enabled = true;
                textBox6.Enabled = true;
                textBox7.Enabled = true;
                textBox8.Enabled = true;
                textBox9.Enabled = true;
            }
            else
            {
                MessageBox.Show("Клиент не найден!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox4.Clear();
                textBox5.Clear();
                textBox6.Clear();
                textBox7.Clear();
                textBox8.Clear();
                textBox9.Clear();
                numericUpDown1.Value = 0;
                label18.Text         = "Выберите клиента";
                label18.ForeColor    = Color.Red;

                textBox4.Enabled = false;
                textBox5.Enabled = false;
                textBox6.Enabled = false;
                textBox7.Enabled = false;
                textBox8.Enabled = false;
                textBox9.Enabled = false;
                label17.Text     = "";
            }
        }
        private void button6_Click(object sender, EventArgs e)
        {
            {
                if (textBox4.Text != "" && textBox5.Text != "" && textBox6.Text != "" && textBox7.Text != "" && textBox9.Text != "" && textBox8.Text != "")
                {
                    Клиенты d      = new Клиенты();
                    bool    result = d.CliRed(dataGridView1, numericUpDown1.Value, textBox4, textBox5, textBox6, textBox8, textBox9, textBox7);
                    if (result)
                    {
                        label18.Text      = "Выберите клиента";
                        label18.ForeColor = Color.Red;
                        textBox4.Clear();
                        textBox5.Clear();
                        textBox6.Clear();
                        textBox7.Clear();
                        textBox8.Clear();
                        textBox9.Clear();
                        numericUpDown1.Value = 0;
                        textBox4.Enabled     = false;
                        textBox5.Enabled     = false;
                        textBox6.Enabled     = false;
                        textBox7.Enabled     = false;
                        textBox8.Enabled     = false;
                        textBox9.Enabled     = false;
                        label17.Text         = "";
                    }
                    else
                    {
                        MessageBox.Show("Неверный формат одного или нескольких полей, введите корректные значения!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }


                    MessageBox.Show("Запись успешно изменена!", "Успех!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    MessageBox.Show("Поля Имя, Фамилия, Телефон, Серия и Номер паспорта обязательны для заполнения!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            Клиенты d = new Клиенты();

            if (textBox1.Text != "" && textBox2.Text != "" && textBox10.Text != "" && textBox11.Text != "" && textBox12.Text != "")
            {
                bool result = d.Cli(dataGridView1, textBox1, textBox2, textBox3, textBox10, textBox11, textBox12);
                if (result)
                {
                    MessageBox.Show("Запись успешно создана!", "Успех!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }

                else
                {
                    MessageBox.Show("Номер телефона уже занят!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox8.Clear();
                }
            }
            else
            {
                MessageBox.Show("Поля Имя, Фамилия, Телефон, Серия и Номер паспорта обязательны для заполнения!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 26
0
        public ActionResult Login(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                // поиск пользователя в бд
                Клиенты user = null;
                using (library_globalContext db = new library_globalContext())
                {
                    user = db.Клиенты.FirstOrDefault(u => u.Login == model.Name && u.Password == model.Password);
                }
                if (user != null)
                {
                    FormsAuthentication.SetAuthCookie(model.Name, true);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("", "Пользователя с таким логином и паролем нет");
                }
            }

            return(View(model));
        }
Esempio n. 27
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                Клиенты user = null;
                using (library_globalContext db = new library_globalContext())
                {
                    user = db.Клиенты.FirstOrDefault(u => u.Login == model.Name);
                }
                if (user == null)
                {
                    // создаем нового пользователя
                    using (library_globalContext db = new library_globalContext())
                    {
                        int lastid = db.Клиенты.Max(u => u.IdКлиента);
                        db.Клиенты.Add(new Клиенты {
                            IdКлиента = lastid + 1, Login = model.Name, Password = model.Password, IdRole = 2
                        });
                        db.SaveChanges();

                        user = db.Клиенты.Where(u => u.Login == model.Name && u.Password == model.Password).FirstOrDefault();
                    }
                    // если пользователь удачно добавлен в бд
                    if (user != null)
                    {
                        FormsAuthentication.SetAuthCookie(model.Name, true);
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Пользователь с таким логином уже существует");
                }
            }

            return(View(model));
        }
 public void DeleteClient(Клиенты client)
 {
     context.Клиенты.Remove(client);
     context.SaveChanges();
 }
Esempio n. 29
0
        }//отключение от БД

        public void ПодготовкаМассивов(string НомерТаблицы)
        {
            Филиалы  Filial = new Филиалы();//Создаем обьекты наших публичных массивов
            Инженеры Ing    = new Инженеры();
            Клиенты  Kl     = new Клиенты();
            емонты   Rem    = new  емонты();

            string Table = "";
            int    Count = 0;
            int    Row   = 0;

            //Отбор логики и переменных по входному числу, которое отвечает за выбор таблицы и инициализацию
            //соответствующего двумерного массива с высотой "Count" и статической шириной "Row"
            if (int.Parse(НомерТаблицы) == 1)
            {
                Table = СписокТаблиц[0];
                Count = filial;
                Row   = 6;
                Filial.МассивФилиалов = new string[filial, Row];
            }
            else if (int.Parse(НомерТаблицы) == 2)
            {
                Table = СписокТаблиц[1];                          //название таблицы из массива
                Count = ingeeneer;                                //количество записей, получаем в Form_load
                Row   = 5;                                        //статическое количество столбцов
                Ing.МассивИнженеров = new string[ingeeneer, Row]; //инициализируем массив
            }
            else if (int.Parse(НомерТаблицы) == 3)
            {
                Table             = СписокТаблиц[2];
                Count             = klient;
                Row               = 5;
                Kl.МассивКлиентов = new string[klient, Row];
            }
            else if (int.Parse(НомерТаблицы) == 4)
            {
                Table = СписокТаблиц[3];
                Count = remont;
                Row   = 21;
                Rem.МассивРемонтов = new string[remont, Row];
            }
            else
            {
                MessageBox.Show("Что-то пошло не так, обратитесь к поставщику БД!");
            }
            MySqlConnection Коннектор = new MySqlConnection(СтрокаПодключения);// Обьявляем cBase как MySqlConnection(переменная строки подключения)
            int             строка    = 1;

            for (int i = 0; i < Count; i++)//цикл выгрузки значений в обьявленные массивы (Внешний цикл - строки, а внутренний - ячейки)
            {
                Коннектор.Open();
                Запрос = $"SELECT * FROM `{Table}` WHERE `ID`={строка}";
                MySqlCommand    Комманда = new MySqlCommand(Запрос, Коннектор);
                MySqlDataReader езультат = Комманда.ExecuteReader();
                езультат.Read();
                for (int ячейка = 0; ячейка < Row; ячейка++)
                {
                    езультат[ячейка].ToString();
                    //Отбор логики и переменных по входному числу, которое отвечает за выбор массива, который соответствует таблице
                    if (int.Parse(НомерТаблицы) == 1)
                    {
                        Filial.МассивФилиалов[(строка - 1), ячейка] = езультат[ячейка].ToString();
                    }
                    else if (int.Parse(НомерТаблицы) == 2)
                    {
                        Ing.МассивИнженеров[(строка - 1), ячейка] = езультат[ячейка].ToString();
                    }
                    else if (int.Parse(НомерТаблицы) == 3)
                    {
                        Kl.МассивКлиентов[(строка - 1), ячейка] = езультат[ячейка].ToString();
                    }
                    else if (int.Parse(НомерТаблицы) == 4)
                    {
                        Rem.МассивРемонтов[(строка - 1), ячейка] = езультат[ячейка].ToString();
                    }
                    else
                    {
                        MessageBox.Show("Что-то пошло не так, обратитесь к поставщику БД!");
                    }
                }
                строка = ++строка;
                Отключиться(Коннектор);
            }
            this.Text           = $"Подключение к {server}  выполнено успешно!";
            bZapolnenie.Enabled = true;
        }