Exemple #1
0
        public static int Add(Students students)
        {
            int retvalue = -1;

            try
            {
                Persons persons = new Persons();
                persons.PersonId     = students.PersonsId;
                persons.FirstName    = students.FirstName;
                persons.LastName     = students.LastName;
                persons.DateOfBirth  = students.DateOfBirth;
                persons.CNIC         = students.CNIC;
                persons.ImageUrlPath = students.ImageUrlPath;
                persons.Phone1       = students.Phone1;
                persons.Phone2       = students.Phone2;
                persons.GendersId    = students.GendersId;

                students.PersonsId = Persons.PersonAdd(persons);

                students.LoginDetailsId = LoginDetails.Add(students.LoginDetails);


                db.cmd.CommandType = CommandType.StoredProcedure;
                db.cmd.CommandText = "procStudents_AddStudents";
                db.cmd.Parameters.AddWithValue("@RegistrationID", students.RegistrationId);
                db.cmd.Parameters.AddWithValue("@DiscountPercentage", students.DiscountPercentage);
                db.cmd.Parameters.AddWithValue("@IdentityCardUrl", students.IdentityCardUrl);
                db.cmd.Parameters.AddWithValue("@AdmissionCard", students.AdmissionCard);
                db.cmd.Parameters.AddWithValue("@PostalAddress", students.PostalAddress);
                db.cmd.Parameters.AddWithValue("@ResidentialAddress", students.ResidentialAddress);
                db.cmd.Parameters.AddWithValue("@Person_ID", students.PersonsId);
                db.cmd.Parameters.AddWithValue("@LoginDetail_ID", students.LoginDetailsId);
                db.cmd.Parameters.AddWithValue("@Parent_ID", students.ParentsId);
                db.cmd.Parameters.AddWithValue("@Class_ID", students.ClassesId);
                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);
        }
        public static int Add(Parents parents)
        {
            int retvalue = -1;

            try
            {
                Persons persons = new Persons();

                persons.FirstName    = parents.FirstName;
                persons.LastName     = parents.LastName;
                persons.DateOfBirth  = parents.DateOfBirth;
                persons.CNIC         = parents.CNIC;
                persons.ImageUrlPath = parents.ImageUrlPath;
                persons.Phone1       = parents.Phone1;
                persons.Phone2       = parents.Phone2;
                persons.GendersId    = parents.GendersId;

                parents.PersonsId = Persons.PersonAdd(persons);

                parents.LoginDetailsId = LoginDetails.Add(parents.LoginDetails);


                db.cmd.CommandType = CommandType.StoredProcedure;
                db.cmd.CommandText = "procParents_AddParents";
                db.cmd.Parameters.AddWithValue("@Person_ID", parents.PersonsId);
                db.cmd.Parameters.AddWithValue("@LoginDetail_ID", parents.LoginDetailsId);
                db.cmd.Parameters.Add("@id", SqlDbType.Int);
                db.cmd.Parameters["@id"].Direction = ParameterDirection.Output;
                db.con.Open();
                db.cmd.ExecuteNonQuery();
                db.con.Close();
                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);
        }
Exemple #3
0
        public static int Add(Employees employee)
        {
            Persons person = new Persons();

            int retvalue = -1;

            try
            {
                employee.PersonsId      = Persons.PersonAdd(employee);
                employee.LoginDetailsId = LoginDetails.Add(employee.LoginDetails);
                db.cmd.CommandType      = CommandType.StoredProcedure;
                db.cmd.CommandText      = "procEmployees_AddEmployees";
                db.cmd.Parameters.AddWithValue("@RegistrationID", employee.RegistrationID);
                db.cmd.Parameters.AddWithValue("@Salary", employee.Salary);
                db.cmd.Parameters.AddWithValue("@IdentityCardUrl", employee.IdentityCardUrl);
                db.cmd.Parameters.AddWithValue("@PostalAddress", employee.PostalAddress);
                db.cmd.Parameters.AddWithValue("@ResidentialAddress", employee.RegistrationID);
                db.cmd.Parameters.AddWithValue("@AggrementUrl", employee.AggrementUrl);
                db.cmd.Parameters.AddWithValue("@Person_ID", employee.PersonsId);
                db.cmd.Parameters.AddWithValue("@Designation_ID", employee.DesignationsId);
                db.cmd.Parameters.AddWithValue("@EmployeeType_ID", employee.EmployeeTypesId);
                db.cmd.Parameters.AddWithValue("@LoginDetail_ID", employee.LoginDetailsId);
                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);
        }