So I hava a page where the user gives data for the app to send it to a database.
When the user clicks on next the app navigates to the next page. But when the user goes back and edits the data the app still saves the old data from the first input to the database.
For example:
Name : Jon Do
The user made a mistake and goes to the previous pageL
Name : John Doe
The user clicks next and the data gets saved to the database. But except of saving the new data "John Doe" it sends the old data, "Jon Do". This, ofcourse, should not happen. I have no clue why this happens.
Here is my C# code of the page where the user should give his/her data
private void btnNext_Click(object sender, RoutedEventArgs e)
{
if (ckbGegevens.IsChecked == false)
{
try
{
dt.saveData = true;
dt.bedrijfsNaam = txxBvName.Text;
dt.contactPersoon = txxContPersn.Text;
dt.telNummer = Convert.ToInt32(txxTelNr.Text);
dt.eMail = txxEMail.Text;
dt.land = txxLand.Text;
dt.plaats = txxPlaats.Text;
dt.postcode = txxPostCode.Text;
postToJson.post("bvg");
this.NavigationService.Navigate(new Doelen());
}
catch (Exception)
{
MessageBox.Show("Er ontbreken gegevens!\nOf u heeft ongeldige gegevens ingevuld!");
}
}
else
{
try {
dt.bedrijfsNaam = txxBvName.Text;
dt.contactPersoon = txxContPersn.Text;
dt.telNummer = Convert.ToInt32(txxTelNr.Text);
dt.eMail = txxEMail.Text;
dt.land = txxLand.Text;
dt.plaats = txxPlaats.Text;
dt.postcode = txxPostCode.Text;
dt.saveData = false;
MessageBox.Show("Uw gegevens worden niet opgeslagen.\nVink voor optimaal gebruik deze functie aan.");
this.NavigationService.Navigate(new Doelen());
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
This is how I save it to the database:
static string bedrijfsNaam = dt.bedrijfsNaam;
static string ContPers = dt.contactPersoon;
static int TelNum = dt.telNummer;
static string email = dt.eMail;
static string Land = dt.land;
static string Plaats = dt.plaats;
static string PostCode = dt.postcode;
static string json;
static string b64encode;
public postToJson(string reqCat)
{
}
public static void post(string reqCat)
{
if (reqCat == "bvg")
{
json = "{\"bedrijfsNaam\":\"" + bedrijfsNaam + "\"," +
"\"ContPers\":\"" + ContPers + "\"," +
"\"TelNum\":\"" + TelNum + "\"," +
"\"email\":\"" + email + "\"," +
"\"Land\":\"" + Land + "\"," +
"\"Plaats\":\"" + Plaats + "\"," +
"\"PostCode\":\"" + PostCode + "\"}";
var b64bytes = System.Text.Encoding.UTF8.GetBytes(json);
b64encode = System.Convert.ToBase64String(b64bytes);
var data = new NameValueCollection();
data["b64string"] = b64encode;
data["filename"] = dt.bedrijfsNaam;
using (WebClient client = new WebClient())
{
var sendB64 = client.UploadValues("http://" + ConfigurationManager.AppSettings["scripturi"].ToString() + "SalesKicker.php", "POST", data);
}
}
}
The problem isn't in the PHP script so I don't have to post that script. I know this because I printed out the result of the JSON. Which always has the data from the first input.
Can someone please tell me what is going on here?
The assignments seem to be done in the declaration of the static class, thereby they will only happen once and you don't know when. Therefore you should put these in a separate method:
static string bedrijfsNaam = dt.bedrijfsNaam;
static string ContPers = dt.contactPersoon;
static int TelNum = dt.telNummer;
static string email = dt.eMail;
static string Land = dt.land;
static string Plaats = dt.plaats;
static string PostCode = dt.postcode;
And then call that method in the post method.
E.g.
private static void updateData() {
bedrijfsNaam = dt.bedrijfsNaam;
ContPers = dt.contactPersoon;
TelNum = dt.telNummer;
email = dt.eMail;
Land = dt.land;
Plaats = dt.plaats;
PostCode = dt.postcode;
}
Related
I'm attempting to loop through a switch in C# for a simple console application that returns data based on user input. I am new to coding. I know that the Switch works as I tested it before trying to implement my loop. But when I add the code for loop to my program I cannot get it to provide the data.
I tried taking the switch out completely and using independent If statements for each "case" but this was not working either. I'd really like to see the switch work in the loop if it's possible.
static void Main(string[] args)
{
var repeat = true;
while(repeat)
{
Console.WriteLine("Hello. Which instrument would you like to review? Type Quit to exit the program.");
string instruments = Console.ReadLine();
var action = Console.ReadLine();
if (action == instruments)
{
switch (instruments)
{
case "Jazzmaster":
string jazzmasterMake = "Fender";
string jazzmasterModel = "Jazzmaster";
string jazzmasterType = "guitar";
string jazzmasterCountry = "Japan";
int jazzmasterYear = 1997;
string jazzmasterSerial = "A019459";
string jazzmasterColor = "Sunburst";
{
Console.WriteLine("Your " + jazzmasterMake + " " + jazzmasterModel + " is a " + jazzmasterType + " made in " + jazzmasterCountry
+ " in " + jazzmasterYear + " in a " + jazzmasterColor + " color and with a serial number of " + jazzmasterSerial + ".");
}
break;
case "Jaguar":
string jaguarMake = "Fender";
string jaguarModel = "Jaguar";
string jaguarType = "guitar";
string jaguarCountry = "Japan";
int jaguarYear = 1997;
string jaguarSerial = "A035931";
string jaguarColor = "White";
{
Console.WriteLine("Your " + jaguarMake + " " + jaguarModel + " is a " + jaguarType + " made in " + jaguarCountry
+ " in " + jaguarYear + " in a " + jaguarColor + " color and with a serial number of " + jaguarSerial + ".");
}
break;
case "Stratocaster":
string stratocasterMake = "Fender";
string stratocasterModel = "Stratocaster";
string stratocasterType = "guitar";
string stratocasterCounty = "USA";
int stratocasterYear = 2018;
string stratocasterSerial = "US18004688";
string stratocasterColor = "Black";
{
Console.WriteLine("Your " + stratocasterMake + " " + stratocasterModel + " is a " + stratocasterType + " made in " + stratocasterCounty
+ " in " + stratocasterYear + " in a " + stratocasterColor + " color and with a serial number of " + stratocasterSerial + ".");
}
break;
default:
Console.WriteLine("That instrument is not in your collection.");
break;
}
}
else if (action == "Quit")
{
repeat = false;
}
}
}
}
}
Here's an alternative way of implementing your code. I post it not as a direct answer to your question, but as a way of showing an alternative to help your learning.
static void Main(string[] args)
{
Dictionary<string, Instrument> instruments = new Dictionary<string, Instrument>()
{
{ "Jazzmaster", new Instrument() { Make = "Fender", Model = "Jazzmaster", Type = "guitar", Country = "Japan", Year = 1997, Serial = "A019459", Color = "Sunburst", } },
{ "Jaguar", new Instrument() { Make = "Fender", Model = "Jaguar", Type = "guitar", Country = "Japan", Year = 1997, Serial = "A035931", Color = "White", } },
{ "Stratocaster", new Instrument() { Make = "Fender", Model = "Stratocaster", Type = "guitar", Country = "USA", Year = 2018, Serial = "US18004688", Color = "Black", } },
};
while (true)
{
Console.WriteLine("Hello. Which instrument would you like to review? Type Quit to exit the program.");
string input = Console.ReadLine();
if (input.ToLowerInvariant() == "quit")
{
break;
}
else if(instruments.ContainsKey(input))
{
Instrument instrument = instruments[input];
Console.WriteLine($"Your {instrument.Make} {instrument.Model} is a {instrument.Type} made in {instrument.Country} in {instrument.Year} in a {instrument.Color} color and with a serial number of {instrument.Serial}.");
}
else
{
Console.WriteLine("That instrument is not in your collection.");
}
}
}
public class Instrument
{
public string Make { get; init; }
public string Model { get; init; }
public string Type { get; init; }
public string Country { get; init; }
public int Year { get; init; }
public string Serial { get; init; }
public string Color { get; init; }
}
I would just remove action and instruments and the if else and just call the input you get choice, because it's what the user wants. I'm not going to recreate your whole code here, but:
static void Main(string[] args)
{
var repeat = true;
while(repeat)
{
Console.WriteLine("Hello. Which instrument would you like to review? Type Quit to exit the program.");
string choice = Console.ReadLine();
switch (choice)
{
case "Jazzmaster":
// Jazzmaster stuff
break;
case "Jaguar":
// Jaguar stuff
break;
case "Stratocaster":
// Stratocaster stuff
break;
case "Quit"
repeat = false;
break;
default:
Console.WriteLine("That instrument is not in your collection.");
break;
}
}
}
This seems much easier to understand what's going on. There are other tricks you can play to clean up your code, like creating an abstract Instrument class that overrides ToString(), to print whatever attributes you want, but that's beyond the scope of the question you've asked.
Ultimately the problem is that you're trying to get TWO inputs from your existing code.
For the code you shared, you have to to type in instrument twice to get a review. Problem is caused here:
Console.WriteLine("Hello. Which instrument would you like to review? Type Quit to exit the program.");
string instruments = Console.ReadLine();
var action = Console.ReadLine();
if (action == instruments)
Notice Console.ReadLine() is executed twice. In order to enter the if, you have to have have the two input strings that match.
I have phone numbers stored in the database, I want to retrieve all phone numbers using foreach loop and assign them to variable and send bulk sms, but problem is, I am getting only one number from database. Here is my code:
// GET: Members/SendBatch
public ActionResult SendBatch()
{
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult SendBatch(Membership member)
{
var db = new ChurchContext();
StreamReader objReader;
WebClient client = new WebClient();
string mess = member.Message;
string cell = member.Cell;
string pass = "xxxx";
string user = "xxxx";
string selectministries = member.SelectMinistries;
string pathtoministries = "";
pathtoministries = GetMinisry(selectministries);
if (pathtoministries == "Youth")
{
var youthtable = from e in db.Youths
select e;
var Entyouth = youthtable.ToList();
foreach (Youth y in Entyouth)
{
string youthcell = y.ContactMobile.ToString();
cell = youthcell;
}
}
string baseurl = "http://bulksms.2way.co.za/eapi/submission/send_sms/2/2.0?" +
"username=" + user + "&" +
"password=" + pass + "&" +
"message=" + mess + "&" +
"msisdn=" + cell;
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(baseurl);
try
{
Stream objStream;
objStream = wrGETURL.GetResponse().GetResponseStream();
objReader = new StreamReader(objStream);
objReader.Close();
}
catch (Exception ex)
{
ex.ToString();
}
return View("Index", member);
}
public static string GetMinisry(string ministry)
{
string membership = "";
switch (ministry)
{
case "Youth":
membership = "Youth";
break;
case "Children":
membership = "Children";
break;
case "Men":
membership = "Men";
break;
case "Women":
membership = "Women";
break;
case "Visitors":
membership = "Visitors";
break;
case "Members":
membership = "Members";
break;
}
return membership;
}
I would like to get all the phone numbers and assigned them to cell variable and then to sms api and send bulk sms.
Try this (dirty but will do the job):
string mess = member.Message;
string cell = member.Cell;
List<string> cellNumbers = new List<string>(); //LIST OF NUMBERs
string pass = "xxxx";
string user = "xxxx";
string selectministries = member.SelectMinistries;
string pathtoministries = "";
pathtoministries = GetMinisry(selectministries);
if (pathtoministries == "Youth")
{
var youthtable = from e in db.Youths
select e;
var Entyouth = youthtable.ToList();
foreach (Youth y in Entyouth)
{
string youthcell = y.ContactMobile.ToString();
cell = youthcell;
cellNumbers.add(cell);
}
}
foreach(string number in cellNumbers) // send all the sms
{
string baseurl = "http://bulksms.2way.co.za/eapi/submission/send_sms/2/2.0?" +
"username=" + user + "&" +
"password=" + pass + "&" +
"message=" + mess + "&" +
"msisdn=" + number;
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(baseurl);
try
{
Stream objStream;
objStream = wrGETURL.GetResponse().GetResponseStream();
objReader = new StreamReader(objStream);
objReader.Close();
}
catch (Exception ex)
{
ex.ToString();
}
}
You have a cycle where you override cell in each iteration and even though cell received all the values you need, all were overriden by the next one, except for the very last one. When the cycle is finished, you are sending the request using the very last value of cell. This is why you had the illusion that you have got a single value. Actually you have got all the values, but made the mistake of overriding them before using them. The solution is to send the request inside the cycle instead of after the cycle, like this:
// GET: Members/SendBatch
public ActionResult SendBatch()
{
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult SendBatch(Membership member)
{
var db = new ChurchContext();
StreamReader objReader;
WebClient client = new WebClient();
string mess = member.Message;
string cell = member.Cell;
string pass = "xxxx";
string user = "xxxx";
string selectministries = member.SelectMinistries;
string pathtoministries = "";
pathtoministries = GetMinisry(selectministries);
if (pathtoministries == "Youth")
{
var youthtable = from e in db.Youths
select e;
var Entyouth = youthtable.ToList();
foreach (Youth y in Entyouth)
{
string youthcell = y.ContactMobile.ToString();
cell = youthcell;
string baseurl = "http://bulksms.2way.co.za/eapi/submission/send_sms/2/2.0?" +
"username=" + user + "&" +
"password=" + pass + "&" +
"message=" + mess + "&" +
"msisdn=" + cell;
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(baseurl);
try
{
Stream objStream;
objStream = wrGETURL.GetResponse().GetResponseStream();
objReader = new StreamReader(objStream);
objReader.Close();
}
catch (Exception ex)
{
ex.ToString();
}
return View("Index", member);
}
}
}
public static string GetMinisry(string ministry)
{
string membership = "";
switch (ministry)
{
case "Youth":
membership = "Youth";
break;
case "Children":
membership = "Children";
break;
case "Men":
membership = "Men";
break;
case "Women":
membership = "Women";
break;
case "Visitors":
membership = "Visitors";
break;
case "Members":
membership = "Members";
break;
}
return membership;
}
Thanks guys, your answers solved my problem, hope future visitors to this page with similar problem will get help quickly.
I have a service that runs a c# method to sync a database with active directory at a specified interval. This code has worked in a test environment and now putting it on a different server it is returning the following message:
The server encountered an error processing the request. Please see the
service help page for constructing valid requests to the service.
The help page looks like this:
But the "SyncActiveDirectory" URI is giving me this error:
This is a new server. Maybe i am missing something that needs to be installed or a setting in IIS? Any help would be much appreciated.
EDIT:
Here is the method that called the webget:
private void SyncActiveDirectoryServiceCall()
{
WriteIntoLogFile("Start _schedulerService.SyncActiveDirectoryServiceCall()");
try
{
var reader = new AppSettingsReader();
var serviceurl = reader.GetValue("ServiceUrl", typeof(string));
var client = new RestSharp.RestClient(serviceurl.ToString());
var request = new RestSharp.RestRequest("SyncActiveDirectory", RestSharp.Method.GET);
var response = client.Execute(request);
WriteIntoLogFile(response.Content);
}
catch (WebException ex)
{
using (WebResponse response = ex.Response)
{
HttpWebResponse httpResponse = (HttpWebResponse)response;
WriteIntoLogFile("Error code: " + httpResponse.StatusCode);
using (Stream data = response.GetResponseStream())
using (var reader = new StreamReader(data))
{
string text = reader.ReadToEnd();
WriteIntoLogFile("STREAMED: " + text);
}
}
WriteIntoLogFile("TRY-CATCH: " + ex.ToString());
}
WriteIntoLogFile("End _schedulerService.SyncActiveDirectoryServiceCall()");
}
And here is the method being called:
namespace SyncActiveDirectory
{
public class SyncLocalWithLDAP : ISyncLocalWithLDAP
{
private List<GenericUser> users { get; set; }
private List<GenericUser> roles { get; set; }
[WebGet(UriTemplate = "SyncActiveDirectory")]
public void SyncActiveDirectory()
{
string constr = GetConnectionStringValue("ProteusMMXCustomerDB");
string usr = GetAppsettingValue("ldap_login_username");
string pss = GetAppsettingValue("ldap_login_password");
string filePath = string.Empty;
ActiveDirectoryWrapper wrapper = new ActiveDirectoryWrapper();
if (!Directory.Exists(WebConfigurationManager.AppSettings["LogFolderPath"] + "ServiceLog"))
{
Directory.CreateDirectory(WebConfigurationManager.AppSettings["LogFolderPath"] + "ServiceLog");
}
if (!File.Exists(WebConfigurationManager.AppSettings["LogFolderPath"] + "ServiceLog" + "/" + "SyncLog.txt"))
{
File.Create(WebConfigurationManager.AppSettings["LogFolderPath"] + "ServiceLog" + "/" + "SyncLog.txt").Dispose();
}
filePath = WebConfigurationManager.AppSettings["LogFolderPath"] + "ServiceLog" + #"\" + "SyncLog.txt";
using (StreamWriter w = File.AppendText(filePath))
{
Log("Constr - " + constr + " , u - " + usr + " p - " + pss, w);
try
{
Log("Start sync outer", w);
SyncLocalWithLDAP_Users_Roles(constr, usr, pss, w);
Log("End sync outer", w);
}
catch (Exception ex)
{
Log("Error: " + ex.Message, w);
}
}
}
EDIT:
Pic of htm file added to that directory.
EDIT:
If this helps here is Chrome Developer Tools headers:
On button click I want the user to redirect to payumoney gateway and if payment has been done successfully, the data of user to be store in database and redirect user to success page vice a versa..
Currently I am saving data using AJAX call and redirect user on ajax success:function.
AJAX
$('#payNowButton').on("click", function () {
var total = $('#main_total_s5').html();
console.log("Total : " + total);
$.ajax({
url: '/Home/Demo?total=' + total, //Demo method in Home Controller is for payumoney payment gateway.
type: "POST",
data: total,
async: false,
success: function (result) {
window.location.href = result;
if (result > 0) {
PlaceOrder(); //after successful payment, it will call this function to save data in database.
window.location.href = '#Url.Action("Sucess", "Home")';
}
else {
alert("Some error occurred." + result);
}
},
error: function (result) {
window.location.href = '#Url.Action("Failure", "Home")';
}
});
});
Controller
[HttpPost]
public void Demo(OrderCustom orderCustom)
{
string firstName = "";
string amount = "";
string productInfo = "";
string email = "";
string phone = "";
string surl;
string furl;
RemotePost myremotepost = new RemotePost();
string key = "";
string salt = "";
//posting all the parameters required for integration.
myremotepost.Url = "https://secure.payu.in/_payment";
myremotepost.Add("key", "");
string txnid = Generatetxnid();
myremotepost.Add("txnid", txnid);
myremotepost.Add("amount", amount);
myremotepost.Add("productinfo", productInfo);
myremotepost.Add("firstname", firstName);
myremotepost.Add("phone", phone);
myremotepost.Add("email", email);
myremotepost.Add("surl", "http://localhost:/Home/Sucess");//Change the success url here depending upon the port number of your local system.
myremotepost.Add("furl", "http://localhost:/Home/Failure");//Change the failure url here depending upon the port number of your local system.
myremotepost.Add("service_provider", "payu_paisa");
string hashString = key + "|" + txnid + "|" + amount + "|" + productInfo + "|" + firstName + "|" + email + "|||||||||||" + salt;
string hash = Generatehash512(hashString);
myremotepost.Add("hash", hash);
myremotepost.Post();
}
public class RemotePost
{
private System.Collections.Specialized.NameValueCollection Inputs = new System.Collections.Specialized.NameValueCollection();
public string Url = "";
public string Method = "post";
public string FormName = "form1";
public void Add(string name, string value)
{
Inputs.Add(name, value);
}
public void Post()
{
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.Write("<html><head>");
System.Web.HttpContext.Current.Response.Write(string.Format("</head><body onload=\"document.{0}.submit()\">", FormName));
System.Web.HttpContext.Current.Response.Write(string.Format("<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >", FormName, Method, Url));
for (int i = 0; i < Inputs.Keys.Count; i++)
{
System.Web.HttpContext.Current.Response.Write(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\">", Inputs.Keys[i], Inputs[Inputs.Keys[i]]));
}
System.Web.HttpContext.Current.Response.Write("</form>");
System.Web.HttpContext.Current.Response.Write("</body></html>");
System.Web.HttpContext.Current.Response.End();
}
}
When I click on button it shows this error :
Error Image
I have faced the same problem yesterday. What I did i, I removed myremotepost.Add("service_provider", "payu_paisa"); and It worked!.
Also check the URL once, if you are doing it on test server then the URL would be https://test.payu.in/_payment
"Key" and "SALT" value cannot be blank, these values will be shared to you by payumoney itself.
string key = "";
string salt = "";
myremotepost.Add("service_provider", "payu_paisa");
This is Mandatory Field, Recently I am contacting with help desk they are asking for some customization. Then it will work
So I am trying to validate a string I received from a MySQL database but for some reason cannot access. I am sure this is a dumb question but can anyone help me out? I feel like it might be related to the public vs private and the static but after playing around with every combination I can think of to pass through the variables, it still keeps giving me errors. Any ideas?
string failReason = "";
int valid = 0;
public static void getNewRow()
{
try
{
string getNewRow = "SELECT * FROM appointments WHERE valid IS NULL";
DbConnection mysqlDB = new DbConnection();
MySqlCommand mysqlCommand = new MySqlCommand(getNewRow, mysqlDB.GetLocalMySQLConnection());
MySqlDataReader reader = mysqlCommand.ExecuteReader();
while (reader.Read())
{
int id = reader.GetInt32("id");
string accountID = reader.GetString("accountID");
string appDate = reader.GetString("appDate");
string appTime = reader.GetString("apptime");
string patientName = reader.GetString("patientName");
string appPhone = reader.GetString("appPhone");
string appPhone2 = reader.GetString("appPhone2");
string smsPhone = reader.GetString("smsPhone");
string special = reader.GetString("special");
string email = reader.GetString("email");
string provider = reader.GetString("provider");
string location = reader.GetString("location");
string other = reader.GetString("other");
Console.WriteLine("ID: " + id);
Console.WriteLine("AccountID: " + accountID);
Console.WriteLine("Appointment Date: " + appDate);
Console.WriteLine("Appointment Time: " + appTime);
Console.WriteLine("Patient Name: " + patientName);
Console.WriteLine("Phone 1: " + appPhone);
Console.WriteLine("Phone 2: " + appPhone2);
Console.WriteLine("SMS Phone: " + smsPhone);
Console.WriteLine("Special: " + special);
Console.WriteLine("Email: " + email);
Console.WriteLine("Provider: " + provider);
Console.WriteLine("Location: " + location);
Console.WriteLine("Other: " + other);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.InnerException);
}
}
private bool validName()
{
if (patientName.Length < 20)
{
failReason = "Bad Name";
return false;
}
else
{
return true;
}
}
private bool validName()
{
if (patientName.Length < 20)
{
failReason = "Bad Name";
return false;
}
else
{
return true;
}
}
patientName exists only within the scope of getNewRow. You need to make that a class-scoped variable (like you did with failReason if you want to use them anywhere outside of getNewRow. You can also pass them as parameters, but I don't see that your methods have parameters to begin with.
string patientName = reader.GetString("patientName");
is local to
public static void getNewRow()
make it as such:
static string failReason = "";
static int valid = 0;
static string patientName = string.Empty;
public static void getNewRow()
{
try
{
string getNewRow = "SELECT * FROM appointments WHERE valid IS NULL";
DbConnection mysqlDB = new DbConnection();
MySqlCommand mysqlCommand = new MySqlCommand(getNewRow, mysqlDB.GetLocalMySQLConnection());
MySqlDataReader reader = mysqlCommand.ExecuteReader();
while (reader.Read())
{
int id = reader.GetInt32("id");
string accountID = reader.GetString("accountID");
string appDate = reader.GetString("appDate");
string appTime = reader.GetString("apptime");
patientName = reader.GetString("patientName");
string appPhone = reader.GetString("appPhone");
string appPhone2 = reader.GetString("appPhone2");
string smsPhone = reader.GetString("smsPhone");
string special = reader.GetString("special");
string email = reader.GetString("email");
string provider = reader.GetString("provider");
string location = reader.GetString("location");
string other = reader.GetString("other");
Console.WriteLine("ID: " + id);
Console.WriteLine("AccountID: " + accountID);
Console.WriteLine("Appointment Date: " + appDate);
Console.WriteLine("Appointment Time: " + appTime);
Console.WriteLine("Patient Name: " + patientName);
Console.WriteLine("Phone 1: " + appPhone);
Console.WriteLine("Phone 2: " + appPhone2);
Console.WriteLine("SMS Phone: " + smsPhone);
Console.WriteLine("Special: " + special);
Console.WriteLine("Email: " + email);
Console.WriteLine("Provider: " + provider);
Console.WriteLine("Location: " + location);
Console.WriteLine("Other: " + other);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.InnerException);
}
}
private static bool validName()
{
if (patientName.Length < 20)
{
failReason = "Bad Name";
return false;
}
else
{
return true;
}
}
private static bool validName()
{
if (patientName.Length < 20)
{
failReason = "Bad Name";
return false;
}
else
{
return true;
}
}
You should decide to make all your methods static or not. You cannot call a non static method from a static method.