Esempio n. 1
0
        public List <StaffListData> GetStaffList(BaseViewModel model)
        {
            SqlCommand    cmd;
            SqlDataReader DataReader;
            TranslationCertificateSettingsModel SettingsModel;
            List <StaffListData> retList = new List <StaffListData>();

            try
            {
                _sqlConnService.OpenConnection();
                cmd             = new SqlCommand("SP_GetStaffList", _sqlConnService.CreateConnection());
                cmd.CommandType = CommandType.StoredProcedure;
                DataReader      = cmd.ExecuteReader();
                while (DataReader.Read() == true)
                {
                    StaffListData retVal = new StaffListData();
                    if (!string.IsNullOrEmpty(DataReader["StaffNo"].ToString()))
                    {
                        retVal.StaffNo = (DataReader["StaffNo"].ToString());
                    }
                    if (!string.IsNullOrEmpty(DataReader["Name"].ToString()))
                    {
                        retVal.Name = (DataReader["Name"].ToString());
                    }
                    if (!string.IsNullOrEmpty(DataReader["BirthDate"].ToString()))
                    {
                        retVal.BirthDate = Convert.ToDateTime(DataReader["BirthDate"]);
                    }
                    if (!string.IsNullOrEmpty(DataReader["Gender"].ToString()))
                    {
                        retVal.Gender = DataReader["Gender"].ToString();
                    }
                    if (!string.IsNullOrEmpty(DataReader["PostalCode"].ToString()))
                    {
                        retVal.PostalCode = DataReader["PostalCode"].ToString();
                    }
                    if (!string.IsNullOrEmpty(DataReader["LivingCountry"].ToString()))
                    {
                        retVal.LivingCountry = DataReader["LivingCountry"].ToString();
                    }
                    retList.Add(retVal);
                }
                DataReader.Close();
            }
            catch (Exception ex)
            {
                IErrorLogService errorLog = new ErrorLogService();
                string           message  = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message;
                errorLog.SetErrorLog(model.CurrentUserID, "StaffListService", message);
                throw new Exception(message);
            }
            finally
            {
                _sqlConnService.CloseConnection();
            }
            return(retList);
        }
Esempio n. 2
0
        public List <StaffListData> GetSearchStaffList(BaseViewModel model, string con)
        {
            List <StaffListData> retList = new List <StaffListData>();
            SqlDataReader        DataReader;

            try
            {
                string branch = con.Split(',')[0];
                string type   = con.Split(',')[1];
                string eid    = con.Split(',')[2];
                string resign = con.Split(',')[3];
                string role   = con.Split(',')[4];
                string author = con.Split(',')[5];
                string ename  = con.Split(',')[6];
                _sqlConnService.OpenConnection();
                SqlCommand command = new SqlCommand("SP_GetSearchAllUser", _sqlConnService.CreateConnection());
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@CultureId", model.CurrentCulture);
                if (model.ID == Guid.Empty)
                {
                    command.Parameters.AddWithValue("@ID", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@ID", model.ID);
                }
                command.Parameters.AddWithValue("@EmployeeId", DBNull.Value);
                command.Parameters.AddWithValue("@UserTypeId", DBNull.Value);
                if (branch == "")
                {
                    command.Parameters.AddWithValue("@branch", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@branch", branch);
                }
                if (type == "")
                {
                    command.Parameters.AddWithValue("@type", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@type", type);
                }
                if (eid == "")
                {
                    command.Parameters.AddWithValue("@eid", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@eid", eid);
                }
                if (resign == "")
                {
                    command.Parameters.AddWithValue("@resign", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@resign", resign);
                }
                if (role == "")
                {
                    command.Parameters.AddWithValue("@role", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@role", role);
                }
                if (author == "")
                {
                    command.Parameters.AddWithValue("@author", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@author", author);
                }
                if (ename == "")
                {
                    command.Parameters.AddWithValue("@ename", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@ename", ename);
                }

                DataReader = command.ExecuteReader();
                while (DataReader.Read() == true)
                {
                    StaffListData retVal = new StaffListData();
                    if (!string.IsNullOrEmpty(DataReader["StaffNo"].ToString()))
                    {
                        retVal.StaffNo = (DataReader["StaffNo"].ToString());
                    }
                    if (!string.IsNullOrEmpty(DataReader["Name"].ToString()))
                    {
                        retVal.Name = (DataReader["Name"].ToString());
                    }
                    if (!string.IsNullOrEmpty(DataReader["BirthDate"].ToString()))
                    {
                        retVal.BirthDate = Convert.ToDateTime(DataReader["BirthDate"]);
                    }
                    if (!string.IsNullOrEmpty(DataReader["Gender"].ToString()))
                    {
                        retVal.Gender = DataReader["Gender"].ToString();
                    }
                    if (!string.IsNullOrEmpty(DataReader["PostalCode"].ToString()))
                    {
                        retVal.PostalCode = DataReader["PostalCode"].ToString();
                    }
                    if (!string.IsNullOrEmpty(DataReader["LivingCountry"].ToString()))
                    {
                        retVal.LivingCountry = DataReader["LivingCountry"].ToString();
                    }
                    retList.Add(retVal);
                }
                DataReader.Close();
            }
            catch (Exception ex)
            {
                IErrorLogService errorLog = new ErrorLogService();
                string           message  = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message;
                errorLog.SetErrorLog(model.CurrentUserID, "StaffListService", message);
                throw new Exception(message);
            }
            finally
            {
                _sqlConnService.CloseConnection();
            }
            return(retList);
        }