Пример #1
0
        protected void Employee_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            var employeeID = new Guid(e.Keys[0].ToString());

            var buisnessLayer = BLFactory.CreateTransactionEmployeeDemoBL();

            buisnessLayer.DeleteEmployee(employeeID);

            Session["employee"] = null;
            BindEmployeeGrid();
        }
Пример #2
0
        private void BindEmployeeGrid()
        {
            List <TransactionEntity> empList;

            if (Session["employee"] == null)
            {
                var buisnessLayer = BLFactory.CreateTransactionEmployeeDemoBL();
                empList             = buisnessLayer.GetEmployeeList();
                Session["employee"] = empList;
            }
            else
            {
                empList = Session["employee"] as List <TransactionEntity>;
            }

            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 TransactionEntity {
                EmpID = employeeID, Address = Address.Text, EMail = EMail.Text, Phone = Phone.Text
            };

            var buisnessLayer = BLFactory.CreateTransactionEmployeeDemoBL();
            var result        = buisnessLayer.UpdateEmployee(emp);

            Employee.EditIndex  = -1;
            Session["employee"] = null;
            BindEmployeeGrid();
        }
Пример #4
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var employeeEntity = new TransactionEntity();

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

            try
            {
                var buisnessLayer = BLFactory.CreateTransactionEmployeeDemoBL();
                var result        = buisnessLayer.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
            }
        }