protected void reptEmployees_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     try
     {
         if (e.Item != null)
         {
             Literal txtEmpID = (Literal)e.Item.FindControl("lbEmpID");
             if (e.CommandName == "rowEdit")
             {
                 // You can use query string in front-end or use session
                 // Also you can encrypt a query string
                 Response.Redirect("EmpUpdate.aspx?id=" + txtEmpID.Text, false);
             }
             else if (e.CommandName == "rowDelete")
             {
                 if (EmployeeBLL.Delete(Convert.ToInt32(txtEmpID.Text)))
                 {
                     lbMsg.Text     = "The record was deleted successfully";
                     e.Item.Visible = false;
                 }
                 else
                 {
                     lbMsg.Text = "An error occurred during this operation";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         lbMsg.Text = "error";
         AppLogger.WriteLog(ex.ToString());
     }
 }
Ejemplo n.º 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                Employees       employees = new Employees();
                DataGridViewRow selected  = dgvEmployee.SelectedRows[0];
                employees.EmployeeID = (int)selected.Cells["EmployeeID"].Value;


                DialogResult result = MessageBox.Show("Departmanı Silmek İstediğinize Emin Misiniz!!!", "Çıkış Onay", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    employeeBLL.Delete(employees);
                    ListEmployee();
                }
                else
                {
                    this.Show();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
 private void buttonEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         if (dataGridViewDataEmpleado.RowCount > 0)
         {
             IdRowSelect = dataGridViewDataEmpleado.CurrentRow.Index;
             cFAT100010 Alert = new cFAT100010("INFORMACION", String.Format("¿Desea eliminar el registro {0}?", dataGridViewDataEmpleado.Rows[IdRowSelect].Cells["Id"].Value.ToString()), MessageBoxIcon.Question);
             Alert.ShowDialog();
             if (Alert.DialogResult == DialogResult.Yes)
             {
                 EmployeeML Employee = new EmployeeML
                 {
                     Id = Int32.Parse(dataGridViewDataEmpleado.Rows[IdRowSelect].Cells["Id"].Value.ToString()),
                 };
                 EmployeeBLL.Delete(Employee);
                 dataGridViewDataEmpleado.Rows.Remove(dataGridViewDataEmpleado.CurrentRow);
             }
         }
         else
         {
             cFAT100010 Alert = new cFAT100010("Información", "No hay datos", MessageBoxIcon.Information);
             Alert.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(String.Format("buttonEliminar_Click: {0}", ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 4
0
        private void splBtnDelete_Click(object sender, EventArgs e)
        {
            DialogResult result = XtraMessageBox.Show("Bạn có chắc chắn muốn xoá nhân viên " + txtEdtFullName.Text + " hay không?",
                                                      "THÔNG BÁO!",
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                if (txtEdtID.Text != "")
                {
                    employee.ID            = txtEdtID.Text;
                    dgvEmployee.DataSource = employeeBLL.Delete(employee);
                    ClearData();
                    GetAll();

                    XtraMessageBox.Show("Đã xoá thông tin nhân viên " + txtEdtFullName.Text, "THÔNG BÁO!",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    XtraMessageBox.Show("Vui lòng chọn nhân viên cần xoá", "THÔNG BÁO!",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Ejemplo n.º 5
0
 //Delete Employee [Post Request]
 public JsonResult Delete(int id)
 {
     status = employeeBll.Delete(id);
     if (status)
     {
         return(Json(1));
     }
     return(Json(0));
 }
Ejemplo n.º 6
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgv.RowCount > 0)
                {
                    if (dgv.CurrentRow != null)
                    {
                        string       pCode         = dgv.Rows[dgv.CurrentRow.Index].Cells[0].Value.ToString();
                        string       pEmployeeCode = dgv.Rows[dgv.CurrentRow.Index].Cells[1].Value.ToString();
                        DialogResult r             = CustomMessageBox.MessageBox.ShowCustomMessageBox(String.Format("{0} <{1}>", Common.clsLanguages.GetResource("CRM125"), pEmployeeCode), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO);

                        int index = (dgv.CurrentRow.Index - 1) > 0 ? (dgv.CurrentRow.Index - 1) : 0;

                        if (r == DialogResult.Yes)
                        {
                            employeeBLL.Delete(pCode);

                            if (string.IsNullOrEmpty(employeeBLL.ErrorString))
                            {
                                Display();
                                dgv.Rows[index].Selected = true;
                            }
                            else
                            {
                                //MessageBox.Show(employeeBLL.ErrorString, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM185"),
                                                                                 Common.clsLanguages.GetResource("CRM11"),
                                                                                 Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                                 Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                                return;
                            }
                        }
                    }
                    else
                    {
                        CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM306"),
                                                                         Common.clsLanguages.GetResource("CRM11"),
                                                                         Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                         Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                        return;
                    }
                }
            }
            catch (Exception)
            {
                string code = System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString();
                if (code == "-532462766")
                {
                    CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM292"),
                                                                     Common.clsLanguages.GetResource("CRM11"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                }
                return;
            }
        }
Ejemplo n.º 7
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataGridView    dgv     = this.listDataGridView[this.tabControl.SelectedIndex];
            int             index   = dgv.SelectedRows[0].Index;
            List <Employee> listEmp = (List <Employee>)dgv.DataSource;

            if (MessageBox.Show("Are you sure to delete this emloyee \"" + listEmp[index].Name + "\"", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                EmployeeBLL employeeBLL = new EmployeeBLL();
                employeeBLL.Delete(listEmp[index]);
                this.LoadData();
            }
        }
Ejemplo n.º 8
0
    /// <summary>
    /// delete一条信息从表中
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>



    protected void gvEmployeeList_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        emp.empId = Convert.ToInt32(((gvEmployeeList.Rows[e.RowIndex].FindControl("Label1") as Label).Text));
        Response.Write("<script>('删除成功!')</script>");
        if (bll.Delete(emp) == 1)
        {
            Response.Write("<script>('删除成功!')</script>");
        }
        else
        {
            Response.Write("<script>('删除失败!')</script>");
        }
    }
Ejemplo n.º 9
0
        public void TestDeleteEmployee(Employee employee, EmployeeDepartment employeeDepartment)
        {
            employeeBLL.Delete(employee);
            bool isDeleted = true;
            List <Department> departments = departmentBLL.ListDepartment();
            List <Employee>   employees   = employeeBLL.ListEmployeeByDepartment(departments[0]);

            for (int i = 0; i < employees.Count; i++)
            {
                if (employees[i].Name == employee.Name && employees[i].Username == employee.Username)
                {
                    isDeleted = false;
                }
            }
            Assert.AreEqual(true, isDeleted);
        }
Ejemplo n.º 10
0
        public void T05_DeleteEmployee(string id)
        {
            // Arrange
            Task task = new Task()
            {
                EmployeeId = id,
                TaskName   = "Task 101",
                StartTime  = DateTime.Now,
                Deadline   = DateTime.Now.AddDays(10)
            };

            task = taskBll.Create(task);
            // Act
            empBll.Delete(id);
            empBll.SaveChanges();

            // Assert
            Assert.IsNull(empBll.Read(id));
        }
Ejemplo n.º 11
0
        private void btnEmployeeDelete_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Tem certeza que deseja excluir?", "", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                Employee employee = new Employee();
                employee.ID = int.Parse(lblID.Text);

                Response response = _employeeBLL.Delete(employee);
                MessageBox.Show(response.Message);

                if (response.Success)
                {
                    this.ClearForm();
                    UpdateGrid();
                    UpdateComponentsRegister();
                }
            }
        }
Ejemplo n.º 12
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            EmployeeDto employee = ((FrameworkElement)sender).DataContext as EmployeeDto;

            if (MessageBox.Show("Are you sure you want to delete " + employee.FirstName + " " + employee.LastName + "?",
                                "Are you sure?", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                var op = EmployeeBLL.Delete(employee.Id);

                if (op.Code != "200")
                {
                    MessageBox.Show("Error : " + op.Message);
                }
                else
                {
                    MessageBox.Show("Employee is successfully deleted from table");
                    showData();
                }
            }
            ;
        }
Ejemplo n.º 13
0
        public async Task <ActionResult <Employee> > DeleteEmployee(Guid id)
        {
            try
            {
                using (employeeBLL)
                {
                    var employee = await employeeBLL.Get(id);

                    if (employee == null)
                    {
                        _logger.LogError($"Employee with id: {id}, hasn't been found in db.");
                        return(NotFound($"Employee with id: {id}, hasn't been found in db."));
                    }
                    await employeeBLL.Delete(employee);

                    return(NoContent());
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong inside DeleteEmployee action: {ex.Message}");
                return(StatusCode(500, "Internal server error"));
            }
        }
Ejemplo n.º 14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (op == Operation.Insert)
                {
                    foreach (Control c in gbInfo.Controls)
                    {
                        if (c is TextBox && c.Text == "")
                        {
                            MessageBox.Show("请输入所有值!");
                            c.Focus();
                            return;
                        }
                    }
                    em              = new Employee();
                    em.EmployeeID   = txtEmployeeID.Text;
                    em.EmployeeName = txtEmployeeName.Text;
                    if (cbSex.Text == "男")
                    {
                        em.Sex = true;
                    }
                    else
                    {
                        em.Sex = false;
                    }
                    em.Birthday = dtBirthday.Value.Date;
                    em.Brief    = txtBrief.Text;

                    if (eBLL.Insert(em))
                    {
                        MessageBox.Show("新增成功!");
                        BindData();
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (list[i].EmployeeID == em.EmployeeID)
                            {
                                dgEmployeeInfo.Rows[i].Selected = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("新增失败!");
                    }
                }
                else if (op == Operation.Update)
                {
                    if (em == null)
                    {
                        MessageBox.Show("请选择要修改的记录!");
                        return;
                    }
                    em.EmployeeName = txtEmployeeName.Text;
                    if (cbSex.Text == "男")
                    {
                        em.Sex = true;
                    }
                    else
                    {
                        em.Sex = false;
                    }
                    em.Birthday = dtBirthday.Value;
                    em.Brief    = txtBrief.Text;

                    if (eBLL.Update(em))
                    {
                        MessageBox.Show("修改成功!");
                        BindData();
                        dgEmployeeInfo.Rows[currentIndex].Selected = true;
                    }
                    else
                    {
                        MessageBox.Show("修改失败!");
                    }
                }
                else if (op == Operation.Delete)
                {
                    if (em == null)
                    {
                        MessageBox.Show("请选择要删除的记录!");
                        return;
                    }

                    if (eBLL.Delete(em))
                    {
                        MessageBox.Show("删除成功!");
                        em = null;
                    }
                    else
                    {
                        MessageBox.Show("删除失败!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// 用户单击“删除”按钮时的事件处理方法。
 /// </summary>
 private void BtnDelete_Click(object sender, EventArgs e)
 {
     EmployeeBLL.Delete(employee.Id.Value);     // 调用“业务逻辑层”的方法,删除关联对象并更新至数据库。
     FormSysMessage.ShowSuccessMsg("“员工信息”删除成功,单击“确定”按钮返回信息列表。");
     FormMain.LoadNewControl(Default.Instance); // 删除完成后,载入该模块的信息列表界面至主窗体显示。
 }
Ejemplo n.º 16
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (op == Operation.INSERT)   //新增按钮被点击
            {
                //判断是否已经输入了所有的值
                foreach (Control col in gbInfo.Controls)
                {
                    if (col is TextBox && col.Text == "")
                    {
                        MessageBox.Show("请输入所有的值", "提示");
                        return;
                    }
                }
                if (cbEmployeeSex.Text == null)
                {
                    MessageBox.Show("请输入所有的值", "提示");
                    return;
                }

                //给实体类赋值
                empl.EmployeeID   = txtEmployeeID.Text.Trim();
                empl.EmployeeName = txtEmployeeName.Text.Trim();
                if (cbEmployeeSex.Text == "男")
                {
                    empl.Sex = 1;
                }
                else
                {
                    empl.Sex = 0;
                }
                empl.Birthday = dtEmployeeBirthday.Value.Date;
                empl.Brief    = txtEmployeeBrief.Text.Trim();

                try
                {
                    //判断执行是否成功(新增)
                    if (employeeBLL.Insert(empl))
                    {
                        MessageBox.Show("新增成功!", "提示");

                        RestoreControlValue();                      //重置控件的值

                        BindDateGridView();                         //调用填充方法 重新填充DateGridView的数据(刷新结果)
                        dgEmployeeInfo.CurrentRow.Selected = false; //取消行的选中状态(第一行)

                        for (int i = 0; i < list.Count; i++)        //新增的当前行被选中
                        {
                            if (list[i].EmployeeID == empl.EmployeeID)
                            {
                                dgEmployeeInfo.Rows[i].Selected = true;
                                //自动跳转到查找到的行
                                dgEmployeeInfo.FirstDisplayedScrollingRowIndex = i;
                                break;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("新增失败!", "提示");
                        RestoreControlValue();  //重置控件的值
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            else if (op == Operation.UPDATE)
            {
                if (empl == null)
                {
                    MessageBox.Show("请选择要修改的数据!", "提示");
                }

                //给实体类赋值
                empl.EmployeeID   = txtEmployeeID.Text.Trim();
                empl.EmployeeName = txtEmployeeName.Text.Trim();
                if (cbEmployeeSex.Text == "男")
                {
                    empl.Sex = 1;
                }
                else
                {
                    empl.Sex = 0;
                }
                empl.Birthday = dtEmployeeBirthday.Value.Date;
                empl.Brief    = txtEmployeeBrief.Text.Trim();


                try
                {
                    //判断执行是否成功(更新)
                    if (employeeBLL.Update(empl))
                    {
                        MessageBox.Show("更新成功!", "提示");
                        BindDateGridView();                                     //重新填充ateGridView (刷新结果)
                        dgEmployeeInfo.CurrentRow.Selected             = false; //取消行的选中状态(第一行)
                        dgEmployeeInfo.Rows[currentRowsIndex].Selected = true;  //将当前被更新的行进行反蓝色显示
                        //自动跳转到查找到的行
                        dgEmployeeInfo.FirstDisplayedScrollingRowIndex = currentRowsIndex;
                    }
                    else
                    {
                        MessageBox.Show("更新失败!", "提示");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            else if (op == Operation.DELETE)
            {
                //弹出是否确认删除的对话框
                DialogResult result = MessageBox.Show("您是否真的要删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (result == DialogResult.Yes)
                {
                    try
                    {
                        if (employeeBLL.Delete(empl))
                        {
                            MessageBox.Show("删除成功", "提示");
                            BindDateGridView();
                            dgEmployeeInfo.CurrentRow.Selected = false;   //取消行的选中状态(第一行)

                            //直接初始化 当前窗口
                            btnNewAdd.Enabled = btnModify.Enabled = btnDelete.Enabled = true;
                            gbInfo.Visible    = false;

                            //初始化(清除)文本控件的值
                            txtEmployeeID.Text       = string.Empty;
                            txtEmployeeName.Text     = string.Empty;
                            txtEmployeeBrief.Text    = string.Empty;
                            cbEmployeeSex.Text       = null;
                            dtEmployeeBirthday.Value = DateTime.Now;
                            empl = null;
                        }
                        else
                        {
                            MessageBox.Show("删除失败!", "提示");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        return;
                    }
                }
            }
        }
Ejemplo n.º 17
0
 // DELETE api/<controller>/5
 public void Delete(string id)
 {
     empBll = new EmployeeBLL(GetXmlPath());
     empBll.Delete(id);
     empBll.SaveChanges();
 }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     MessageBox.Show(employeeBLL.Delete(employee).Message);
     dgvEmployees.DataSource = employeeBLL.GetAllEmployeesByActive().Data;
 }