コード例 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            dgvEmployee_CellClick(null, null);
            int employeeID = Convert.ToInt32(txtEmployeeID.Text);

            MessageBoxButtons buttons   = MessageBoxButtons.YesNo;
            DialogResult      isDeleted = MessageBox.Show("Are you sure want to delete this Employee?", "Delete a Employee", buttons);

            if (isDeleted == DialogResult.Yes)
            {
                int result = EmployeeBusiness.DeleteEmployee(employeeID);
                if (result == 1)
                {
                    MessageBox.Show("Deleted successfully!", "Delete a Employee");
                    pnlPostData.Hide();
                }
                else
                {
                    MessageBox.Show("Failed to delete a Employee!", "Delete a Employee");
                }
                loadData();
            }
            else
            {
            }
        }
コード例 #2
0
        public async Task DeleteEmployee_ShouldDeleteEmployee()
        {
            Mock <IEmployeeData> mock = new Mock <IEmployeeData>();
            //Arrange
            Employees employee = new Employees();

            employee.EmployeeId = 1;
            mock.Setup(x => x.DeleteEmployee(employee.EmployeeId)).ReturnsAsync("deleted");
            EmployeeBusiness employeeBusiness = new EmployeeBusiness(mock.Object);
            //Act
            string actual = await employeeBusiness.DeleteEmployee(employee.EmployeeId);

            //Assert
            Assert.AreEqual(actual, "deleted");
        }
コード例 #3
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (txtMaNV.Text != "")
            {
                int id = int.Parse(txtMaNV.Text);

                if (EB.DeleteEmployee(id))
                {
                    MessageBox.Show("Xóa thành công !");
                    DisplayData();
                    clearText();
                }
                else
                {
                    MessageBox.Show("Xóa thất bại!");
                }
            }
            else
            {
                MessageBox.Show("Xin vui lòng chọn nhân viên !");
            }
        }
コード例 #4
0
    protected void imgbtnDelete_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            ImageButton ibDelete = (ImageButton)sender;
            HiddenField hf       = (HiddenField)ibDelete.FindControl("hfEmployeeId");

            EB.DeleteEmployee(new Guid(hf.Value));
            loadData();
            pnlGreen.Visible       = true;
            lblSuccess.Text        = "An employee has been deleted successfully.";
            hplnkGreen.Text        = "Close and continue.";
            hplnkGreen.NavigateUrl = "";
        }
        catch (Exception ex)
        {
            pnlRed.Visible       = true;
            lblError.Text        = ex.Message;
            hplnkRed.Text        = "Close and continue.";
            hplnkRed.NavigateUrl = "";
        }
    }
コード例 #5
0
 public HttpResponseMessage DeleteEmployee(string id, string CreateBy)
 {
     try
     {
         var img = _userBusiness.DeleteEmployee(id, CreateBy);
         if (!string.IsNullOrEmpty(img))
         {
             string[] mang = img.Split(';');
             for (int i = 0; i < mang.Length; i++)
             {
                 if (!string.IsNullOrEmpty(mang[i]))
                 {
                     UploadFileServer.DeleteFile(mang[i]);
                 }
             }
         }
         return(Request.CreateResponse(HttpStatusCode.OK, string.Empty));
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message, ex.InnerException);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }