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(); }
private void detach_employees(employees entity) { this.SendPropertyChanging(); entity.faculties = null; }
private void detach_employees(employees entity) { this.SendPropertyChanging(); entity.positions = null; }
partial void Deleteemployees(employees instance);
partial void Updateemployees(employees instance);
partial void Insertemployees(employees instance);