Example #1
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();
        }
Example #2
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();
        }
Example #3
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();
        }
Example #4
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();
        }
Example #5
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();
        }
Example #6
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();
        }
Example #7
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();
        }
Example #8
0
        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;
            }
        }