Exemplo n.º 1
0
    //修改員工資料(個人)
    public static void UpdateInfo(YenEmployee e)
    {
        using (SqlConnection cn = new SqlConnection(Common.DBConnectionString))
        {
            SqlCommand command = new SqlCommand("update Employee set Password=@Password, Mobile=@Mobile, Address=@Address, Birthdate=@Birthdate, ImageFileName=@ImageFileName where EmployeeID = @EmployeeID", cn);

            command.Parameters.AddWithValue("@EmployeeID", e.EmployeeID);
            command.Parameters.AddWithValue("@Password", e.Password);
            if (e.Mobile != null)
            {
                command.Parameters.AddWithValue("@Mobile", e.Mobile);
            }
            else
            {
                command.Parameters.AddWithValue("@Mobile", DBNull.Value);
            }
            if (e.Email != null)
            {
                command.Parameters.AddWithValue("@Email", e.Email);
            }
            else
            {
                command.Parameters.AddWithValue("@Email", DBNull.Value);
            }
            if (e.Address != null)
            {
                command.Parameters.AddWithValue("@Address", e.Address);
            }
            else
            {
                command.Parameters.AddWithValue("@Address", DBNull.Value);
            }
            if (e.BirthDate != null)
            {
                command.Parameters.AddWithValue("@BirthDate", e.BirthDate);
            }
            else
            {
                command.Parameters.AddWithValue("@BirthDate", DBNull.Value);
            }
            if (e.ImageFileName != null)
            {
                command.Parameters.AddWithValue("@ImageFileName", e.ImageFileName);
            }
            else
            {
                command.Parameters.AddWithValue("@ImageFileName", DBNull.Value);
            }
            cn.Open();
            command.ExecuteNonQuery();
            cn.Close();
        }
    }
Exemplo n.º 2
0
    //根據id修改員工資料(人事)
    public static void UpdateEmployeeByID(YenEmployee e)
    {
        using (SqlConnection cn = new SqlConnection(Common.DBConnectionString))
        {
            SqlCommand command = new SqlCommand("update Employee set Password = @Password, LastName=@LastName, FirstName=@FirstName," +
                                                " Gender=@Gender,DepartmentName=@DepartmentName,DepartmentID=@DepartmentID, AuthorizationLevel=@AuthorizationLevel, Salary=@Salary, ResignedDate=@ResignedDate," +
                                                "Mobile=@Mobile, Address=@Address where EmployeeID = @EmployeeID", cn);

            command.Parameters.AddWithValue("@EmployeeID", e.EmployeeID);
            //command.Parameters.AddWithValue("@Email", e.Email);
            command.Parameters.AddWithValue("@Password", e.Password);
            command.Parameters.AddWithValue("@LastName", e.LastName);
            command.Parameters.AddWithValue("@FirstName", e.FirstName);
            command.Parameters.AddWithValue("@Gender", e.Gender);
            command.Parameters.AddWithValue("@DepartmentName", e.DepartmentName);
            command.Parameters.AddWithValue("@DepartmentID", e.DepartmentID);
            command.Parameters.AddWithValue("@AuthorizationLevel", e.AuthorizationLevel);
            command.Parameters.AddWithValue("@Salary", e.Salary);
            if (e.ResignedDate != null)
            {
                command.Parameters.AddWithValue("@ResignedDate", e.ResignedDate);
            }
            else
            {
                command.Parameters.AddWithValue("@ResignedDate", DBNull.Value);
            }
            if (e.Mobile != null)
            {
                command.Parameters.AddWithValue("@Mobile", e.Mobile);
            }
            else
            {
                command.Parameters.AddWithValue("@Mobile", DBNull.Value);
            }
            if (e.Address != null)
            {
                command.Parameters.AddWithValue("@Address", e.Address);
            }
            else
            {
                command.Parameters.AddWithValue("@Address", DBNull.Value);
            }
            cn.Open();
            command.ExecuteNonQuery();
            cn.Close();
        }
    }
Exemplo n.º 3
0
    //修改員工資料
    public static void InsertEmployee(YenEmployee e)
    {
        using (SqlConnection cn = new SqlConnection(Common.DBConnectionString))
        {
            SqlCommand cmd = new SqlCommand(
                "insert into Employee (Email, Password, LastName, FirstName, Gender, DepartmentID, DepartmentName, AuthorizationLevel, HiredDate, Salary)"
                + "values(@Email, @Password, @LastName, @FirstName, @Gender, @DepartmentID, @DepartmentName, @AuthorizationLevel, @HiredDate, @Salary)",
                cn);

            cmd.Parameters.AddWithValue("@Email", e.Email);
            cmd.Parameters.AddWithValue("@Password", e.Password);
            cmd.Parameters.AddWithValue("@LastName", e.LastName);
            cmd.Parameters.AddWithValue("@FirstName", e.FirstName);
            cmd.Parameters.AddWithValue("@Gender", e.Gender);
            cmd.Parameters.AddWithValue("@DepartmentID", e.DepartmentID);
            cmd.Parameters.AddWithValue("@DepartmentName", e.DepartmentName);
            cmd.Parameters.AddWithValue("@AuthorizationLevel", e.AuthorizationLevel);
            cmd.Parameters.AddWithValue("@HiredDate", e.HiredDate);
            cmd.Parameters.AddWithValue("@Salary", e.Salary);

            cn.Open();
            cmd.ExecuteNonQuery();
        }
    }
Exemplo n.º 4
0
    //取回員工頭貼檔名
    public static string GetImageFileName(int id)
    {
        YenEmployee emp = GetEmployeeByID(id);

        return(emp.ImageFileName);
    }