private void select() { for (int i = 0; i < pers.Count; i++) { if(Manager_personal_list.SelectedItem.ToString()==pers[i].login){ personal = pers[i]; Manager_login_txt.Text = pers[i].login; Manager_pass_txt.Text = pers[i].pass; Manager_name_txt.Text = pers[i].Name; Manage_lastname_txt.Text = pers[i].scndName; Manager_title_txt.Text = pers[i].title; if (pers[i].add) { Manger_chk_add.Checked = true; } else { Manger_chk_add.Checked = false; } if (pers[i].create_pdf) { Manger_chk_createPDF.Checked = true; } else { Manger_chk_createPDF.Checked = false; } if (pers[i].change) { Manger_chk_change.Checked = true; } else { Manger_chk_change.Checked = false; } if (pers[i].download) { Manger_chk_download.Checked = true; } else { Manger_chk_download.Checked = false; } if (pers[i].admin) { Manger_chk_admin.Checked = true; } else { Manger_chk_admin.Checked = false; } } } }
private void Manager_addpersonal_Click(object sender, EventArgs e) { Personal p = new Personal(); if (isadd) { if (isLoginOk()) { isadd = false; Manager_addpersonal.Text = "Добавить"; SQL sql = new SQL(); int add_int; int change_int; int dl_int; int create_int; int admin_int; if (Manger_chk_add.Checked) { add_int = 1; } else { add_int = 0; } if (Manger_chk_change.Checked) { change_int = 1; } else { change_int = 0; } if (Manger_chk_download.Checked) { dl_int = 1; } else { dl_int = 0; } if (Manger_chk_createPDF.Checked) { create_int = 1; } else { create_int = 0; } if (Manger_chk_admin.Checked) { admin_int = 1; } else { admin_int = 0; } sql.ExecuteNonQuery("INSERT INTO PERSONAL (USER_LOGIN,PASS,ADD_COIN,CREATE_PDF,CHANGE,DOWNLOAD,ADMIN_RULE,NAME,LAST_NAME,TITLE) VALUES('" + Manager_login_txt.Text + "','" + Manager_pass_txt.Text + "'," + add_int + "," + create_int + "," + change_int + "," + dl_int + "," + admin_int + ",'" + Manager_name_txt.Text + "','" + Manage_lastname_txt.Text + "','" + Manager_title_txt.Text + "')"); p = pers[pers.Count - 1]; p.login = Manager_login_txt.Text; p.pass = Manager_pass_txt.Text; p.add = Manger_chk_add.Checked; p.change = Manger_chk_change.Checked; p.download = Manger_chk_download.Checked; p.create_pdf = Manger_chk_createPDF.Checked; p.admin = Manger_chk_admin.Checked; p.Name = Manager_name_txt.Text; p.scndName = Manage_lastname_txt.Text; p.title = Manager_title_txt.Text; refreshPers(); Manager_personal_list.SetSelected(Manager_personal_list.Items.Count - 1, true); select(); } else { MessageBox.Show("Два пользователя с одним логином"); } }else{ isadd=true; Manager_personal_list.Items.Add("Пользователь"); Manager_personal_list.SetSelected(Manager_personal_list.Items.Count-1,true); p.login = "******"; // p.scndName = "Пользователь "; pers.Add(p); select(); Manager_addpersonal.Text = "Cохранить"; } }
private void Manager_Load(object sender, EventArgs e) { SQL sql = new SQL(); FbDataReader reader = sql.StartQuery("SELECT * FROM PERSONAL"); try { while (reader.Read()) { Personal p = new Personal(); p.login = reader.GetString(1); p.pass = reader.GetString(2); if (reader.GetInt32(3) == 1) { p.add = true; } else { p.add = false; } if (reader.GetInt32(4) == 1) { p.create_pdf = true; } else { p.create_pdf = false; } if (reader.GetInt32(5) == 1) { p.change = true; } else { p.change = false; } if (reader.GetInt32(6) == 1) { p.download = true; } else { p.download = false; } if (reader.GetInt32(7) == 1) { p.admin = true; } else { p.admin = false; } if (!reader.IsDBNull(8)) { p.Name = reader.GetString(8); } if (!reader.IsDBNull(9)) { p.scndName = reader.GetString(9); } if (!reader.IsDBNull(10)) { p.title = reader.GetString(10); } pers.Add(p); } } finally { sql.EndQuery(); refreshPers(); Manager_personal_list.SetSelected(0, true); select(); } sql = new SQL(); reader = sql.StartQuery("SELECT * FROM CAT"); try { while (reader.Read()) { Cat c = new Cat(); c.cat = reader.GetString(1); c.id = reader.GetInt32(0); cat.Add(c); } } finally { sql.EndQuery(); refreshCat(); } }