Exemplo n.º 1
0
        public ActionResult staffUpdate(Staff staff, Address address, AdditionalContactInfoModel aci)
        {
            bool success;

            StaffDataController dataController = new StaffDataController();

            staff.deleted = true;

            success = dataController.InsertStaff(staff, address, aci);

            return(Content(success.ToString()));
        }
Exemplo n.º 2
0
/********************************************************** UPDATE METHODS ***********************************************************/

        //update Staff Member
        public bool staffUpdate(Staff thisStaff, Address staffAddress, AdditionalContactInfoModel staffContact)
        {
            try
            {
                //Update Staff
                DbCommand upd_Staff = db.GetStoredProcCommand("upd_Staff");

                // db.AddInParameter(dbCommand, "@parameterName", DbType.TypeName, variableName);

                db.AddInParameter(upd_Staff, "@staffID", DbType.String, thisStaff.staffID);
                db.AddInParameter(upd_Staff, "@firstName", DbType.String, thisStaff.firstName);
                db.AddInParameter(upd_Staff, "@lastName", DbType.String, thisStaff.lastName);
                db.AddInParameter(upd_Staff, "@handicapped", DbType.Boolean, 0);
                db.AddInParameter(upd_Staff, "@staffAltID", DbType.String, thisStaff.staffAltID);
                db.AddInParameter(upd_Staff, "@deleted", DbType.Boolean, thisStaff.deleted);
                db.AddInParameter(upd_Staff, "@staffSSN", DbType.Int32, thisStaff.SSN);

                db.ExecuteNonQuery(upd_Staff);

                //update Staff's Addresses
                DbCommand upd_Addresses = db.GetStoredProcCommand("upd_Addresses");

                db.AddInParameter(upd_Addresses, "@memberID", DbType.Int32, thisStaff.staffID);
                db.AddInParameter(upd_Addresses, "@memberTypeID", DbType.Int32, thisStaff.memberTypeID);
                db.AddInParameter(upd_Addresses, "@addressesID", DbType.Int32, staffAddress.addressesID);
                db.AddInParameter(upd_Addresses, "@addressTypeID", DbType.Int32, staffAddress.addressesType);
                db.AddInParameter(upd_Addresses, "@address1", DbType.String, staffAddress.address1);
                db.AddInParameter(upd_Addresses, "@address2", DbType.String, staffAddress.address2);
                db.AddInParameter(upd_Addresses, "@city", DbType.String, staffAddress.city);
                db.AddInParameter(upd_Addresses, "@st", DbType.String, staffAddress.state);
                db.AddInParameter(upd_Addresses, "@zip", DbType.Int32, staffAddress.zip);
                db.AddInParameter(upd_Addresses, "@county", DbType.String, "");
                db.AddInParameter(upd_Addresses, "@deleted", DbType.Boolean, staffAddress.deleted);

                db.ExecuteNonQuery(upd_Addresses);

                //update Staff's Additional Contact Info
                DbCommand upd_AdditionalContactInfo = db.GetStoredProcCommand("upd_AdditionalContactInfo");

                db.AddInParameter(upd_AdditionalContactInfo, "@additionalContactInfoID", DbType.Int32, staffContact.additionalContactInfoID);
                db.AddInParameter(upd_AdditionalContactInfo, "@additionalContactInfo", DbType.String, staffContact.additionalContactInfo);
                db.AddInParameter(upd_AdditionalContactInfo, "@additionalContactInfoTypeID", DbType.Int32, staffContact.additionalContactInfoTypeID);
                db.AddInParameter(upd_AdditionalContactInfo, "@deleted", DbType.Boolean, staffContact.deleted);

                db.ExecuteNonQuery(upd_AdditionalContactInfo);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        //gets contact info by a dataset
        public AdditionalContactInfoModel GetAddContactInfoByDataSet(DataSet ds)
        {
            //datasets passed through only have one row so we access that row
            DataRow dr = ds.Tables[0].Rows[0];
            //then assign values from that row to a new Address model
            AdditionalContactInfoModel thisAddContactInfo = new AdditionalContactInfoModel()
            {
                additionalContactInfo = dr.Field <string>("additionalContactInfo")
            };

            return(thisAddContactInfo);
        }
Exemplo n.º 4
0
        public AdditionalContactInfoModel UpdateAdditionalContactInformation(AdditionalContactInfoModel additionalContactInfo, int memberID, int memberTypeID)
        {
            DbCommand upd_AdditionalContactInfo = db.GetStoredProcCommand("upd_AdditionalContactInformation");

            db.AddInParameter(upd_AdditionalContactInfo, "@additionalContactInfoID", DbType.Int32, additionalContactInfo.additionalContactInfoID);
            db.AddInParameter(upd_AdditionalContactInfo, "@additionalContactInfo", DbType.String, additionalContactInfo.additionalContactInfo);

            db.AddOutParameter(upd_AdditionalContactInfo, "@success", DbType.Boolean, 1);

            try
            {
                db.ExecuteNonQuery(upd_AdditionalContactInfo);
            }
            catch (Exception e)
            {
                Debug.WriteLine("UpdateAdditionalContactInfo failed, exception: {0}", e);
            }

            return(additionalContactInfo);
        }
Exemplo n.º 5
0
        public bool DeleteAdditionalContactInformation(AdditionalContactInfoModel additionalContactInfo)
        {
            DbCommand del_AdditionalContactInfo = db.GetStoredProcCommand("del_AdditionalContactInformation");

            db.AddInParameter(del_AdditionalContactInfo, "@additionalContactInfoID", DbType.Int32, additionalContactInfo.additionalContactInfoID);
            db.AddOutParameter(del_AdditionalContactInfo, "@success", DbType.Boolean, 1);

            bool success;

            try
            {
                db.ExecuteNonQuery(del_AdditionalContactInfo);
                success = Convert.ToBoolean(db.GetParameterValue(del_AdditionalContactInfo, "@success"));
            }
            catch (Exception e)
            {
                Debug.WriteLine("DeleteAdditionalContactInfo failed, exception: {0}", e);
                success = false;
            }

            return(success);
        }
Exemplo n.º 6
0
        public AdditionalContactInfoModel InsertAdditionalContactInformation(AdditionalContactInfoModel additionalContactInfo, int memberID, int memberTypeID)
        {
            DbCommand ins_AdditionalContactInformation = db.GetStoredProcCommand("ins_AdditionalContactInformation");

            db.AddInParameter(ins_AdditionalContactInformation, "@memberID", DbType.Int32, memberID);
            db.AddInParameter(ins_AdditionalContactInformation, "@memberTypeID", DbType.Int32, memberTypeID);
            db.AddInParameter(ins_AdditionalContactInformation, "@additionalContactInfoTypeID", DbType.Int32, additionalContactInfo.additionalContactInfoTypeID);
            db.AddInParameter(ins_AdditionalContactInformation, "@additionalContactInfo", DbType.String, additionalContactInfo.additionalContactInfo);

            db.AddOutParameter(ins_AdditionalContactInformation, "@additionalContactInfoID", DbType.Int32, sizeof(int));

            try
            {
                db.ExecuteNonQuery(ins_AdditionalContactInformation);

                additionalContactInfo.additionalContactInfoID = Convert.ToInt32(db.GetParameterValue(ins_AdditionalContactInformation, "@additionalContactInfoID"));
            }
            catch (Exception e)
            {
                Debug.WriteLine("InsertContactInformation failed, exception: {0}", e);
            }

            return(additionalContactInfo);
        }
Exemplo n.º 7
0
/*********************************************************** INSERT METHODS *******************************************************/


        public bool InsertStaff(Staff thisStaff, Address thisAddress, AdditionalContactInfoModel staffContact)
        {
            try
            {
                int    addressID;
                string staffAltID;
                int    staffID;
                string shortFirst;
                string shortLast;

                shortFirst = StringTool.Truncate(thisStaff.firstName, 4);
                shortLast  = StringTool.Truncate(thisStaff.lastName, 4);

                //insert Staff's Addresses
                DbCommand ins_Addresses = db.GetStoredProcCommand("ins_Addresses");
                db.AddInParameter(ins_Addresses, "@memberID", DbType.Int32, thisStaff.staffID);
                db.AddInParameter(ins_Addresses, "@memberTypeID", DbType.Int32, thisStaff.memberTypeID);
                db.AddInParameter(ins_Addresses, "@addressTypeID", DbType.Int32, thisAddress.addressTypeID);
                db.AddInParameter(ins_Addresses, "@address1", DbType.String, thisAddress.address1);
                db.AddInParameter(ins_Addresses, "@address2", DbType.String, thisAddress.address2);
                db.AddInParameter(ins_Addresses, "@city", DbType.String, thisAddress.city);
                db.AddInParameter(ins_Addresses, "@st", DbType.String, thisAddress.state);
                db.AddInParameter(ins_Addresses, "@zip", DbType.Int32, thisAddress.zip);
                db.AddInParameter(ins_Addresses, "@county", DbType.String, "");
                db.AddInParameter(ins_Addresses, "@deleted", DbType.Boolean, false);
                db.AddOutParameter(ins_Addresses, "@addressID", DbType.Int32, sizeof(Int32));
                db.ExecuteScalar(ins_Addresses);
                addressID = (int)db.GetParameterValue(ins_Addresses, "@addressID");


                //Inserts staff
                DbCommand ins_Staff = db.GetStoredProcCommand("ins_StaffMember");


                db.AddInParameter(ins_Staff, "@staffTypeID", DbType.Int32, thisStaff.staffTypeID);
                db.AddInParameter(ins_Staff, "@addressesID", DbType.Int32, Convert.ToInt32(addressID));
                db.AddInParameter(ins_Staff, "@memberTypeID", DbType.Int32, thisStaff.memberTypeID);
                db.AddInParameter(ins_Staff, "@firstName", DbType.String, thisStaff.firstName);
                db.AddInParameter(ins_Staff, "@lastName", DbType.String, thisStaff.lastName);
                db.AddInParameter(ins_Staff, "@handicapped", DbType.Boolean, thisStaff.handicapped);
                db.AddInParameter(ins_Staff, "@staffAltID", DbType.String, thisStaff.staffAltID);
                db.AddInParameter(ins_Staff, "@deleted", DbType.Boolean, thisStaff.deleted);
                db.AddInParameter(ins_Staff, "@ssn", DbType.String, thisStaff.SSN);
                db.AddInParameter(ins_Staff, "@dob", DbType.Date, thisStaff.DOB);
                db.AddInParameter(ins_Staff, "@staffStatus", DbType.Int32, thisStaff.status);
                db.AddOutParameter(ins_Staff, "@staffID", DbType.Int32, sizeof(int));
                db.ExecuteScalar(ins_Staff);
                staffID = (int)db.GetParameterValue(ins_Staff, "@staffID");


                //insert Staff's Additional Contact Info
                DbCommand ins_AdditionalContactInfo = db.GetStoredProcCommand("ins_AdditionalContactInfo");

                db.AddInParameter(ins_AdditionalContactInfo, "@memberTypeID", DbType.Int32, thisStaff.memberTypeID);
                db.AddInParameter(ins_AdditionalContactInfo, "@additionalContactInfo", DbType.String, staffContact.additionalContactInfo);
                db.AddInParameter(ins_AdditionalContactInfo, "@additionalContactInfoTypeID", DbType.Int32, staffContact.additionalContactInfoTypeID);
                db.AddInParameter(ins_AdditionalContactInfo, "@deleted", DbType.Boolean, false);
                db.AddInParameter(ins_AdditionalContactInfo, "@memberID", DbType.Int32, staffID);
                db.ExecuteNonQuery(ins_AdditionalContactInfo);

                //enters Staff Alt ID into table
                staffAltID = shortFirst + shortLast + thisStaff.staffID.ToString();

                DbCommand upd_StaffAltID = db.GetStoredProcCommand("upd_StaffAltID");

                db.AddInParameter(upd_StaffAltID, "@staffID", DbType.Int32, staffID);
                db.AddInParameter(upd_StaffAltID, "@staffAltID", DbType.String, staffAltID);
                db.ExecuteNonQuery(upd_StaffAltID);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 8
0
        public Staff GetStaffMember(int staffID)
        {
            DbCommand dbCommand = db.GetStoredProcCommand("get_StaffByID");

            db.AddInParameter(dbCommand, "staffID", DbType.Int32, staffID);
            // db.AddInParameter(dbCommand, "@parameterName", DbType.TypeName, variableName);

            DataSet ds = db.ExecuteDataSet(dbCommand);

            DataRow dr = ds.Tables[0].Rows[0];

            Staff currentStaff = new Staff()
            {
                staffID      = dr.Field <int>("staffID"),
                staffTypeID  = dr.Field <int>("staffTypeID"),
                staffType    = dr.Field <string>("staffType"),
                addressesID  = dr.Field <int>("addressesID"),
                memberTypeID = dr.Field <int>("memberTypeID"),
                firstName    = dr.Field <string>("firstName"),
                lastName     = dr.Field <string>("lastName"),
                handicapped  = dr.Field <bool>("handicapped"),
                fullName     = dr.Field <string>("firstName") + " " + dr.Field <string>("lastName"),
                staffAltID   = dr.Field <string>("staffAltID"),
                sexID        = dr.Field <int>("sexID"),
                deleted      = dr.Field <bool>("deleted"),
                SSN          = dr.Field <int>("ssn"),
                DOB          = dr.IsNull("dob") ? new DateTime(1900, 1, 1) : dr.Field <DateTime>("dob"),
            };

            Address thisAddress = new Address()
            {
                addressesID   = dr.Field <int>("addressesID"),
                addressTypeID = dr.Field <int>("addressesTypeID"),
                address1      = dr.Field <string>("address1"),
                address2      = dr.Field <string>("address2"),
                city          = dr.Field <string>("city"),
                state         = dr.Field <string>("st"),
                zip           = dr.Field <int>("zip"),
                mapsco        = dr.Field <string>("mapsco"),
                addressesType = dr.Field <string>("addressesType")
            };

            AdditionalContactInfoModel thisContact = new AdditionalContactInfoModel()
            {
                additionalContactInfoID     = dr.Field <int>("additionalContactInfoID"),
                additionalContactInfo       = dr.Field <string>("additionalContactInfo"),
                additionalContactInfoTypeID = dr.Field <int>("additionalContactInfoTypeID"),
                additionalContactInfoType   = dr.Field <string>("additionalContactInfoType"),
            };

            //var timeHeaderList = (from drRow in ds.Tables[0].AsEnumerable()
            //                  select new TimeHeaderModel()
            //                  {
            //                      weekEnding = drRow.Field<string>("weekEnding")

            //                  }).ToList();



            currentStaff.staffAddress = thisAddress;
            currentStaff.staffContact = thisContact;



            //Addresses addr = new Addresses();
            //currentStaff.staffAddress = addr.GetAddressByDataSet(ds);

            return(currentStaff);
        }