Esempio n. 1
0
        public static int Add(Designations designations)
        {
            int retvalue = -1;

            try
            {
                db.cmd.CommandType = CommandType.StoredProcedure;
                db.cmd.CommandText = "procDesignations_Designations";
                db.cmd.Parameters.AddWithValue("@DesignationName", designations.DesignationName);
                db.cmd.Parameters.Add("@Id", SqlDbType.Int);
                db.cmd.Parameters["@Id"].Direction = ParameterDirection.Output;
                db.con.Open();
                db.cmd.ExecuteNonQuery();
                retvalue = Convert.ToInt32(db.cmd.Parameters["@Id"].Value);
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }

            return(retvalue);
        }
Esempio n. 2
0
        private static List <Designations> _GetDesignations()
        {
            List <Designations> designations = new List <Designations>();


            try
            {
                Command            = "select * from tblDesignations";
                db.cmd.CommandText = Command;
                db.con.Open();

                SqlDataReader rdr = db.cmd.ExecuteReader();
                while (rdr.Read())
                {
                    Designations singleDesignations = new Designations();
                    singleDesignations.Id = (int)rdr[0];
                    singleDesignations.DesignationName = rdr[1].ToString();
                    designations.Add(singleDesignations);
                }
            }
            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.con.Close();
            }
            return(designations);
        }
Esempio n. 3
0
        public static int Add(Employees employees, Designations designations)
        {
            int retvalue = -1;

            employees.DesignationsId = Designations.Add(designations);
            retvalue = Employees.Add(employees);
            return(retvalue);
        }
Esempio n. 4
0
        public static void Update(int id, Designations designations)
        {
            try
            {
                db.cmd.CommandText = "update tblDesignations set DesignationName = @DesignationName where Id=@id";
                db.cmd.Parameters.AddWithValue("@DesignationName", designations.DesignationName);
                db.cmd.Parameters.AddWithValue("@id", id);
                db.con.Open();
                db.cmd.ExecuteNonQuery();
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }
        }
Esempio n. 5
0
        private static List <Employees> _GetEmployees()
        {
            List <Employees> employees = new List <Employees>();


            try
            {
                Command            = @"select * from tblEmployees";
                db.cmd.CommandText = Command;
                db.con.Open();

                SqlDataReader rdr = db.cmd.ExecuteReader();
                while (rdr.Read())
                {
                    Employees singleEmployees = new Employees();
                    singleEmployees.Id                 = (int)rdr[0];
                    singleEmployees.RegistrationID     = rdr[1].ToString();
                    singleEmployees.Salary             = Convert.ToSingle(rdr[2]);
                    singleEmployees.IdentityCardUrl    = rdr[3].ToString();
                    singleEmployees.PostalAddress      = rdr[4].ToString();
                    singleEmployees.ResidentialAddress = rdr[5].ToString();
                    singleEmployees.AggrementUrl       = rdr[6].ToString();
                    singleEmployees.PersonsId          = (int)rdr[7];
                    singleEmployees.DesignationsId     = (int)rdr[8];
                    singleEmployees.EmployeeTypesId    = (int)rdr[9];
                    singleEmployees.LoginDetailsId     = (int)rdr[10];

                    var emptypes = new EmployeeTypes();
                    singleEmployees.EmployeeTypes = EmployeeTypes.ListOfEmployeeTypes.SingleOrDefault(et => et.Id == singleEmployees.EmployeeTypesId);
                    var logindetails = new LoginDetails();
                    singleEmployees.LoginDetails = LoginDetails.ListOfLoginDetails.SingleOrDefault(ld => ld.Id == singleEmployees.LoginDetailsId);
                    var desig = new Designations();
                    singleEmployees.Designations = Designations.ListOfDesignations.SingleOrDefault(d => d.Id == singleEmployees.DesignationsId);
                    var a = Persons.ListOfPersons.SingleOrDefault(p => p.PersonId == singleEmployees.PersonsId);
                    singleEmployees.FirstName    = a.FirstName;
                    singleEmployees.LastName     = a.LastName;
                    singleEmployees.PersonId     = a.PersonId;
                    singleEmployees.DateOfBirth  = a.DateOfBirth;
                    singleEmployees.CNIC         = a.CNIC;
                    singleEmployees.ImageUrlPath = a.ImageUrlPath;
                    singleEmployees.Phone1       = a.Phone1;
                    singleEmployees.Phone2       = a.Phone2;
                    singleEmployees.GendersId    = a.GendersId;

                    singleEmployees.Genders.Id         = a.Genders.Id;
                    singleEmployees.Genders.GenderName = a.Genders.GenderName;

                    employees.Add(singleEmployees);
                }
            }
            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.con.Close();
            }
            return(employees);
        }
Esempio n. 6
0
 public Employees()
 {
     EmployeeTypes = new EmployeeTypes();
     LoginDetails  = new LoginDetails();
     Designations  = new Designations();
 }
Esempio n. 7
0
 public static void Update(int empId, Employees employees, EmployeeTypes employeeTypes, Designations designations)
 {
     employees.DesignationsId  = Designations.Add(designations);
     employees.EmployeeTypesId = EmployeeTypes.Add(employeeTypes);
     Employees.Update(empId, employees);
 }