コード例 #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //Adding New Employee Records

            if ((txtCusID.Text != "") || (txtName.Text != "") || (txtEmail.Text != "") || (txtPhone.Text != ""))
            {
                try
                {
                    MyService.Customer customer = new MyService.Customer();
                    customer.CusID = txtCusID.Text;
                    customer.Name  = txtName.Text;
                    customer.Email = txtEmail.Text;
                    customer.Phone = txtPhone.Text;
                    customer.Type  = rbtnGender.SelectedItem.Text;

                    MyService.CustomerServiceClient client = new MyService.CustomerServiceClient();
                    lblMsg.Text = "Employee ID: " + customer.CusID + ", " + client.AddCustomerRecord(customer);
                }
                catch (Exception ex)
                {
                    lblMsg.Text = "Employee ID must be unique! " + ex;
                }
            }
            else
            {
                lblMsg.Text      = "All fields are mandatory! ";
                lblMsg.ForeColor = System.Drawing.Color.Red;
            }
        }
コード例 #2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            MyService.CustomerServiceClient client = new MyService.CustomerServiceClient();

            MyService.Customer employee = new MyService.Customer();
            employee.CusID = txtSearch.Text.Trim();
            string result = client.DeleteRecords(employee);

            if (result == "Record Deleted Successfully!")
            {
                BindGridData();
                lblSearchResult.Text = "Employee ID: " + txtSearch.Text.Trim() + "Deleted Successfully!";
            }
            else
            {
                lblSearchResult.Text = "Employee ID: " + txtSearch.Text.Trim() + "Not Found!";
            }
        }