private void button17_Click(object sender, EventArgs e) { num2 = Convert.ToInt32(textBox1.Text.Trim()); MathServiceClient client = new MathServiceClient(); if (opt == "add") { textBox1.Text = client.Add(num1, num2).ToString(); } else if (opt == "sub") { textBox1.Text = client.Add(num1, num2).ToString(); } else if (opt == "multi") { textBox1.Text = client.Add(num1, num2).ToString(); } else if (opt == "div") { textBox1.Text = client.Add(num1, num2).ToString(); } else { textBox1.Text = ""; } }
private void button_Calc_Click(object sender, EventArgs e) { var loClient = new MathServiceClient(); Int32 loNum1 = Convert.ToInt32(textBox1.Text.Trim()); Int32 loNum2 = Convert.ToInt32(textBox2.Text.Trim()); switch (comboBox1.Text) { case "Add": textResult.Text = loClient.Add(loNum1, loNum2).ToString(); break; case "Subtract": textResult.Text = loClient.Subtract(loNum1, loNum2).ToString(); break; case "Multiply": textResult.Text = loClient.Multiply(loNum1, loNum2).ToString(); break; case "Divide": textResult.Text = loClient.Divide(loNum1, loNum2).ToString(); break; } }
private void btnCalc_Click(object sender, EventArgs e) { MathServiceClient msClient = new MathServiceClient(); Int32 msNum1 = Convert.ToInt32(txtNum1.Text.Trim()); Int32 msNum2 = Convert.ToInt32(txtNum2.Text.Trim()); if (cboOperation.Text == "Add") { txtResult.Text = msClient.Add(msNum1, msNum2).ToString(); } else if (cboOperation.Text == "Subtract") { txtResult.Text = msClient.Subtract(msNum1, msNum2).ToString(); } else if (cboOperation.Text == "Multiply") { txtResult.Text = msClient.Multiply(msNum1, msNum2).ToString(); } else if (cboOperation.Text == "Sin") { txtResult.Text = msClient.Sin(msNum1, msNum2).ToString(); } else { txtResult.Text = msClient.Divide(msNum1, msNum2).ToString(); } }
private void btnActoin_Click(object sender, EventArgs e) { lblResult.Text = "= ?"; Int32 lhs, rhs, ret = 0; if (Int32.TryParse(tbxLhs.Text, out lhs) == false || Int32.TryParse(tbxRhs.Text, out rhs) == false) { MessageBox.Show("Invalid Argurment"); return; } MathServiceClient client = new MathServiceClient(); if (cmbOperation.Text == "+") { ret = client.Add(lhs, rhs); } else if (cmbOperation.Text == "-") { ret = client.Subtract(lhs, rhs); } else if (cmbOperation.Text == "*") { ret = client.Multify(lhs, rhs); } else if (cmbOperation.Text == "/") { ret = client.Divide(lhs, rhs); } lblResult.Text = string.Format("= {0}", ret); }
private void button1_Click(object sender, EventArgs e) { int locNum1 = Convert.ToInt32(textBox2.Text.Trim()); int locNum2 = Convert.ToInt32(textBox3.Text.Trim()); textBox4.Text = localClient.Add(locNum1, locNum2).ToString(); }
private void buttonCalc_Click(object sender, EventArgs e) { MathServiceClient loClient = new MathServiceClient(); Int32 loNum1 = Convert.ToInt32(textBoxNum1.Text.Trim()); Int32 loNum2 = Convert.ToInt32(textBoxNum2.Text.Trim()); if (comboBoxOperator.Text == "Add") { textBoxResult.Text = loClient.Add(loNum1, loNum2).ToString(); } else if (comboBoxOperator.Text == "Subtract") { textBoxResult.Text = loClient.Subtract(loNum1, loNum2).ToString(); } else if (comboBoxOperator.Text == "Multiply") { textBoxResult.Text = loClient.Multiply(loNum1, loNum2).ToString(); } else { textBoxResult.Text = loClient.Divide(loNum1, loNum2).ToString(); } }
static void Main(string[] args) { MathServiceClient srvClient = new MathServiceClient(); int number1 = 10; int number2 = 2; Console.WriteLine("Hank sold {0} marbles for $ {1} each and earned $ {2} in total\n", number1.ToString(), number2.ToString(), srvClient.Multiply(number1, number2).ToString()); Console.WriteLine("Suzy splitted her {0} sweets in {1}, to share with her friend.\nNow they have {2} sweets each\n", number1.ToString(), number2.ToString(), srvClient.Devide(number1, number2).ToString()); Console.WriteLine("John had {0} stanps. His grandpa gave him {1} more. Now he has {2} stamps\n", number1.ToString(), number2.ToString(), srvClient.Add(number1, number2).ToString()); Console.WriteLine("Sam owned {0} rabbits and {1} rabbits died last week.\nNow he owns {2} rabbits.", number1.ToString(), number2.ToString(), srvClient.Subtract(number1, number2).ToString()); }
private void btnCalc_Click(object sender, EventArgs e) { MathServiceClient msClient = new MathServiceClient(); try { Int32 msNum1 = Convert.ToInt32(txtNum1.Text.Trim()); Int32 msNum2 = Convert.ToInt32(txtNum2.Text.Trim()); if (cboOperation.Text == "Add") { txtResult.Text = msClient.Add(msNum1, msNum2).ToString(); } else if (cboOperation.Text == "Subtract") { txtResult.Text = msClient.Subtract(msNum1, msNum2).ToString(); } else if (cboOperation.Text == "Multiply") { txtResult.Text = msClient.Multiply(msNum1, msNum2).ToString(); } else if (cboOperation.Text == "Divide") { txtResult.Text = msClient.Divide(msNum1, msNum2).ToString(); } else { MessageBox.Show("Please select an operator."); } } catch (Exception ex) { MessageBox.Show("Error. Please enter a valid value. Error Message: " + ex.Message); } }
static void Main(string[] args) { SchoolServiceClient proxy = new SchoolServiceClient(); var newStudent = proxy.AddStudent("A123456", "Smith", "Bill", DateTime.Parse("2/3/1977"), GenderEnum.Male, "Communication", 33f, 3.5f); //Console.WriteLine(newStudent.ID + " " + newStudent.LastName + " " + newStudent.FirstName + " " + newStudent.DOB + " " + newStudent.Gender + " " + newStudent.Major + newStudent.Units + " " + newStudent.GPA); newStudent = proxy.AddStudent("B435345", "Williams", "Bill", DateTime.Parse("1/3/1988"), GenderEnum.Male, "Computer Science", 31f, 2.5f); //Console.WriteLine(newStudent.ID + " " + newStudent.LastName + " " + newStudent.FirstName + " " + newStudent.DOB + " " + newStudent.Gender + " " + newStudent.Major + newStudent.Units + " " + newStudent.GPA); newStudent = proxy.AddStudent("D777666", "Francis", "Jill", DateTime.Parse("8/8/1982"), GenderEnum.Female, "Math", 22f, 3.9f); //Console.WriteLine(newStudent.ID + " " + newStudent.LastName + " " + newStudent.FirstName + " " + newStudent.DOB + " " + newStudent.Gender + " " + newStudent.Major + newStudent.Units + " " + newStudent.GPA); newStudent = proxy.UpdateStudent("A123456", "Smith", "Bill", DateTime.Parse("2/3/1977"), GenderEnum.Unknown, "Communication", 33f, 3.5f); var getstud = proxy.GetStudent("A123456"); var students = proxy.GetStudents(); proxy.DeleteStudent("A123456"); students = proxy.GetStudents(); var newTeacher = proxy.AddTeacher(1, "George", "Paul", DateTime.Parse("5/1/1955"), GenderEnum.Male, DateTime.Parse("5/1/1990"), 50); newTeacher = proxy.AddTeacher(2, "Byers", "Bill", DateTime.Parse("1/1/1960"), GenderEnum.Male, DateTime.Parse("1/1/1990"), 50); newTeacher = proxy.AddTeacher(3, "Lopez", "Janice", DateTime.Parse("2/1/1965"), GenderEnum.Male, DateTime.Parse("2/1/1990"), 50); var teachers = proxy.GetTeachers(); proxy.DeleteTeacher(1); teachers = proxy.GetTeachers(); proxy.GetPeople("", "Bill"); MathServiceClient proxy2 = new MathServiceClient(); double result = proxy2.Add(12.5, 2.3); Console.WriteLine(result); result = proxy2.Subtract(12.5, 2.3); Console.WriteLine(result); result = proxy2.Multiply(12.5, 2.3); Console.WriteLine(result); result = proxy2.Divide(12.5, 2.3); Console.WriteLine(result); result = proxy2.CircleArea(2.3); Console.WriteLine(result); }
private void button1_Click(object sender, EventArgs e) { MyNumbers obj = new MyNumbers(); obj.Number1 = Convert.ToInt32(textBox1.Text); obj.Number2 = Convert.ToInt32(textBox2.Text); textBox3.Text = proxy.Add(obj).ToString(); }
static void MathService() { MathServiceClient client = new MathServiceClient(); int result = client.Add(5, 6); Console.WriteLine(" Result from WCF WebService Add 5 + 6 is {0}", result); int result2 = client.Multiply(5, 6); Console.WriteLine(" Result from WCF WebService Multiply 5 * 6 is {0}", result2); int result3 = client.Subtract(10, 5); Console.WriteLine(" Result from WCF WebService Subtract 10 - 5 is {0}", result3); int result4 = client.Divide(10, 5); Console.WriteLine(" Result from WCF WebService Multiply 10 / 5 is {0}", result4); //Process.Start("https://www.youtube.com/watch?v=GzN1vHWlJjA"); }
private static int TcpMethod(int num1, int num2, int op) { int result = 0; Console.WriteLine("\nUsing TCP binding :"); MathServiceClient mathClientTcp = new MathServiceClient("NetTcpBinding_IMathService"); switch (op) { case 1: result = mathClientTcp.Add(num1, num2); break; case 2: result = mathClientTcp.Subtract(num1, num2); break; } return(result); }
private void button1_Click(object sender, EventArgs e) { MathServiceClient loClient = new MathServiceClient(); int lonum1 = Convert.ToInt32(textboxnum1.Text.Trim()); int lonum2 = Convert.ToInt32(textboxnum2.Text.Trim()); /* #pragma warning disable CS0168 // Variable is declared but never used * catch (Exception exception) #pragma warning restore CS0168 // Variable is declared but never used * { */ if (comboBox1.Text == "Add") { txtresult.Text = loClient.Add(lonum1, lonum2).ToString(); } else if (comboBox1.Text == "Subtract") { txtresult.Text = loClient.Subtract(lonum1, lonum2).ToString(); } else if (comboBox1.Text == "Multiply") { txtresult.Text = loClient.Multiply(lonum1, lonum2).ToString(); } else { if (lonum2 == 0) { txtresult.Text = "Error"; } else { txtresult.Text = loClient.Divide(lonum1, lonum2).ToString(); } } }
/// <summary> /// Main entry method for the TestClient program /// </summary> /// <param name="args">No input arguments utilizied</param> static void Main(string[] args) { // Creates Proxy to Math Service MathServiceClient proxy = new MathServiceClient(); // Math Service Operations Test: Add Console.WriteLine("====== Math Operations Test ======"); Console.WriteLine("Adding 12.5 + 2.3"); double result = proxy.Add(12.5, 2.3); Console.WriteLine(result); // Math Service Operations Test: Subtract Console.WriteLine("Subtracting 12.5 - 2.3"); result = proxy.Subtract(12.5, 2.3); Console.WriteLine(result); // Math Service Operations Test: Multiply Console.WriteLine("Multiplying 12.5 * 2.3"); result = proxy.Multiply(12.5, 2.3); Console.WriteLine(result); // Math Service Operations Test: Divide Console.WriteLine("Dividing 12.5 / 2.3"); result = proxy.Divide(12.5, 2.3); Console.WriteLine(result); // Math Service Operations Test: Circle Area Console.WriteLine("====== Circle Area Test ======"); Console.WriteLine("Area of circle with radius 12.5"); result = proxy.CircleArea(12.5); Console.WriteLine(result); Console.WriteLine("Area of circle with radius 2.3"); result = proxy.CircleArea(2.3); Console.WriteLine(result); // Wait for user to read output Console.ReadLine(); } // end of main method
private static int HttpMethod(int num1, int num2, int op) { int result = 0; Console.WriteLine("\nUsing HTTP binding :"); MathServiceClient mathClientHttp = new MathServiceClient("BasicHttpBinding_IMathService"); //Added to suppress certificate validation at client side. ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => ValidateCert(sender, certificate, chain, sslPolicyErrors); switch (op) { case 1: result = mathClientHttp.Add(num1, num2); break; case 2: result = mathClientHttp.Subtract(num1, num2); break; } return(result); }
/// <summary> /// Main entry method for the Program /// </summary> /// <param name="args">No command line arguments used</param> static void Main(string[] args) { // Creates Proxy to School Service SchoolServiceClient proxy = new SchoolServiceClient(); #region Student Test // Student Test Console.WriteLine(new string('=', 24)); Console.WriteLine("= Student Service Test ="); Console.WriteLine(new string('=', 24)); Console.WriteLine(); Console.WriteLine("Adding new students..."); Console.WriteLine(); Student newStudent = proxy.AddStudent("Smith", "Bill", DateTime.Parse("2/3/1977"), GenderEnum.Male, "A123456", "Communication", 33f, 3.5f); newStudent = proxy.AddStudent("Williams", "Bill", DateTime.Parse("1/3/1988"), GenderEnum.Male, "B435345", "Computer Science", 31f, 2.5f); newStudent = proxy.AddStudent("Francis", "Jill", DateTime.Parse("8/8/1982"), GenderEnum.Female, "D777666", "Math", 22f, 3.9f); newStudent = proxy.AddStudent("West", "Kathleen", DateTime.Parse("1/19/1981"), GenderEnum.Female, "D777777", "C# Programming", 25f, 4.0f); newStudent = proxy.AddStudent("West", "Jared", DateTime.Parse("9/18/1978"), GenderEnum.Male, "D777778", "Graphic Design", 33f, 2.9f); newStudent = proxy.AddStudent("West", "KathieOpps", DateTime.Parse("11/01/2018"), GenderEnum.Unknown, "D777779", "Forgetfullness", 1f, 1.9f); List <Student> students = proxy.GetStudents(); PrintStudents(students); Console.WriteLine(); Console.WriteLine("Getting Student D777779..."); Console.WriteLine(); Student student = proxy.GetStudent("D777779"); PrintPerson(student); Console.WriteLine(); Console.WriteLine("Updating Student D777779..."); Console.WriteLine(); student = proxy.UpdateStudent("West", "Kathleen", DateTime.Parse("01/19/1981"), GenderEnum.Female, "D777779", "Electrical Engineering", 150f, 3.3f); PrintPerson(student); Console.WriteLine(); Console.WriteLine("Deleting Student D777779..."); Console.WriteLine(); proxy.DeleteStudent("D777779"); students = proxy.GetStudents(); PrintStudents(students); #endregion Student Test #region Teacher Test // Student Test Console.WriteLine(new string('=', 24)); Console.WriteLine("= Teacher Service Test ="); Console.WriteLine(new string('=', 24)); Console.WriteLine(); Console.WriteLine("Adding new teachers..."); Console.WriteLine(); Teacher newTeacher = proxy.AddTeacher("Smith", "Bill", DateTime.Parse("2/3/1977"), GenderEnum.Male, 1111111, DateTime.Parse("1/1/2018"), 25000); newTeacher = proxy.AddTeacher("Williams", "Bill", DateTime.Parse("1/3/1988"), GenderEnum.Male, 2111111, DateTime.Parse("2/1/2018"), 35000); newTeacher = proxy.AddTeacher("Francis", "Jill", DateTime.Parse("8/8/1982"), GenderEnum.Female, 3111111, DateTime.Parse("3/1/2018"), 45000); newTeacher = proxy.AddTeacher("West", "Kathleen", DateTime.Parse("1/19/1981"), GenderEnum.Female, 4111111, DateTime.Parse("4/1/2018"), 95000); newTeacher = proxy.AddTeacher("West", "Jared", DateTime.Parse("9/18/1978"), GenderEnum.Male, 5111111, DateTime.Parse("5/1/2018"), 75000); newTeacher = proxy.AddTeacher("West", "Kathleen", DateTime.Parse("01/19/1981"), GenderEnum.Female, 6111111, DateTime.Parse("6/1/2018"), 1000); List <Teacher> teachers = proxy.GetTeachers(); PrintTeachers(teachers); Console.WriteLine(); Console.WriteLine("Getting Teacher 6111111..."); Console.WriteLine(); Teacher teacher = proxy.GetTeacher(6111111); PrintPerson(teacher); Console.WriteLine(); Console.WriteLine("Updating Teacher 6111111..."); Console.WriteLine(); teacher = proxy.UpdateTeacher("West", "KathieOpps", DateTime.Parse("11/01/2018"), GenderEnum.Unknown, 6111111, DateTime.Parse("6/1/2018"), 5000); PrintPerson(teacher); Console.WriteLine(); Console.WriteLine("Deleting Teacher 6111111..."); Console.WriteLine(); proxy.DeleteTeacher(6111111); teachers = proxy.GetTeachers(); PrintTeachers(teachers); #endregion Teacher Test #region People Test // People Test Console.WriteLine(new string('=', 23)); Console.WriteLine("= People Service Test ="); Console.WriteLine(new string('=', 23)); Console.WriteLine(); Console.WriteLine("Getting people Kathleen West..."); Console.WriteLine(); PersonList people = new PersonList(); people = proxy.GetPeople("West", "Kathleen"); PrintPeople(people); Console.WriteLine(); Console.WriteLine("Getting people Bill Smith..."); Console.WriteLine(); people = proxy.GetPeople("Smith", "Bill"); PrintPeople(people); Console.WriteLine(); #endregion People Test #region Math Service Test // Creates Proxy to Math Service MathServiceClient mathproxy = new MathServiceClient(); // Math Service Operations Test: Add Console.WriteLine("====== Math Operations Test ======"); Console.WriteLine("Adding 12.5 + 2.3"); double result = mathproxy.Add(12.5, 2.3); Console.WriteLine(result); // Math Service Operations Test: Subtract Console.WriteLine("Subtracting 12.5 - 2.3"); result = mathproxy.Subtract(12.5, 2.3); Console.WriteLine(result); // Math Service Operations Test: Multiply Console.WriteLine("Multiplying 12.5 * 2.3"); result = mathproxy.Multiply(12.5, 2.3); Console.WriteLine(result); // Math Service Operations Test: Divide Console.WriteLine("Dividing 12.5 / 2.3"); result = mathproxy.Divide(12.5, 2.3); Console.WriteLine(result); // Math Service Operations Test: Circle Area Console.WriteLine("====== Circle Area Test ======"); Console.WriteLine("Area of circle with radius 12.5"); result = mathproxy.CircleArea(12.5); Console.WriteLine(result); Console.WriteLine("Area of circle with radius 2.3"); result = mathproxy.CircleArea(2.3); Console.WriteLine(result); #endregion Math Service Test Console.WriteLine("Press <Enter> to Quit..."); Console.ReadLine(); } // end of method