private void FillFields() { NpgsqlDataReader dataReader = PgSql.SelectFromWhere("*", "dating_club_department", "id", id.ToString()); dataReader.Read(); for (int i = 1; i < dataReader.FieldCount; i++) { String str = dataReader[i].ToString(); switch (i) { case 1: tbName.Text = str; break; case 2: str = str.Remove(0, 1); str = str.Remove(str.Length - 1, 1); String[] tmp = str.Split(','); StringHelper.Scorlupa(tmp, '\"'); tbCountry.Text = tmp[0]; tbCity.Text = tmp[1]; tbStreet.Text = tmp[2]; numHouse.Value = Int32.Parse(tmp[3]); numHouse2.Value = Int32.Parse(tmp[4]); break; case 3: numPayment.Value = Int32.Parse(str); break; } } dataReader.Close(); }
private void FillFields() { try { NpgsqlDataReader dataReader = PgSql.SelectFromWhere("*", "contract", "id", id.ToString()); dataReader.Read(); for (int i = 1; i < dataReader.FieldCount; i++) { String str = dataReader[i].ToString(); StringHelper.Scorlupa(ref str, ' '); switch (i) { case 2: if (str == "") { numFinalPartnerID.Value = -1; } else { numFinalPartnerID.Value = Int32.Parse(str); } break; case 3: numEmployeeID.Value = Int32.Parse(str); break; case 4: numContractTerm.Value = Int32.Parse(str); break; case 1: numClientID.Value = Int32.Parse(str); break; case 5: cbState.Text = str; break; case 6: String[] tmp = str.Split('-'); numDay.Value = Int32.Parse(tmp[2]); numMonth.Value = Int32.Parse(tmp[1]); numYear.Value = Int32.Parse(tmp[0]); break; case 7: numSum.Value = Int32.Parse(str); break; } } dataReader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } }
private bool GetInfoFromPanelControls() { try { NpgsqlDataReader dataReader = PgSql.SelectFromWhere("id", "Nationality", "name", cbNationality.Text); dataReader.Read(); nation_id = Int32.Parse(dataReader[0].ToString()); dataReader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } return(true); }
private bool GetInfoFromPanelControls() { try { NpgsqlDataReader dataReader = PgSql.SelectFromWhere("id", "Nationality", "name", cbNationality.Text); dataReader.Read(); nation_id = Int32.Parse(dataReader[0].ToString()); dataReader = PgSql.SelectFromWhere("id", "Eyecolor", "color", cbEyeColor.Text); dataReader.Read(); eyecolor_id = Int32.Parse(dataReader[0].ToString()); dataReader = PgSql.SelectFromWhere("id", "Haircolor", "color", cbHairColor.Text); dataReader.Read(); haircolor_id = Int32.Parse(dataReader[0].ToString()); interests = "{"; String[] tmp = tbInterests.Text.Split('\n'); foreach (String a in tmp) { interests += "\"" + a + "\", "; } interests = interests.Remove(interests.Length - 2, 2); interests += "}"; pos_features = "{"; tmp = tbPosFeat.Text.Split('\n'); foreach (String a in tmp) { pos_features += "\"" + a + "\", "; } pos_features = pos_features.Remove(pos_features.Length - 2, 2); pos_features += "}"; neg_features = "{"; tmp = tbNegFeat.Text.Split('\n'); foreach (String a in tmp) { neg_features += "\"" + a + "\", "; } neg_features = neg_features.Remove(neg_features.Length - 2, 2); neg_features += "}"; } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } return(true); }
private void FillFields() { NpgsqlDataReader dataReader = PgSql.SelectFromWhere("*", "meeting_place", "id", id.ToString()); dataReader.Read(); for (int i = 1; i < dataReader.FieldCount; i++) { String str = dataReader[i].ToString(); StringHelper.Scorlupa(ref str, '\"'); StringHelper.Scorlupa(ref str, '{'); StringHelper.Scorlupa(ref str, '}'); StringHelper.Scorlupa(ref str, ' '); StringHelper.Scorlupa(ref str, '('); StringHelper.Scorlupa(ref str, ')'); switch (i) { case 1: String[] tmp2 = str.Split(','); StringHelper.Scorlupa(tmp2, '\"'); tbCountry.Text = tmp2[0]; tbCity.Text = tmp2[1]; tbStreet.Text = tmp2[2]; numHouse.Value = Int32.Parse(tmp2[3]); numHouse2.Value = Int32.Parse(tmp2[4]); break; case 2: cbPlaceType.SelectedIndex = Int32.Parse(str) - 1; break; case 3: cbPlaceTheme.SelectedIndex = Int32.Parse(str) - 1; break; case 4: cbPrice.Text = str; break; case 5: numRent.Value = Int32.Parse(str); break; } } dataReader.Close(); }
private bool GetInfoFromPanelControls() { try { NpgsqlDataReader dataReader = PgSql.SelectFromWhere("id", "PlaceTheme", "name", cbPlaceTheme.Text); dataReader.Read(); place_theme_id = Int32.Parse(dataReader[0].ToString()); dataReader = PgSql.SelectFromWhere("id", "PlaceType", "name", cbPlaceType.Text); dataReader.Read(); place_type_id = Int32.Parse(dataReader[0].ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } return(true); }
private void FillFields() { try { NpgsqlDataReader dataReader = PgSql.SelectFromWhere("*", "employee", "id", id.ToString()); dataReader.Read(); for (int i = 1; i < dataReader.FieldCount; i++) { String str = dataReader[i].ToString(); StringHelper.Scorlupa(ref str, '\"'); StringHelper.Scorlupa(ref str, '{'); StringHelper.Scorlupa(ref str, '}'); StringHelper.Scorlupa(ref str, ' '); StringHelper.Scorlupa(ref str, '('); StringHelper.Scorlupa(ref str, ')'); switch (i) { case 2: tbSur.Text = str; break; case 3: tbName.Text = str; break; case 4: tbPatr.Text = str; break; case 1: numClub.Value = Int32.Parse(str); break; case 5: cbPosition.SelectedIndex = Int32.Parse(str) - 1; break; case 6: numTerm.Value = Int32.Parse(str); break; case 7: numSurcharge.Value = Int32.Parse(str); break; case 8: int val; if (!Int32.TryParse(str, out val)) { val = -1; } numOrgDates.Value = val; break; case 9: int val2; if (!Int32.TryParse(str, out val2)) { val2 = -1; } numOrgContracts.Value = val2; break; } } dataReader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } }
private void FillFields() { try { NpgsqlDataReader dataReader = PgSql.SelectFromWhere("*", "meeting", "id", id.ToString()); dataReader.Read(); for (int i = 1; i < dataReader.FieldCount; i++) { String str = dataReader[i].ToString(); //Shnir.Scorlupa(ref str, '\"'); //Shnir.Scorlupa(ref str, '{'); //Shnir.Scorlupa(ref str, '}'); StringHelper.Scorlupa(ref str, ' '); //Shnir.Scorlupa(ref str, '('); //Shnir.Scorlupa(ref str, ')'); switch (i) { case 1: numClientID.Value = Int32.Parse(str); break; case 2: numPlaceID.Value = Int32.Parse(str); break; case 3: String[] tmp = str.Split('-'); numDay.Value = Int32.Parse(tmp[2]); numMonth.Value = Int32.Parse(tmp[1]); numYear.Value = Int32.Parse(tmp[0]); break; case 4: String[] tmp2 = str.Split(':'); numHours.Value = Int32.Parse(tmp2[0]); numMinutes.Value = Int32.Parse(tmp2[1]); break; case 5: if (str == "") { numDuration.Value = -1; } else { numDuration.Value = Int32.Parse(str); } break; case 6: if (str == "") { cbResult.SelectedIndex = 0; } else { cbResult.Text = str; } break; case 7: numEmployeeID.Value = Int32.Parse(str); break; } } dataReader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } }
private void FillFields() { NpgsqlDataReader dataReader = PgSql.SelectFromWhere("*", "client", "id", id.ToString()); dataReader.Read(); for (int i = 1; i < dataReader.FieldCount; i++) { String str = dataReader[i].ToString(); StringHelper.Scorlupa(ref str, '\"'); StringHelper.Scorlupa(ref str, '{'); StringHelper.Scorlupa(ref str, '}'); StringHelper.Scorlupa(ref str, ' '); StringHelper.Scorlupa(ref str, '('); StringHelper.Scorlupa(ref str, ')'); switch (i) { case 2: tbSur.Text = str; break; case 3: tbName.Text = str; break; case 4: tbPatr.Text = str; break; case 1: numClub.Value = Int32.Parse(str); break; case 5: cbGender.Text = str; break; case 6: cbNationality.SelectedIndex = Int32.Parse(str) - 1; break; case 7: String[] tmp = str.Split('-'); numDay.Value = Int32.Parse(tmp[2]); numMonth.Value = Int32.Parse(tmp[1]); numYear.Value = Int32.Parse(tmp[0]); break; case 8: String[] tmp2 = str.Split(','); StringHelper.Scorlupa(tmp2, '\"'); tbCountry.Text = tmp2[0]; tbCity.Text = tmp2[1]; tbStreet.Text = tmp2[2]; numHouse.Value = Int32.Parse(tmp2[3]); numHouse2.Value = Int32.Parse(tmp2[4]); break; case 9: if (str == "") { tbEmail.Text = ""; } else { tbEmail.Text = str; } break; case 10: tbPhone.Text = str; break; case 11: tbPass.Text = str; break; case 12: numHeight.Value = Int32.Parse(str); break; case 13: numWeight.Value = Int32.Parse(str); break; case 14: cbEyeColor.SelectedIndex = Int32.Parse(str) - 1; break; case 15: cbHairColor.SelectedIndex = Int32.Parse(str) - 1; break; case 16: if (str == "") { tbInterests.Text = ""; } else { String[] tmp3 = str.Split(','); StringHelper.Scorlupa(tmp3, '\"'); foreach (String s in tmp3) { tbInterests.Text += s + '\n'; } if (tbInterests.TextLength != 0) { tbInterests.Text = tbInterests.Text.Remove(tbInterests.TextLength - 1, 1); } } break; case 17: cbTemperament.Text = str; break; case 18: String[] tmp4 = str.Split(','); StringHelper.Scorlupa(tmp4, '\"'); foreach (String s in tmp4) { tbPosFeat.Text += s + '\n'; } if (tbPosFeat.TextLength != 0) { tbPosFeat.Text = tbPosFeat.Text.Remove(tbPosFeat.TextLength - 1, 1); } break; case 19: String[] tmp5 = str.Split(','); StringHelper.Scorlupa(tmp5, '\"'); foreach (String s in tmp5) { tbNegFeat.Text += s + '\n'; } if (tbNegFeat.TextLength != 0) { tbNegFeat.Text = tbNegFeat.Text.Remove(tbNegFeat.TextLength - 1, 1); } break; case 20: cbMartialStatus.Text = str; break; case 21: numChild.Value = Int32.Parse(str); break; case 22: cbProsperity.Text = str; break; case 23: cbPurposeofdating.Text = str; break; } } dataReader.Close(); }
private void ApplyUser(Panel users_panel) { String user, role2 = "", new_role = ""; new_role = ((ComboBox)(users_panel.Controls[1])).Text; user = ((Label)(users_panel.Controls[0])).Text; if (user == "hoba") { MessageBox.Show("Невозможно изменить учетную запись гл. администратора."); return; } //узнаем настоящую роль пользователя try { NpgsqlDataReader dataReader = PgSql.SelectFromWhere("role", "users", "login", user); if (dataReader.Read()) { role2 = dataReader[0].ToString(); } else { throw new Exception("error..."); } dataReader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if (StringHelper.TextToRole(role2) == StringHelper.TextToRole(new_role)) { MessageBox.Show("Если Вы хотите сменить роль пользователя, выберите в выпадающем списке роль, отличную от текущей."); return; } if (StringHelper.TextToRole(role) != "admin" && StringHelper.TextToRole(new_role) == "admin") { MessageBox.Show("Администратора может назначить только администратор."); return; } if (StringHelper.TextToRole(role2) == "admin" && StringHelper.TextToRole(role) != "admin") { MessageBox.Show("Администратора может переназначить только администратор."); return; } DialogResult res; if (user == curr_user) { res = MessageBox.Show(String.Format("Вы уверены, что хотите сменить свою роль с \"{1}\" на \"{2}\"? Это приведет к вашему выходу из системы.", user, StringHelper.RoleToText(role2), new_role), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } else { res = MessageBox.Show(String.Format("Вы уверены, что хотите сменить роль пользователя \"{0}\" с \"{1}\" на \"{2}\"?", user, StringHelper.RoleToText(role2), new_role), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } if (res == DialogResult.Yes) { try { PgSql.UpdateSet("users", "role", String.Format("('{0}') WHERE login = '******'", StringHelper.TextToRole(new_role), user)); ShowAllUsers(); MessageBox.Show(String.Format("Роль изменена успешно.", user)); if (user == curr_user) { this.DialogResult = DialogResult.Retry; this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { return; } }
private void DropUser(Panel users_panel) { String user, role2 = ""; user = ((Label)(users_panel.Controls[0])).Text; if (user == "hoba") { MessageBox.Show("Невозможно удалить учетную запись гл. администратора."); return; } try { NpgsqlDataReader dataReader = PgSql.SelectFromWhere("role", "users", "login", user.ToString()); if (dataReader.Read()) { role2 = dataReader[0].ToString(); } else { throw new Exception("error..."); } dataReader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if (StringHelper.TextToRole(role2) == "admin" && StringHelper.TextToRole(role) != "admin") { MessageBox.Show("Администратора может удалить только администратор."); return; } var res = DialogResult.OK; if (user == curr_user) { res = MessageBox.Show(String.Format("Вы уверены, что хотите удалить из базы данных себя (\"{0}\")?\nЭто действие приведет к выходу программы к окну авторизации.", user), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } else { res = MessageBox.Show(String.Format("Вы уверены, что хотите удалить пользователя \"{0}\" с ролью \"{1}\" из Базы Данных?", user, StringHelper.RoleToText(role2)), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } if (res == DialogResult.Yes) { try { PgSql.DeleteFromTable("users", "login", user); ShowAllUsers(); MessageBox.Show(String.Format("Пользователь {0} успешно удален", user)); if (user == curr_user) { this.DialogResult = DialogResult.Retry; this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { return; } }