Beispiel #1
0
        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();
        }
Beispiel #2
0
 private void btnDeleteClient_Click(object sender, EventArgs e)
 {
     if (chosenId >= 0)
     {
         if (currTable == CurrentTable.ClientList)
         {
             MessageBox.Show("Невозможно удалить запись. Попробуйте удалить ее аналог по id в меню \"Клиенты\" в главном меню.");
             return;
         }
         var answer = MessageBox.Show("Вы уверены что хотите удалить запись с id " + chosenId.ToString() + "?", "Удалить?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (answer == DialogResult.Yes && currTableStringName != "pare")
         {
             try
             {
                 PgSql.DeleteFromTableById(currTableStringName, chosenId);
             }
             catch (NpgsqlException ex)
             {
                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
             catch
             {
                 MessageBox.Show("Не удалось удалить.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
             RefreshTable();
         }
     }
 }
Beispiel #3
0
 private void SetComboBoxes()
 {
     try
     {
         NpgsqlDataReader dataReader = PgSql.SelectFrom("name", "nationality");
         while (dataReader.Read())
         {
             cbNationality.Items.Add(dataReader[0].ToString());
         }
         dataReader = PgSql.SelectFrom("color", "Eyecolor");
         while (dataReader.Read())
         {
             cbEyeColor.Items.Add(dataReader[0].ToString());
         }
         dataReader = PgSql.SelectFrom("color", "Haircolor");
         while (dataReader.Read())
         {
             cbHairColor.Items.Add(dataReader[0].ToString());
         }
         foreach (Control c in pnlControls.Controls)
         {
             if (c.GetType().Equals(cbEyeColor.GetType()))
             {
                 ((ComboBox)(c)).SelectedIndex = 0;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         this.Close();
     }
 }
Beispiel #4
0
        private void btnAction_Click(object sender, EventArgs e)
        {
            try
            {
                switch (at)
                {
                case ActionType.Insert:
                    if (!GetInfoFromPanelControls())
                    {
                        return;
                    }
                    PgSql.InsertIntoValues("Employee", String.Format("DEFAULT, {0}, '{1}', '{2}', '{3}', {4}, {5}, {6}, {7}, {8}", numClub.Value.ToString(), tbSur.Text, tbName.Text, tbPatr.Text, position_id, numTerm.Value.ToString(), numSurcharge.Value.ToString(), (numOrgDates.Value == -1) ? "NULL" : numOrgDates.Value.ToString(), (numOrgContracts.Value == -1) ? "NULL" : numOrgContracts.Value.ToString()));
                    break;

                case ActionType.Update:
                    if (!GetInfoFromPanelControls())
                    {
                        return;
                    }
                    PgSql.UpdateSet("employee", "club_department_id, surname, name, patronymic, position, term_of_work, surcharge, num_of_organized_visits, num_of_contracts", String.Format("( {0}, '{1}', '{2}', '{3}', {4}, {5}, {6}, {7}, {8}) WHERE id = {9}", numClub.Value.ToString(), tbSur.Text, tbName.Text, tbPatr.Text, position_id, numTerm.Value.ToString(), numSurcharge.Value.ToString(), (numOrgDates.Value == -1) ? "NULL" : numOrgDates.Value.ToString(), (numOrgContracts.Value == -1) ? "NULL" : numOrgContracts.Value.ToString(), id));
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            MessageBox.Show(String.Format("Success.", at.ToString()));
            this.Close();
        }
Beispiel #5
0
 private void GetPare()
 {
     try
     {
         NpgsqlDataReader dataReader = PgSql.HasFunctionGetParePrivileges();
         if (dataReader.Read())
         {
             if (dataReader[0].ToString() == "t")
             {
                 dataReader.Close();
                 GetPare gp = new GetPare();
                 gp.ShowDialog();
             }
             else
             {
                 dataReader.Close();
                 MessageBox.Show("Нет доступа к функции get_pare(int)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             throw new Exception("error");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #6
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (tbLogin.Text == "" || tbPass.Text == "" || tbPass2.Text == "")
     {
         MessageBox.Show("Пожалуйста, заполните все поля регистрационной формы.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     else if (tbPass.Text != tbPass2.Text)
     {
         MessageBox.Show("Введенные вами пароли не совпадают. Проверьте правильность введенных данных.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     else if (curr_role != "admin" && StringHelper.TextToRole(cbRole.Text) == "admin")
     {
         MessageBox.Show("Невозможно создать пользователя с ролью администратора, не будучи администратором.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     else
     {
         try
         {
             PgSql.ConnectToUsersDB(curr_role, curr_pass);
             PgSql.InsertIntoValues("users", String.Format("'{0}', '{1}', '{2}'", tbLogin.Text, Crypter.Encrypt(tbPass.Text), StringHelper.TextToRole(cbRole.Text)));
             MessageBox.Show("Пользователь создан с правами \" " + cbRole.Text + "\". Теперь он можете войти, используя свой логин и пароль.");
             this.Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             return;
         }
     }
 }
 private void Search()
 {
     try
     {
         NpgsqlDataReader dataReader = PgSql.GetContactReport();
         dataGridView.RowCount    = 0;
         dataGridView.ColumnCount = dataReader.FieldCount;
         int row = 0;
         while (dataReader.Read())
         {
             int cell = 0;
             dataGridView.RowCount++;
             for (int i = 0; i < dataReader.FieldCount; i++)
             {
                 dataGridView.Columns[i].HeaderText       = dataReader.GetName(i);
                 dataGridView.Rows[row].Cells[cell].Value = dataReader[i].ToString();
                 cell++;
             }
             dataGridView.Rows[row].HeaderCell.Value = (row + 1).ToString();
             row++;
         }
         dataReader.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #8
0
        private void SetComboBoxes()
        {
            try
            {
                NpgsqlDataReader dataReader = PgSql.SelectFrom("name", "placetype");
                cbPlaceTheme.Items.Clear();
                cbPlaceType.Items.Clear();
                while (dataReader.Read())
                {
                    String s = dataReader[0].ToString();
                    cbPlaceType.Items.Add(s);
                    //MessageBox.Show(dataReader[0].ToString());
                }
                dataReader.Close();

                dataReader = PgSql.SelectFrom("name", "placetheme");
                while (dataReader.Read())
                {
                    this.cbPlaceTheme.Items.Add(dataReader[0].ToString());
                    //MessageBox.Show(dataReader[0].ToString());
                }
                dataReader.Close();

                foreach (Control c in this.Controls.OfType <ComboBox>())
                {
                    ((ComboBox)(c)).SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
            }
        }
Beispiel #9
0
        private void btnAction_Click(object sender, EventArgs e)
        {
            try
            {
                switch (at)
                {
                case ActionType.Insert:
                    PgSql.InsertIntoValues("Meeting", String.Format("DEFAULT, {0}, {1}, '{2}.{3}.{4}', '{5}:{6}', {7}, {8}, {9}", numClientID.Value, numPlaceID.Value, numDay.Value, numMonth.Value, numYear.Value, numHours.Value, numMinutes.Value, (numDuration.Value == -1) ? "NULL" : numDuration.Value.ToString(),
                                                                    (cbResult.Text == "<NULL>") ? "NULL" : "\'" + cbResult.Text + "\'", numEmployeeID.Value));
                    break;

                case ActionType.Update:
                    PgSql.UpdateSet("Meeting", "client_id, place_id, meeting_date, meeting_time, meeting_duration, m_result, orginized_employee_id", String.Format("({0}, {1}, '{2}.{3}.{4}', '{5}:{6}', {7}, {8}, {9}) WHERE id = {10}", numClientID.Value, numPlaceID.Value, numDay.Value, numMonth.Value, numYear.Value, numHours.Value,
                                                                                                                                                                   numMinutes.Value, (numDuration.Value == -1) ? "NULL" : numDuration.Value.ToString(), (cbResult.Text == "<NULL>") ? "NULL" : "\'" + cbResult.Text + "\'", numEmployeeID.Value, id));
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            MessageBox.Show(String.Format("Success.", at.ToString()));
            this.Close();
        }
Beispiel #10
0
        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();
            }
        }
Beispiel #11
0
        public bool IsPassInDB(String Login, String Pass)
        {
            login = Login;
            PgSql.ConnectToUsersDB("reg", "reg");
            NpgsqlDataReader dataReader = PgSql.SelectRoleFromUsers(Login, Pass);

            if (dataReader.Read())
            {
                role = dataReader[0].ToString();
                return(true);
            }
            return(false);
        }
Beispiel #12
0
 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);
 }
Beispiel #13
0
 private void FillFields()
 {
     try
     {
         NpgsqlDataReader dataReader = PgSql.SelectFromWhere2("*", "pare", "client1_id", id1.ToString(), "client2_id", id2.ToString());
         dataReader.Read();
         numClientID.Text  = dataReader[0].ToString();
         numClient2Id.Text = dataReader[1].ToString();
         dataReader.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         this.Close();
     }
 }
Beispiel #14
0
        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();
        }
Beispiel #15
0
 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);
 }
Beispiel #16
0
 private void SetComboBoxes()
 {
     try
     {
         NpgsqlDataReader dataReader = PgSql.SelectFrom("name", "WorkPosition");
         while (dataReader.Read())
         {
             cbPosition.Items.Add(dataReader[0].ToString());
         }
         dataReader.Close();
         cbPosition.SelectedIndex = 0;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         this.Close();
     }
 }
Beispiel #17
0
 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);
 }
Beispiel #18
0
 private void SetComboBoxes()
 {
     try
     {
         NpgsqlDataReader dataReader = PgSql.SelectFrom("name", "nationality");
         while (dataReader.Read())
         {
             cbNationality.Items.Add(dataReader[0].ToString());
         }
         dataReader.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         this.DialogResult = DialogResult.Cancel;
         this.Close();
     }
 }
Beispiel #19
0
 private void ShowAllUsers()
 {
     y = 10;
     ClearUserButtons();
     try
     {
         PgSql.ConnectToUsersDB(role, role_pass);
         NpgsqlDataReader dataReader = PgSql.SelectFrom("login,role", "users");
         while (dataReader.Read())
         {
             CreateUsersButtons(dataReader[0].ToString(), dataReader[1].ToString());
         }
         dataReader.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         lblNoUsers.Visible    = true;
         btnRegistrate.Enabled = false;
     }
 }
Beispiel #20
0
 public void RefreshTable()
 {
     lblNoTable.Visible = false;
     try
     {
         chosenId = -1;
         NpgsqlDataReader dataReader = PgSql.SelectTable(currTable, currTableStringName, filterString);
         //PgSql.SelectAllFromWhere(currTableStringName, filterString);
         dataGridView.RowCount    = 0;
         dataGridView.ColumnCount = dataReader.FieldCount;
         int  row = 0;
         bool collumnsLocalized = false;
         while (dataReader.Read())
         {
             int cell = 0;
             dataGridView.RowCount++;
             for (int i = 0; i < dataReader.FieldCount; i++)
             {
                 if (!collumnsLocalized)
                 {
                     dataGridView.Columns[i].HeaderText = StringHelper.Localize(dataReader.GetName(i), currTable);
                 }
                 dataGridView.Rows[row].Cells[cell].Value = dataReader[i].ToString();
                 cell++;
             }
             collumnsLocalized = true;
             dataGridView.Rows[row].HeaderCell.Value = (row + 1).ToString();
             row++;
         }
         dataGridView_SelectionChanged();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         lblNoTable.Visible = true;
         dataGridView.Rows.Clear();
         dataGridView.Refresh();
     }
 }
Beispiel #21
0
        private void btnAction_Click(object sender, EventArgs e)
        {
            try
            {
                switch (at)
                {
                case ActionType.Insert:
                    if (!GetInfoFromPanelControls())
                    {
                        return;
                    }
                    PgSql.InsertIntoValues("client", String.Format("DEFAULT, {0}, '{1}', '{2}', '{3}', '{4}', {5}, '{6}.{7}.{8}', ('{9}','{10}','{11}', {12}, {13}), '{14}', '{15}', '{16}', {17}, {18}, {19}, {20}, '{21}', '{22}', '{23}', '{24}', '{25}', {26}, '{27}', '{28}'",
                                                                   numClub.Value.ToString(), tbSur.Text, tbName.Text, tbPatr.Text, cbGender.Text, nation_id, numDay.Value.ToString(), numMonth.Value.ToString(), numYear.Value.ToString(),
                                                                   tbCountry.Text, tbCity.Text, tbStreet.Text, numHouse.Value.ToString(), numHouse2.Value.ToString(), tbEmail.Text, tbPhone.Text, tbPass.Text, numHeight.Value.ToString(),
                                                                   numWeight.Value.ToString(), eyecolor_id, haircolor_id, interests, cbTemperament.Text, pos_features, neg_features, cbMartialStatus.Text, numChild.Value.ToString(), cbProsperity.Text, cbPurposeofdating.Text));
                    break;

                case ActionType.Update:
                    if (!GetInfoFromPanelControls())
                    {
                        return;
                    }
                    PgSql.UpdateSet("client", "club_department_id, surname, name, patronymic, gender, nationality, date_of_birth, address, email, phone_number, passport_id, height, weight, eye_color, hair_color, interests, temperament, positive_features, negative_features, marital_status, amount_of_children, prosperity, purpose_of_dating",
                                    String.Format("({0}, '{1}', '{2}', '{3}', '{4}', {5}, '{6}.{7}.{8}', ('{9}','{10}','{11}', {12}, {13}), '{14}', '{15}', '{16}', {17}, {18}, {19}, {20}, '{21}', '{22}', '{23}', '{24}', '{25}', {26}, '{27}', '{28}') WHERE client.id = {29}",
                                                  numClub.Value.ToString(), tbSur.Text, tbName.Text, tbPatr.Text, cbGender.Text, nation_id, numDay.Value.ToString(), numMonth.Value.ToString(), numYear.Value.ToString(),
                                                  tbCountry.Text, tbCity.Text, tbStreet.Text, numHouse.Value.ToString(), numHouse2.Value.ToString(), tbEmail.Text, tbPhone.Text, tbPass.Text, numHeight.Value.ToString(),
                                                  numWeight.Value.ToString(), eyecolor_id, haircolor_id, interests, cbTemperament.Text, pos_features, neg_features, cbMartialStatus.Text, numChild.Value.ToString(), cbProsperity.Text, cbPurposeofdating.Text, id));
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            MessageBox.Show(String.Format("Success.", at.ToString()));
            this.Close();
        }
Beispiel #22
0
        private void btnAction_Click(object sender, EventArgs e)
        {
            try
            {
                switch (at)
                {
                case ActionType.Insert:
                    PgSql.InsertIntoValues("Contract", String.Format("DEFAULT, {0}, {1}, {2}, {3}, '{4}', '{5}.{6}.{7}', {8}", numClientID.Value, (numFinalPartnerID.Value == -1) ? "NULL" : numFinalPartnerID.Value.ToString(), numEmployeeID.Value, numContractTerm.Value, cbState.Text, numDay.Value, numMonth.Value, numYear.Value, numSum.Value));
                    break;

                case ActionType.Update:
                    PgSql.UpdateSet("contract", "client_id, final_partner_id, orginized_employee_id, contract_term, state, date_of_registration, price", String.Format("({0}, {1}, {2}, {3}, '{4}', '{5}.{6}.{7}', {8}) WHERE id = {9}", numClientID.Value, (numFinalPartnerID.Value == -1) ? "NULL" : numFinalPartnerID.Value.ToString(), numEmployeeID.Value, numContractTerm.Value, cbState.Text, numDay.Value, numMonth.Value, numYear.Value, numSum.Value, id));
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            MessageBox.Show(String.Format("Success.", at.ToString()));
            this.Close();
        }
Beispiel #23
0
        private void btnAction_Click(object sender, EventArgs e)
        {
            try
            {
                switch (at)
                {
                case ActionType.Insert:
                    PgSql.InsertIntoValues("Pare", String.Format("{0}, {1}", numClientID.Value, numClient2Id.Value));
                    break;

                case ActionType.Update:
                    PgSql.UpdateSet("Pare", "client1_id, client2_id", String.Format("({0}, {1}) WHERE client1_id = {2} AND client2_id = {3}", numClientID.Value, numClient2Id.Value, id1, id2));
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            MessageBox.Show(String.Format("Success.", at.ToString()));
            this.Close();
        }
Beispiel #24
0
        private void btnAction_Click(object sender, EventArgs e)
        {
            try
            {
                switch (at)
                {
                case ActionType.Insert:
                    PgSql.InsertIntoValues("dating_club_department", String.Format("DEFAULT, '{0}', ('{1}', '{2}', '{3}', {4}, {5}), {6}", tbName.Text, tbCountry.Text, tbCity.Text, tbStreet.Text, numHouse.Value.ToString(), numHouse2.Value.ToString(), numPayment.Value.ToString()));
                    break;

                case ActionType.Update:
                    PgSql.UpdateSet("dating_club_department", "name, address, rent_cost", String.Format("('{0}', ('{1}', '{2}', '{3}', {4}, {5}), {6}) WHERE dating_club_department.id = {7}", tbName.Text, tbCountry.Text, tbCity.Text, tbStreet.Text, numHouse.Value.ToString(), numHouse2.Value.ToString(), numPayment.Value.ToString(), id));
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            MessageBox.Show(String.Format("Success.", at.ToString()));
            this.Close();
        }
Beispiel #25
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            int target_id;

            if (Int32.TryParse(tbID.Text, out target_id))
            {
                try
                {
                    NpgsqlDataReader dataReader = PgSql.GetPare(target_id);
                    dataGridView.RowCount    = 0;
                    dataGridView.ColumnCount = dataReader.FieldCount;
                    int row = 0;
                    while (dataReader.Read())
                    {
                        int cell = 0;
                        dataGridView.RowCount++;
                        for (int i = 0; i < dataReader.FieldCount; i++)
                        {
                            dataGridView.Columns[i].HeaderText       = StringHelper.Localize(dataReader.GetName(i), CurrentTable.Clients);
                            dataGridView.Rows[row].Cells[cell].Value = dataReader[i].ToString();
                            cell++;
                        }
                        dataGridView.Rows[row].HeaderCell.Value = (row + 1).ToString();
                        row++;
                    }
                    dataReader.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Введите в текстовое поле числовое значение - ID целевого клиента.");
            }
        }
Beispiel #26
0
        private void btnAction_Click(object sender, EventArgs e)
        {
            if (!GetInfoFromPanelControls())
            {
                return;
            }

            try
            {
                switch (at)
                {
                case ActionType.Insert:
                    if (!GetInfoFromPanelControls())
                    {
                        return;
                    }
                    PgSql.InsertIntoValues("meeting_place", String.Format("DEFAULT, ('{0}', '{1}', '{2}', {3}, {4}), {5}, {6}, '{7}', {8}", tbCountry.Text, tbCity.Text, tbStreet.Text, numHouse.Value, numHouse2.Value, place_type_id, place_theme_id, cbPrice.Text, numRent.Value));
                    break;

                case ActionType.Update:
                    if (!GetInfoFromPanelControls())
                    {
                        return;
                    }
                    PgSql.UpdateSet("meeting_place", "address, place_type, place_theme, price_policy,rent_cost", String.Format("(('{0}', '{1}', '{2}', {3}, {4}), {5}, {6}, '{7}', {8}) WHERE id = {9}", tbCountry.Text, tbCity.Text, tbStreet.Text, numHouse.Value, numHouse2.Value, place_type_id, place_theme_id, cbPrice.Text, numRent.Value, id));
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            MessageBox.Show(String.Format("Success.", at.ToString()));
            this.Close();
        }
Beispiel #27
0
        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();
            }
        }
Beispiel #28
0
        private void ShowButtonDescription(String buttonText)
        {
            String showtext        = "";
            String table_to_access = "none";

            if (buttonText == "Отделения")
            {
                showtext        = "Просмотр всех отделений клуба знакомств. Их название, адрес и арендная плата.";
                table_to_access = "dating_club_department";
            }
            else if (buttonText == "Клиенты")
            {
                showtext        = "Просмотр данных всех клиентов.";
                table_to_access = "client";
            }
            else if (buttonText == "Контракты")
            {
                showtext        = "Просмотр контрактов клиентов.";
                table_to_access = "contract";
            }
            else if (buttonText == "Работники")
            {
                showtext        = "Просмотр данных всех работников отделений клуба знакомств.";
                table_to_access = "employee";
            }
            else if (buttonText == "Администрирование")
            {
                showtext = "Просмотр учетных записей всех пользователей Базы Данных, изменение их ролей.";
            }
            else if (buttonText == "Свидания")
            {
                showtext        = "Просмотр всех запланированных и прошедших свиданий.";
                table_to_access = "meeting";
            }
            else if (buttonText == "Места встреч")
            {
                showtext        = "Просмотр всех зарезервированных клубом мест для свиданий клиентов.";
                table_to_access = "meeting_place";
            }
            else if (buttonText == "Пары")
            {
                showtext        = "Просмотр всех пар клиентов.";
                table_to_access = "pare";
            }
            else if (buttonText == "О программе")
            {
                showtext = "Раздел, содержащию информацию о программе.";
            }
            else if (buttonText == "Подобрать пару клиенту")
            {
                showtext = "Подобрать подходящие кандидатуры в пару клиенту по его ID.";
            }
            else if (buttonText == "Показать клиенту список")
            {
                showtext = "Показать клиенту список всех клиентов клуба, имеющих действительный контракт. В списке отсутствует личная информация.";
            }
            else if (buttonText == "Отчет по договорам")
            {
                showtext = "Вывести краткий отчет по оформленным договорам: всего, за последний месяц, завершенные, отмененные, активные.";
            }
            else if (buttonText == "Сменить пользователя")
            {
                showtext = "Выход к окну авторизации.";
            }
            else if (buttonText == "Закрыть программу")
            {
                showtext = "Завершение работы программы.";
            }

            if (table_to_access != "none")
            {
                try
                {
                    String[]      access_check     = { "SELECT", "INSERT", "UPDATE", "DELETE" };
                    String[]      access_check_rus = { "чтение", "запись", "изменение", "удаление" };
                    List <String> access_mods      = new List <string>();
                    for (int i = 0; i < access_check.Length; i++)
                    {
                        NpgsqlDataReader dataReader = PgSql.HasTablePrivileges(table_to_access, access_check[i]);

                        if (dataReader.Read())
                        {
                            if (dataReader[0].ToString() == "t")
                            {
                                access_mods.Add(access_check_rus[i]);
                            }
                        }
                        //dataReader.Close();
                    }

                    showtext += "\n\nДоступ: ";

                    if (access_mods.Count == 0)
                    {
                        showtext += "отсутствует.";
                    }
                    else
                    {
                        for (int i = 0; i < access_mods.Count; i++)
                        {
                            showtext += access_mods[i];
                            if (i != access_mods.Count - 1)
                            {
                                showtext += ", ";
                            }
                            else
                            {
                                showtext += ".";
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            lbButtonDescription.Text = showtext;
        }
Beispiel #29
0
        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();
            }
        }
Beispiel #30
0
        private void StartWork()
        {
            lblYouEntered.Text = String.Format("Вы вошли как {0} ({1})", login, StringHelper.RoleToText(role));
            role_password      = PassContainer.GetRolePasswordByRoleName(role);
            try
            {
                PgSql.ConnectToDatingClubDB(role, role_password);
            }
            catch (Exception msg)
            {
                MessageBox.Show(msg.Message);
                this.Close();
            }

            filterString = "";

            int y = 15;
            //здесь надо вызывать ф-цию GetPermissions которая будет доставать из БД
            //действия доступные пользователю. Записать их в массив

            Button bt = CreateButton("Отделения", ref y);

            bt.Click += new EventHandler(delegate { ShowDepartments(); });

            bt        = CreateButton("Работники", ref y);
            bt.Click += new EventHandler(delegate { ShowEmployees(); });

            bt        = CreateButton("Клиенты", ref y);
            bt.Click += new EventHandler(delegate { ShowClients(); });

            bt        = CreateButton("Контракты", ref y);
            bt.Click += new EventHandler(delegate { ShowContracts(); });

            bt        = CreateButton("Свидания", ref y);
            bt.Click += new EventHandler(delegate { ShowMeetings(); });

            bt        = CreateButton("Места встреч", ref y);
            bt.Click += new EventHandler(delegate { ShowMeetingPlaces(); });

            bt        = CreateButton("Пары", ref y);
            bt.Click += new EventHandler(delegate { ShowPares(); });

            bt        = CreateButton("Подобрать пару клиенту", ref y);
            bt.Click += new EventHandler(delegate { GetPare(); });

            bt        = CreateButton("Показать клиенту список", ref y);
            bt.Click += new EventHandler(delegate { GetClientList(); });

            bt        = CreateButton("Отчет по договорам", ref y);
            bt.Click += new EventHandler(delegate { GetContractReport(); });

            bt        = CreateButton("Администрирование", ref y);
            bt.Click += new EventHandler(delegate { ShowAdminPanel(); });

            bt        = CreateButton("О программе", ref y);
            bt.Click += new EventHandler(delegate { ShowHelp(); });


            AnchorAllButtons();
            gbActionButtons.Text += "(" + pnlActionButtons.Controls.Count + ") ";
        }