예제 #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Label6.Text = null; //for msg

            employeesDataContextDataContext db = new employeesDataContextDataContext();

            var get_log = (from a in db.employees where a.login == (TextBox1.Text.Trim()) select a.login).FirstOrDefault(); //get the needed log from db

            //login

            if (get_log == null)
            {
                if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "")
                {
                    Label6.Text     = "Заполните все поля!";
                    Label6.CssClass = "msg msg-error";
                }
                else
                {
                    //create
                    employees NewEmployee = new employees();
                    NewEmployee.login      = TextBox1.Text;
                    NewEmployee.pswd       = "1234";
                    NewEmployee.first_name = TextBox2.Text;
                    NewEmployee.last_name  = TextBox3.Text;
                    NewEmployee.role       = "user";
                    NewEmployee.position   = Convert.ToInt32(DropDownList1.SelectedValue);
                    NewEmployee.faculty_id = Convert.ToInt32(DropDownList2.SelectedValue);
                    //Insert new record in tblmembers
                    db.employees.InsertOnSubmit(NewEmployee);
                    //Update table
                    db.SubmitChanges();
                    BindGridView();

                    Label6.Text     = "Пользователь успешно зарегистрирован!";
                    Label6.CssClass = "msg msg-success";
                }
            }
            else
            {
                string login = Convert.ToString(get_log);
                login = System.Text.RegularExpressions.Regex.Replace(login, @"\s+", ""); //remove spaces

                if (login != null)
                {
                    Label6.Text     = "Пользователь с таким логином уже зарегистрирован в системе!";
                    Label6.CssClass = "msg msg-error";
                }
            }

            clearFields();
        }
예제 #2
0
 private void detach_employees(employees entity)
 {
     this.SendPropertyChanging();
     entity.faculties = null;
 }
예제 #3
0
 private void detach_employees(employees entity)
 {
     this.SendPropertyChanging();
     entity.positions = null;
 }
예제 #4
0
 partial void Deleteemployees(employees instance);
예제 #5
0
 partial void Updateemployees(employees instance);
예제 #6
0
 partial void Insertemployees(employees instance);