Esempio n. 1
0
        public void GetJobPosition()
        {
            try
            {
                EPList = new List <EmployeePositionList>();
                using (var db = new LetranIntegratedSystemEntities())
                {
                    var jobpos = db.EmployeePositions.ToList();

                    foreach (var x in jobpos)
                    {
                        EmployeePositionList epl = new EmployeePositionList();
                        epl.PositionID = x.EmployeePositionID;
                        if (x.EmployeeRank != null)
                        {
                            epl.PositionRankID = x.EmployeeRank.EmployeeRankID;
                            epl.PositionRank   = x.EmployeeRank.EmployeeRankName;
                        }
                        epl.Description  = x.Description;
                        epl.IsActive     = x.Active;
                        epl.PositionName = x.EmployeePositionName;
                        EPList.Add(epl);
                    }
                    dgJobPosition.ItemsSource = EPList.OrderBy(m => m.PositionName);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 2
0
        public static EmployeePositionList GetEditPositionData(string id, int index)
        {
            //  Set active row
            HttpContext.Current.Session["ROW_ID"] = id;
            HttpContext.Current.Session["ROW"]    = index;

            var positionData   = new EmployeePositionList();
            var dsDataPosition = new DataSet();

            try
            {
                using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                {
                    List <SqlParameter> arrParm = new List <SqlParameter>
                    {
                        new SqlParameter("@id", SqlDbType.Int)
                        {
                            Value = Convert.ToInt32(id)
                        },
                        new SqlParameter("@search_name", SqlDbType.VarChar, 200)
                        {
                            Value = ""
                        }
                    };
                    conn.Open();
                    dsDataPosition = SqlHelper.ExecuteDataset(conn, "sp_employee_position_list", arrParm.ToArray());
                    conn.Close();
                }

                if (dsDataPosition.Tables.Count > 0)
                {
                    var row = dsDataPosition.Tables[0].Rows[0];
                    positionData.id       = Convert.IsDBNull(row["id"]) ? 0 : Convert.ToInt32(row["id"]);
                    positionData.name_tha = Convert.IsDBNull(row["name_tha"]) ? null : Convert.ToString(row["name_tha"]);
                    positionData.name_eng = Convert.IsDBNull(row["name_eng"]) ? null : Convert.ToString(row["name_eng"]);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(positionData);
        }