Inheritance: System.Web.UI.Page
Exemplo n.º 1
0
        public static int GetAddressID(int addressType, int id)
        {
            int             addressID       = 0;
            EmployeeAddress employeeAddress = new EmployeeAddress();
            MyDBConnection  myConn          = new MyDBConnection();
            SqlConnection   conn            = new SqlConnection();
            SqlDataReader   dr;
            SqlCommand      cmd = null;
            string          sql = "Select addressid from AquaOne.dbo.EmployeeAddress where EmployeeID = @EmployeeID and AddressType = @AddressType";

            // Open the connection
            try
            {
                conn = myConn.OpenDB();
                cmd  = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@EmployeeID", SqlDbType.Int).Value  = id;
                cmd.Parameters.Add("@AddressType", SqlDbType.Int).Value = addressType;
                dr = cmd.ExecuteReader();

                if (dr.Read())
                {
                    addressID = dr.GetInt32(0);
                    //  accountAddress = FillDataRecord(dr);
                }
            }
            finally
            {
                cmd.Dispose();
                //close the connection
                myConn.CloseDB(conn);
            }
            return(addressID);
        }
Exemplo n.º 2
0
 public Department(string name, Employee employee,
                   EmployeeAddress employeeAddress) : this()
 {
     Name            = name;
     Employee        = employee;
     EmployeeAddress = employeeAddress;
 }
Exemplo n.º 3
0
        public static EmployeeAddressDTO ConvertEmployeeAddressToDTO(EmployeeAddress Item)
        {
            EmployeeAddressDTO Record = new EmployeeAddressDTO
            {
                Id           = Item.Id,
                EmployeeCode = Item.EmployeeCode,
                HouseNumber  = Item.HouseNumber,
                WardNumber   = Item.WardNumber,
                VDC          = Item.VDC,
                District     = Item.District,
                Zone         = Item.Zone,
                State        = Item.State,
                Country      = Item.Country,
                LandMark     = Item.LandMark,
                AddressType  = Item.AddressType,
                Employee     = new EmployeeDTO
                {
                    EmpName = Item.Employee.EmpName
                },
                Zone1 = new ZoneDTO
                {
                    ZoneName = Item.Zone1.ZoneName,
                },
                District1 = new DistrictDTO
                {
                    DistrictName = Item.District1.DistrictName,
                },
                Country1 = new CountryDTO
                {
                    CountryName = Item.Country1.CountryName
                }
            };

            return(Record);
        }
Exemplo n.º 4
0
        public static void UpdateEmployeeAddress(EmployeeAddress oldEmployeeAddress, EmployeeAddress newEmployeeAddress)
        {
            ConnectionHolder.Connection.Connection.Open();

            var command = ConnectionHolder.Connection.Connection.CreateCommand();

            byte bit = 0;

            if (newEmployeeAddress.IsResidence)
            {
                bit = 1;
            }

            string baseQuery = "UPDATE employee_address ";

            string getCurrentEmployee =
                $"WHERE bsn = '{oldEmployeeAddress.Bsn}' AND postal_code = '{oldEmployeeAddress.PostalCode}' AND country = '{oldEmployeeAddress.Country}' ";
            string changeValues =
                $"SET bsn = '{newEmployeeAddress.Bsn}', postal_code = '{newEmployeeAddress.PostalCode}', country = '{newEmployeeAddress.Country}', is_residence = {bit} ";

            string query = baseQuery + changeValues + getCurrentEmployee;

            command.CommandText = query;
            command.ExecuteNonQuery();

            ConnectionHolder.Connection.Connection.Close();
        }
Exemplo n.º 5
0
        private async Task <int> SaveAddress(int id, EmployeeAddress input)
        {
            int ret = 0;

            try
            {
                if ((null != input) && (null != input.Address1) && (null != input.City) && (null != input.ZipCode))
                {
                    if (id > 0)
                    {
                        _context.Update(input);
                    }
                    else
                    {
                        _context.EmployeeAdresses.Add(input);
                    }
                    await _context.SaveChangesAsync();

                    ret = input.Id;
                }
                else
                {
                    ret = id;
                }
            }
            catch (Exception ex)
            {
                ret = ex.HResult;
            }

            return(ret);
        }
        public async Task <IActionResult> Edit(int id, [Bind("AddressId,City,District,WardNo,EmployeeId")] EmployeeAddress employeeAddress)

        {
            if (id != employeeAddress.EmployeeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employeeAddress);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeAddressExists(employeeAddress.EmployeeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "FristName", employeeAddress.EmployeeId);

            return(View(employeeAddress));
        }
Exemplo n.º 7
0
        public static int AddEmployeeAddress(EmployeeAddress newEmployeeAddress)
        {
            int result;

            result = EmployeeAddressDB.AddEmployeeAddress(newEmployeeAddress);
            return(result);
        }
Exemplo n.º 8
0
        public async Task <ActionResult> Edit(EmployeeAddress employeeAddress)
        {
            if (ModelState.IsValid)
            {
                EmployeeAddress empadd = await db.EmployeeAddresses.FindAsync(employeeAddress.id);

                if (empadd != null)
                {
                    empadd.addressline1    = employeeAddress.addressline1;
                    empadd.addressline2    = employeeAddress.addressline2;
                    empadd.landmark        = employeeAddress.landmark;
                    empadd.country         = employeeAddress.country;
                    empadd.state           = employeeAddress.state;
                    empadd.city            = employeeAddress.city;
                    empadd.pin             = employeeAddress.pin;
                    empadd.contact         = employeeAddress.contact;
                    empadd.ispermanant     = employeeAddress.ispermanant;
                    empadd.status          = employeeAddress.status;
                    db.Entry(empadd).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            BindDropDown(employeeAddress);
            return(View(employeeAddress));
        }
Exemplo n.º 9
0
        public EmployeeAddressEditViewModel Update(EmployeeAddressEditViewModel EmployeeAddressEditViewModel)
        {
            EmployeeAddress EmployeeAddress = EmployeeAddressRepo.Update(EmployeeAddressEditViewModel.ToModel());

            unitOfWork.commit();
            return(EmployeeAddress.ToEditableViewModel());
        }
Exemplo n.º 10
0
        public bool EditEmployeeAddress(EmployeeAddress model)
        {
            bool result = true;

            using (var context = new IMC2Context())
            {
                try
                {
                    var employeeAddressModel = context.EmployeeAddress.First(m => m.EmployeeAddressId == model.EmployeeAddressId);
                    employeeAddressModel.EmployeeAddressId = model.EmployeeAddressId;
                    employeeAddressModel.EmployeeId        = model.EmployeeId;
                    employeeAddressModel.AddressType       = model.AddressType;
                    employeeAddressModel.Address           = model.Address;
                    employeeAddressModel.Subdistrict       = model.Subdistrict;
                    employeeAddressModel.DistrictId        = model.DistrictId;
                    employeeAddressModel.ProvinceId        = model.ProvinceId;
                    employeeAddressModel.PostalCode        = model.PostalCode;
                    employeeAddressModel.PhoneNo           = model.PhoneNo;
                    employeeAddressModel.DateModified      = DateTime.Now;
                    employeeAddressModel.ModifiedBy        = model.ModifiedBy;
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    result = false;
                }
            }

            return(result);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Deep load all EmployeeAddress children.
        /// </summary>
        private void Step_03_DeepLoad_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                int count = -1;
                mock           = CreateMockInstance(tm);
                mockCollection = DataRepository.EmployeeAddressProvider.GetPaged(tm, 0, 10, out count);

                DataRepository.EmployeeAddressProvider.DeepLoading += new EntityProviderBaseCore <EmployeeAddress, EmployeeAddressKey> .DeepLoadingEventHandler(
                    delegate(object sender, DeepSessionEventArgs e)
                {
                    if (e.DeepSession.Count > 3)
                    {
                        e.Cancel = true;
                    }
                }
                    );

                if (mockCollection.Count > 0)
                {
                    DataRepository.EmployeeAddressProvider.DeepLoad(tm, mockCollection[0]);
                    System.Console.WriteLine("EmployeeAddress instance correctly deep loaded at 1 level.");

                    mockCollection.Add(mock);
                    // DataRepository.EmployeeAddressProvider.DeepSave(tm, mockCollection);
                }

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
Exemplo n.º 12
0
        ///<summary>
        ///  Returns a Typed EmployeeAddress Entity with mock values.
        ///</summary>
        static public EmployeeAddress CreateMockInstance_Generated(TransactionManager tm)
        {
            EmployeeAddress mock = new EmployeeAddress();

            mock.ModifiedDate = TestUtility.Instance.RandomDateTime();

            //OneToOneRelationship
            Address mockAddressByAddressId = AddressTest.CreateMockInstance(tm);

            DataRepository.AddressProvider.Insert(tm, mockAddressByAddressId);
            mock.AddressId = mockAddressByAddressId.AddressId;
            //OneToOneRelationship
            Employee mockEmployeeByEmployeeId = EmployeeTest.CreateMockInstance(tm);

            DataRepository.EmployeeProvider.Insert(tm, mockEmployeeByEmployeeId);
            mock.EmployeeId = mockEmployeeByEmployeeId.EmployeeId;

            // create a temporary collection and add the item to it
            TList <EmployeeAddress> tempMockCollection = new TList <EmployeeAddress>();

            tempMockCollection.Add(mock);
            tempMockCollection.Remove(mock);


            return((EmployeeAddress)mock);
        }
Exemplo n.º 13
0
        public static int AddEmployeeAddress(EmployeeAddress newEmployeeAddress)
        {
            int            result;
            MyDBConnection dbconn = new MyDBConnection();
            SqlConnection  conn   = new SqlConnection();
            SqlCommand     cmd    = new SqlCommand();

            try
            {
                conn            = dbconn.OpenDB();
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "dbo.AddEmployeeAddress";

                cmd.Parameters.Add("@EmployeeID", SqlDbType.Int).Value        = newEmployeeAddress.EmployeeID;
                cmd.Parameters.Add("@AddressID", SqlDbType.Int).Value         = newEmployeeAddress.AddressID;
                cmd.Parameters.Add("@AddressType", SqlDbType.Int).Value       = newEmployeeAddress.AddressType;
                cmd.Parameters.Add("@CreatedDate", SqlDbType.DateTime).Value  = newEmployeeAddress.CreatedDate;
                cmd.Parameters.Add("@ModifiedDate", SqlDbType.DateTime).Value = newEmployeeAddress.ModifiedDate;
                cmd.Parameters.Add("@CreatedBy", SqlDbType.VarChar).Value     = newEmployeeAddress.CreatedBy;
                cmd.Parameters.Add("@ModifiedBy", SqlDbType.VarChar).Value    = newEmployeeAddress.ModifiedBy;


                result = cmd.ExecuteNonQuery();
            }
            finally
            {
                cmd.Dispose();
                dbconn.CloseDB(conn);
            }

            return(result);
        }
Exemplo n.º 14
0
        protected void btnSave_Command(object sender, CommandEventArgs e)
        {
            // Save the new employee
            Employee employee = GetEmployeeDetailsFromForm();

            employee.EmployeeID = EmployeeManager.Save(employee);

            //Save the home address
            Address myHomeAddress = null;

            myHomeAddress           = GetHomeAddressDetailsFromForm();
            myHomeAddress.AddressID = AddressManager.Save(myHomeAddress);

            //Save the Home address and the new employee on the EmployeeAddress table
            EmployeeAddress newEmployeeAddress = new EmployeeAddress();

            newEmployeeAddress.EmployeeID  = employee.EmployeeID;
            newEmployeeAddress.AddressID   = myHomeAddress.AddressID;
            newEmployeeAddress.AddressType = Convert.ToInt32(AddressType.Home);
            EmployeeAddressManager.AddEmployeeAddress(newEmployeeAddress);

            Session["employeeID"] = null;
            Session["employeeID"] = employee.EmployeeID;
            Response.Redirect("~/Admin/EmployeeManagement/ViewEmployee.aspx");
        }
Exemplo n.º 15
0
        public ActionResult DeleteConfirmed(int id)
        {
            EmployeeAddress employeeAddress = db.EmployeeAddress.Find(id);

            db.EmployeeAddress.Remove(employeeAddress);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 16
0
        ///<summary>
        ///  Update the Typed EmployeeAddress Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance(TransactionManager tm, EmployeeAddress mock)
        {
            EmployeeAddressTest.UpdateMockInstance_Generated(tm, mock);

            // make any alterations necessary
            // (i.e. for DB check constraints, special test cases, etc.)
            SetSpecialTestData(mock);
        }
Exemplo n.º 17
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            EmployeeAddress employeeAddress = await db.EmployeeAddresses.FindAsync(id);

            db.EmployeeAddresses.Remove(employeeAddress);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 18
0
 public void EditEmployee(EmployeeAddress emp)
 {
     this.operation = () =>
     {
         EmplyeeRepopsitory access = new EmplyeeRepopsitory(this.Transaction);
         access.EditEmployee(emp);
     };
     this.Start(false);
 }
Exemplo n.º 19
0
        private static EmployeeAddress FillDataRecord(IDataRecord dr)
        {
            EmployeeAddress employeeAddress = new EmployeeAddress();

            employeeAddress.AddressID   = dr.GetInt32(dr.GetOrdinal("AddressID"));
            employeeAddress.EmployeeID  = dr.GetInt32(dr.GetOrdinal("EmployeeID"));
            employeeAddress.AddressType = dr.GetInt32(dr.GetOrdinal("AddressType"));

            return(employeeAddress);
        }
Exemplo n.º 20
0
 public ActionResult Edit([Bind(Include = "Id,PrimaryEmployeeAddress,City,State,ZipCode")] EmployeeAddress employeeAddress)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employeeAddress).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employeeAddress));
 }
 public ActionResult Edit([Bind(Include = "Id,EmployeeId,Address1,Address2,City,State,Country")] EmployeeAddress employeeAddress)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employeeAddress).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "FirstName", employeeAddress.EmployeeId);
     return(View(employeeAddress));
 }
Exemplo n.º 22
0
        public ActionResult Create([Bind(Include = "Id,PrimaryEmployeeAddress,City,State,ZipCode")] EmployeeAddress employeeAddress)
        {
            if (ModelState.IsValid)
            {
                db.EmployeeAddress.Add(employeeAddress);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employeeAddress));
        }
Exemplo n.º 23
0
        public ActionResult EditEmployee(int empid)
        {
            var        dep         = _objEmployeeService.GetDepartments();
            SelectList departments = new SelectList(dep, "depid", "DepartmentName");

            ViewBag.Departments = departments;

            EmployeeAddress emp = _objEmployeeService.GetEmployee(empid);

            return(View("EditEmployee", emp));
        }
Exemplo n.º 24
0
        /// <summary>
        /// Test methods exposed by the EntityHelper class.
        /// </summary>
        private void Step_20_TestEntityHelper_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);

                EmployeeAddress entity = mock.Copy() as EmployeeAddress;
                entity = (EmployeeAddress)mock.Clone();
                Assert.IsTrue(EmployeeAddress.ValueEquals(entity, mock), "Clone is not working");
            }
        }
Exemplo n.º 25
0
 public ActionResult Edit([Bind(Include = "AddressId,EmployeeId,StreetName,ZipCode,Housenumber,City")] EmployeeAddress employeeAddress)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employeeAddress).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "Name", employeeAddress.EmployeeId);
     return(View(employeeAddress));
 }
Exemplo n.º 26
0
        public async Task <ActionResult> Edit([Bind(Include = "AddressId,Address1,Address2,City,PostalCode")] EmployeeAddress employeeAddress)
        {
            if (ModelState.IsValid)
            {
                db.Entry(employeeAddress).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(employeeAddress));
        }
Exemplo n.º 27
0
        public EmployeeAddress GetEmployee(int id)
        {
            EmployeeAddress emp = new EmployeeAddress();

            this.operation = () =>
            {
                EmplyeeRepopsitory access = new EmplyeeRepopsitory(this.Transaction);
                emp = access.GetEmployee(id).FirstOrDefault();
            };
            this.Start(false);
            return(emp);
        }
Exemplo n.º 28
0
        ///<summary>
        ///  Returns a Typed EmployeeAddress Entity with mock values.
        ///</summary>
        static public EmployeeAddress CreateMockInstance(TransactionManager tm)
        {
            // get the default mock instance
            EmployeeAddress mock = EmployeeAddressTest.CreateMockInstance_Generated(tm);

            // make any alterations necessary
            // (i.e. for DB check constraints, special test cases, etc.)
            SetSpecialTestData(mock);

            // return the modified object
            return(mock);
        }
 public List <EmployeeAddressDto> GetEmployeeAddress()
 {
     try
     {
         var eaList = da.List <EmployeeAddress>(null);
         return(EmployeeAddress.GetEntityCollection(eaList));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemplo n.º 30
0
        // GET: EmployeeAddresses/Create
        public ActionResult Create(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmployeeAddress employeeAddress = new EmployeeAddress();

            ViewBag.country     = new SelectList(db.countries, "id", "name");
            employeeAddress.eid = Convert.ToInt32(id);
            return(View(employeeAddress));
        }
Exemplo n.º 31
0
        public void CreateAddress(EmployeeAddress address)
        {
            try
            {
                PayrollDataContext context = new PayrollDataContext();
                if (address.Id == Guid.Empty)
                    address.Id = Guid.NewGuid();

                if (address.EmployeeId == Guid.Empty)
                    throw new Exception("Cannot add address to empty employee id");

                context.EmployeeAddresses.InsertOnSubmit(address);
                context.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 /// <summary>
 /// Create a new EmployeeAddress object.
 /// </summary>
 /// <param name="employeeID">Initial value of EmployeeID.</param>
 /// <param name="addressID">Initial value of AddressID.</param>
 /// <param name="rowguid">Initial value of rowguid.</param>
 /// <param name="modifiedDate">Initial value of ModifiedDate.</param>
 public static EmployeeAddress CreateEmployeeAddress(int employeeID, int addressID, global::System.Guid rowguid, global::System.DateTime modifiedDate)
 {
     EmployeeAddress employeeAddress = new EmployeeAddress();
     employeeAddress.EmployeeID = employeeID;
     employeeAddress.AddressID = addressID;
     employeeAddress.rowguid = rowguid;
     employeeAddress.ModifiedDate = modifiedDate;
     return employeeAddress;
 }
 /// <summary>
 /// There are no comments for EmployeeAddress in the schema.
 /// </summary>
 public void AddToEmployeeAddress(EmployeeAddress employeeAddress)
 {
     base.AddObject("EmployeeAddress", employeeAddress);
 }
Exemplo n.º 34
0
        public void UpdateEmployeeAddress(EmployeeAddress address)
        {
            PayrollDataContext context = new PayrollDataContext();

            var newAddress = context.EmployeeAddresses.Where(x => x.Id == address.Id).FirstOrDefault();
            newAddress.Address = address.Address;
            newAddress.CityMun = address.CityMun;
            newAddress.ProvState = address.ProvState;
            newAddress.CountryCode = address.CountryCode;
            newAddress.ZipCode = address.ZipCode;

            context.SubmitChanges();
        }