private string[] GetMerchantInfo(string account) { string[] str = new string[4]; string strPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); INIManager manager = new INIManager(strPath + @"\settings.ini"); NpgsqlConnection pgsqlConnection = new NpgsqlConnection(@"Server=" + manager.GetPrivateString("Database", "id") + ";Port=" + manager.GetPrivateString("Database", "port") + ";User ID=" + manager.GetPrivateString("Database", "login") + ";Password="******"Database", "password") + ";Database=" + manager.GetPrivateString("Database", "db")); try { pgsqlConnection.Open(); NpgsqlCommand pgsqlCommand = pgsqlConnection.CreateCommand(); pgsqlCommand.CommandText = $@"select p.id as payee, p.agent_id as partner from pr_agent_info a, pr_point p where a.number_40702 = '{account}' and a.id = p.agent_info_id and p.agent_id != '119000119'"; using (DbDataReader reader = pgsqlCommand.ExecuteReader()) { if (reader.HasRows) { reader.Read(); str[0] = reader.GetValue(0).ToString(); string[] arrS = reader.GetValue(1).ToString().Split(new string[] { "000" }, StringSplitOptions.None); str[1] = arrS[0]; } } pgsqlCommand.CommandText = $@"select h.agent_kd from pr_agent h where parent_agent_id = '{str[1]}'*1000000 and h.agent_kd like 'PS%' "; using (DbDataReader reader = pgsqlCommand.ExecuteReader()) { if (reader.HasRows) { reader.Read(); string[] arrS = reader.GetValue(0).ToString().Split('S'); str[3] = arrS[1]; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { pgsqlConnection.Close(); pgsqlConnection.Dispose(); } str[2] = account; return(str); }
private string[] GetMerchantInfo(string trans) { string[] str = new string[3]; string strPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); INIManager manager = new INIManager(strPath + @"\settings.ini"); NpgsqlConnection pgsqlConnection = new NpgsqlConnection(@"Server=" + manager.GetPrivateString("Database", "id") + ";Port=" + manager.GetPrivateString("Database", "port") + ";User ID=" + manager.GetPrivateString("Database", "login") + ";Password="******"Database", "password") + ";Database=" + manager.GetPrivateString("Database", "db")); try { pgsqlConnection.Open(); NpgsqlCommand pgsqlCommand = pgsqlConnection.CreateCommand(); pgsqlCommand.CommandText = $@"select auth_agent_id from pr_trn where id = {trans}"; using (DbDataReader reader = pgsqlCommand.ExecuteReader()) { if (reader.HasRows) { reader.Read(); str[0] = reader.GetValue(0).ToString(); string[] arrS = reader.GetValue(1).ToString().Split(new string[] { "000" }, StringSplitOptions.None); str[1] = arrS[0]; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { pgsqlConnection.Close(); pgsqlConnection.Dispose(); } str[2] = trans; return(str); }
private void regButton_Click(object sender, RoutedEventArgs e) { regButton.IsEnabled = false; Merchant merchant = new Merchant(merchantTb.Text, partnerTb.Text, accountTb.Text, psTb.Text); string strPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); INIManager manager = new INIManager(strPath + @"\settings.ini"); SqlConnection sqlConnection = new SqlConnection(@"Data Source=" + manager.GetPrivateString("Database", "id") + ";Initial Catalog=" + manager.GetPrivateString("Database", "db") + ";User ID=" + manager.GetPrivateString("Database", "login") + ";Password="******"Database", "password")); try { sqlConnection.Open(); SqlCommand sqlCommand = sqlConnection.CreateCommand(); sqlCommand.CommandText = "INSERT INTO MerchInfo(PartnerID,MerchID,Account) VALUES ('" + merchant.partnerID + "','" + merchant.merchantID + "','" + merchant.account + "')"; sqlCommand.ExecuteNonQuery(); MessageBox.Show("Данные добавлены успешно"); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { sqlConnection.Close(); sqlConnection.Dispose(); } partnerTb.Text = ""; merchantTb.Text = ""; accountTb.Text = ""; regButton.IsEnabled = true; }