示例#1
0
        /// <summary>
        /// Deletes a record from the Staff table by its primary key.
        /// </summary>
        public bool Staff_Delete(Staff.BLDAL.DTO.Staff StaffLine)
        {
            bool status = false;

            try
            {
                SqlCommand sqlCmd = new SqlCommand();
                sqlCmd.CommandType = CommandType.StoredProcedure;
                sqlCmd.CommandText = "usp_Staff_Delete";
                sqlCmd.Connection  = this._sqlConn;
                sqlCmd.Parameters.AddWithValue("@StaffID", StaffLine.StaffID);
                if (this._sqlConn.State == ConnectionState.Closed)
                {
                    this._sqlConn.Open();
                }
                int numberOfRecordsAffected = sqlCmd.ExecuteNonQuery();
                if (numberOfRecordsAffected > 0)
                {
                    status = true;
                }
                this._sqlConn.Close();
            }
            catch (Exception ex)
            {
                if (ConfigurationManager.AppSettings["RethrowErrors"] == "true")
                {
                    throw ex;
                }
                status = false;
            }
            return(status);
        }
        public static List <DTO.Staff> Staff_Search_SelectList(Staff.BLDAL.DTO.Staff _StaffLine)
        {
            List <Staff.BLDAL.DTO.Staff> StaffList = new List <Staff.BLDAL.DTO.Staff>();

            try
            {
                StaffDAL      IO       = new StaffDAL();
                SqlDataReader myReader = IO.Staff_Search_SelectList(_StaffLine);
                while (myReader.Read())
                {
                    Staff.BLDAL.DTO.Staff StaffLine = new Staff.BLDAL.DTO.Staff();
                    if (myReader["StaffID"] != DBNull.Value)
                    {
                        StaffLine.StaffID = (int)myReader["StaffID"];
                    }
                    if (myReader["LastName"] != DBNull.Value)
                    {
                        StaffLine.LastName = (string)myReader["CompanyName"];
                    }
                    if (myReader["MiddleName"] != DBNull.Value)
                    {
                        StaffLine.MiddleName = (string)myReader["Address"];
                    }
                    if (myReader["FirstName"] != DBNull.Value)
                    {
                        StaffLine.FirstName = (string)myReader["FirstName"];
                    }
                    if (myReader["Gender"] != DBNull.Value)
                    {
                        StaffLine.Gender = (string)myReader["Gender"];
                    }
                    if (myReader["Position"] != DBNull.Value)
                    {
                        StaffLine.Position = (string)myReader["Position"];
                    }
                    if (myReader["HiredDate"] != DBNull.Value)
                    {
                        StaffLine.HiredDate = (string)myReader["HiredDate"];
                    }
                    if (myReader["Salary"] != DBNull.Value)
                    {
                        StaffLine.Salary = (string)myReader["Salary"];
                    }
                    StaffList.Add(StaffLine);
                }
                myReader.Close();
            }
            catch (Exception ex)
            {
                if (ConfigurationManager.AppSettings["RethrowErrors"] == "true")
                {
                    throw ex;
                }
                return(new List <Staff.BLDAL.DTO.Staff>());
            }
            return(StaffList);
        }
示例#3
0
        public ActionResult Create(Staff.BLDAL.DTO.Staff model)
        {
            if (ModelState.IsValid)
            {
                if (StaffBLL.Staff_Insert(model))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(model));
                }
            }

            return(View(model));
        }
示例#4
0
        /// <summary>
        /// Selects a record from the Staff table by its primary key.
        /// </summary>
        public SqlDataReader Staff_Select(Staff.BLDAL.DTO.Staff StaffLine)
        {
            SqlCommand sqlCmd = new SqlCommand();

            sqlCmd.CommandType = CommandType.StoredProcedure;
            sqlCmd.CommandText = "usp_Staff_Select";
            sqlCmd.Connection  = this._sqlConn;
            sqlCmd.Parameters.AddWithValue("@StaffID", StaffLine.StaffID);
            if (this._sqlConn.State == ConnectionState.Closed)
            {
                this._sqlConn.Open();
            }
            SqlDataReader rd = sqlCmd.ExecuteReader(CommandBehavior.CloseConnection);

            return(rd);
        }
示例#5
0
        /// <summary>
        /// Saves a record to the Staff table.
        /// </summary>
        public bool Staff_Update(Staff.BLDAL.DTO.Staff StaffLine)
        {
            bool status = false;

            try
            {
                SqlCommand sqlCmd = new SqlCommand();
                sqlCmd.CommandType = CommandType.StoredProcedure;
                sqlCmd.CommandText = "usp_Staff_Update";
                sqlCmd.Connection  = this._sqlConn;
                sqlCmd.Parameters.AddWithValue("@LastName", ((StaffLine.LastName != null) ? (object)StaffLine.LastName : DBNull.Value));
                sqlCmd.Parameters.AddWithValue("@MiddleName", StaffLine.MiddleName);
                sqlCmd.Parameters.AddWithValue("@FirstName", ((StaffLine.FirstName != null) ? (object)StaffLine.FirstName : DBNull.Value));
                sqlCmd.Parameters.AddWithValue("@Gender", ((StaffLine.Gender != null) ? (object)StaffLine.Gender : DBNull.Value));
                sqlCmd.Parameters.AddWithValue("@Position", ((StaffLine.Position != null) ? (object)StaffLine.Position : DBNull.Value));
                sqlCmd.Parameters.AddWithValue("@HiredDate", ((StaffLine.HiredDate != null) ? (object)StaffLine.HiredDate : DBNull.Value));
                sqlCmd.Parameters.AddWithValue("@Salary", ((StaffLine.Salary != null) ? (object)StaffLine.Salary : DBNull.Value));
                if (this._sqlConn.State == ConnectionState.Closed)
                {
                    this._sqlConn.Open();
                }
                int numberOfRecordsAffected = sqlCmd.ExecuteNonQuery();
                if (numberOfRecordsAffected > 0)
                {
                    status = true;
                }
                this._sqlConn.Close();
            }
            catch (Exception ex)
            {
                if (ConfigurationManager.AppSettings["RethrowErrors"] == "true")
                {
                    throw ex;
                }
                status = false;
            }
            return(status);
        }
        /// <summary>
        /// Deletes a record from the Staff table by its primary key.
        /// </summary>
        public static bool Staff_Delete(Staff.BLDAL.DTO.Staff _StaffLine)
        {
            StaffDAL IO = new StaffDAL();

            return(IO.Staff_Delete(_StaffLine));
        }
        /// <summary>
        /// Saves a record to the Staff table.
        /// </summary>
        public static bool Staff_Insert(Staff.BLDAL.DTO.Staff _StaffLine)
        {
            StaffDAL IO = new StaffDAL();

            return(IO.Staff_Insert(_StaffLine));
        }