示例#1
0
        protected void Employee_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            var employeeID = new Guid(e.Keys[0].ToString());

            var service = new AF.Transaction.Sample.TransactionService.WCFTransactionDemoClient();

            service.DeleteEmployee(employeeID);

            Session["employee"] = null;
            BindEmployeeGrid();
        }
示例#2
0
        private void BindEmployeeGrid()
        {
            List <WCFTransactionEntity> empList;

            if (Session["employee"] == null)
            {
                var service = new AF.Transaction.Sample.TransactionService.WCFTransactionDemoClient();
                empList             = service.GetEmployeeList().ToList <WCFTransactionEntity>();
                Session["employee"] = empList;
            }
            else
            {
                empList = Session["employee"] as List <WCFTransactionEntity>;
            }

            Employee.DataSource = empList;
            Employee.DataBind();
        }
示例#3
0
        protected void Employee_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            var     employeeID = new Guid(e.Keys[0].ToString());
            TextBox Address    = (TextBox)Employee.Rows[e.RowIndex].FindControl("txtAddress");
            TextBox EMail      = (TextBox)Employee.Rows[e.RowIndex].FindControl("txtEMail");
            TextBox Phone      = (TextBox)Employee.Rows[e.RowIndex].FindControl("txtPhone");

            var emp = new WCFTransactionEntity {
                EmpID = employeeID, Address = Address.Text, EMail = EMail.Text, Phone = Phone.Text
            };

            var service = new AF.Transaction.Sample.TransactionService.WCFTransactionDemoClient();
            var result  = service.UpdateEmployee(emp);

            Employee.EditIndex  = -1;
            Session["employee"] = null;
            BindEmployeeGrid();
        }
示例#4
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var employeeEntity = new WCFTransactionEntity();

            employeeEntity.EmpID   = Guid.NewGuid();
            employeeEntity.Name    = txtName.Text;
            employeeEntity.Address = txtAddress.Text;
            employeeEntity.Phone   = txtPhone.Text;
            employeeEntity.EMail   = txtEMail.Text;

            try
            {
                var service = new AF.Transaction.Sample.TransactionService.WCFTransactionDemoClient();
                var result  = service.AddEmployee(employeeEntity);
                Session["employee"] = null;
                BindEmployeeGrid();

                if (result.IsValid)
                {
                    lblMessage.ForeColor = Color.Black;
                    txtName.Text         = String.Empty;
                    txtAddress.Text      = String.Empty;
                    txtPhone.Text        = String.Empty;
                    txtEMail.Text        = String.Empty;
                    lblMessage.Text      = "Record added successfuly";
                }
                else
                {
                    lblMessage.ForeColor = Color.Red;
                    foreach (var msg in result.Message)
                    {
                        lblMessage.Text = msg + "<br/>";
                    }
                }
            }
            catch (Exception ex)
            {
                //Log Error
            }
        }