public void InitializationDataBox()
 {
     UserDAO daoUser = new UserDAO();
     DepartmentDAO daoDepartment = new DepartmentDAO();
     comboBoxUser.Items.AddRange(daoUser.getUserComboBox().ToArray());
     comboBoxDepartment.Items.AddRange(daoDepartment.getComboBox().ToArray());
 }
 private void saveButton(object sender, EventArgs e)
 {
     if (isValid())
     {
         if (Project == null)
         {
             Project = new InvestProject();
         }
         Project.nameProject = textBoxNameStage.Text;
         Project.numberProject = textBoxNumberProject.Text;
         Project.dateBegin = dateBeginPlan.Value;
         Project.dateEnd = dateEndPlan.Value;
         Project.dateBeginProg = dateBeginProg.Value;
         Project.dateEndProg = dateEndProg.Value;
         UserDAO daoUser = new UserDAO();
         DepartmentDAO daoDepartment = new DepartmentDAO();
         InvestProjectDAO projectDAO = new InvestProjectDAO();
         Project.user = daoUser.getById(Convert.ToInt32(((KeyValuePair)comboBoxUser.SelectedItem).Key));
         Project.department = daoDepartment.getById(Convert.ToInt32(((KeyValuePair)comboBoxDepartment.SelectedItem).Key));
         
         if (Project.idProject != 0)
         {
             projectDAO.update(Project);
         }
         else
         {
             projectDAO.insert(Project);
         }
         this.Close();
     }
 }
        public void TestUpdateSqlBuilder()
        {
            DepartmentDAO dep = new DepartmentDAO();

            string actual = dep.UpdateSqlBuilder("departments", new List <string>()
            {
                "name", "address"
            });

            Assert.Equal("update departments set name = @name, address = @address where id = @id;", actual);
        }
        public static TaskDTO GetAll()
        {
            TaskDTO taskdto = new TaskDTO();

            taskdto.Employees   = EmployeeDAO.GetEmployees();
            taskdto.Departments = DepartmentDAO.GetDepartments();
            taskdto.Positions   = PositionDAO.GetPositions();
            taskdto.TaskStates  = TaskDAO.GetTaskStates();
            taskdto.Tasks       = TaskDAO.GetTasks();
            return(taskdto);
        }
        public static SalaryDTO GetAll()
        {
            SalaryDTO dto = new SalaryDTO();

            dto.Employees   = EmployeeDAO.GetEmployees();
            dto.Departments = DepartmentDAO.GetDepartments();
            dto.Positions   = PositionDAO.GetPositions();
            dto.Months      = SalaryDAO.GetMonths();
            dto.Salaries    = SalaryDAO.GetSalarys();
            return(dto);
        }
Example #6
0
 //EmployeeDAO _employeeDAO;
 //RequisitionDAO _requisitionDAO;
 //RequisitionItemDAO _requisitionItemDAO;
 //ItemDAO _itemDAO;
 //DepartmentDAO _deparmentDAO;
 //CollectionPointDAO _collectionPointDAO;
 public DepartmentHeadController()
 {
     _employeeDAO            = new EmployeeDAO();
     _requisitionDAO         = new RequisitionDAO();
     _requisitionItemDAO     = new RequisitionItemDAO();
     _itemDAO                = new ItemDAO();
     _departmentDAO          = new DepartmentDAO();
     _notificationChannelDAO = new NotificationChannelDAO();
     _collectionPointDAO     = new CollectionPointDAO();
     _delegationDAO          = new DelegationDAO();
 }
Example #7
0
        /// <summary>
        /// Convert DepartmentDAO into Department.
        /// </summary>
        /// <param name="departmentDAO">The DepartmentDAO to convert.</param>
        /// <returns>The Department.</returns>
        public static Department MapToDepartment(DepartmentDAO departmentDAO)
        {
            RegistrationData data = new RegistrationData();

            Department department = data.FindOrCreateDepartment(departmentDAO.Id);

            department.DepartmentId = departmentDAO.Id;
            department.Name         = departmentDAO.Name;

            return(department);
        }
Example #8
0
 public HomeController()
 {
     _employeeDAO            = new EmployeeDAO();
     _collectionPointDAO     = new CollectionPointDAO();
     _notificationChannelDAO = new NotificationChannelDAO();
     _requisitionDAO         = new RequisitionDAO();
     _delegationDAO          = new DelegationDAO();
     _departmentDAO          = new DepartmentDAO();
     _disbursementDAO        = new DisbursementDAO();
     _disbursementItemDAO    = new DisbursementItemDAO();
 }
Example #9
0
        public DepartmentDAOTests()
        {
            DALUtils util = new DALUtils();

            util.LoadCollections();

            DepartmentDAO dao = new DepartmentDAO();
            Department    dep = dao.GetByDepartmentName("Administration");

            did = dep.GetIdAsString();
        }
Example #10
0
 public static void CreateDisbursementLists(List <DisbursementList> disbursementLists)
 {
     foreach (var disbursementList in disbursementLists)
     {
         disbursementList.Department = DepartmentDAO.GetDepartmentById(disbursementList.Department.DeptId);
         long listId = DisbursementListDAO.CreateDisbursementList(disbursementList);
         foreach (var item in disbursementList.DisbursementListDetails)
         {
             DisbursementListDetailsDAO.CreateDisbursementListDetails(listId, item);
         }
     }
 }
Example #11
0
        public void DepartmentDAOUpdateShouldReturnTrue()
        {
            DepartmentDAO dao = new DepartmentDAO();
            //simulate user 1 getting an employee
            Department dep = dao.GetByID("564107b33dd4ed255425f4c5"); //administrations' id

            dep.DepartmentName = "Administration";
            int rowsUpdated = dao.Update(dep);

            //user 1 makes update
            Assert.IsTrue(rowsUpdated == 1);
        }
        public void Update(int ID, string Name, string Address)
        {
            Department dep = new Department()
            {
                ID      = ID,
                Name    = Name,
                Address = Address
            };
            DepartmentDAO dao = new DepartmentDAO();

            dao.Update(dep);
        }
        public static SalaryDTO GetAll()
        {
            SalaryDTO salaryDTO = new SalaryDTO();

            salaryDTO.Employees   = EmployeeDAO.GetEmployees();
            salaryDTO.Departments = DepartmentDAO.GetDepartments();
            salaryDTO.Positions   = PositionDAO.GetPositions();
            salaryDTO.Months      = SalaryDAO.GetMonths();
            salaryDTO.Salaries    = SalaryDAO.GetSalaries();

            return(salaryDTO);
        }
Example #14
0
        public void TestDeleteShouldReturnOne()
        {
            DepartmentDAO dao = new DepartmentDAO();
            Department    dep = dao.GetByDepartmentName("Medical");

            if (dep == null)//did delete run before create
            {
                TestCreateShouldReturnNewId();
                dep = dao.GetByDepartmentName("Medical");
            }
            Assert.IsTrue(dao.Delete(dep.GetIdAsString()) == 1);
        }
Example #15
0
        public void TestUpdateShouldReturnStale()
        {
            DepartmentDAO dao  = new DepartmentDAO();
            Department    dep  = dao.GetByDepartmentName("Lab");
            Department    dep2 = dao.GetByDepartmentName("Lab");

            dep.DepartmentName  = "Butcher";
            dep2.DepartmentName = "LOL";
            UpdateStatus status = dao.Update(dep);

            Assert.IsTrue(dao.Update(dep2) == UpdateStatus.Stale);
        }
Example #16
0
        /// <summary>
        /// 创建节点
        /// </summary>
        private void CreateTreeVie()
        {
            DepartmentDAO dptDAO   = new DepartmentDAO();
            ArrayList     dptList  = dptDAO.GetAllDepartments();
            TreeNode      rootNode = null;

            foreach (Department dpt in dptList)
            {
                rootNode = new TreeNode(dpt.Depname.ToString());
                treeView1.Nodes.Add(rootNode);
            }
        }
Example #17
0
        public DataTable GetDeptInfo()
        {
            DataTable dt = DepartmentDAO.GetAllDepartments();

            if (dt != null)
            {
                return(dt);
            }
            else
            {
                return(null);
            }
        }
 public void TestGetAllDepartment()
 {
     try
     {
         DepartmentDAO     dep         = new DepartmentDAO();
         List <Department> departments = dep.GetAll();
         Assert.Contains(departments, d => d.ID != 0);
     }
     catch (Exception ex)
     {
         Assert.False(true, ex.Message);
     }
 }
        public int UpdateDepartmentByCode(Department dept)
        {
            DepartmentDAO dDAO = new DepartmentDAO();

            int row = dDAO.UpdateDepartmentInfo(dept);

            if (row != 0) // update successful
            {
                EmailNotification.EmailNotificationForCollectionPointChange(dept.departmentCode);
            }

            return(row);
        }
Example #20
0
    public void TestDeleteShouldReturnOne()
    {
        DepartmentDAO dao = new DepartmentDAO();
        Department    dep = dao.GetByDepartment("Test Department");

        if (dep == null)                   // in case this test runs before the Create method test
        {
            TestCreateShouldReturnNewId(); // run it for sure
            dep = dao.GetByDepartment("Test Department");
        }

        Assert.IsTrue(dao.Delete(dep.GetIdAsString()) == 1);
    } // TestShouldReturnOne
Example #21
0
        public DepartmentViewModel departmentDetails()
        {
            string userId = User.Identity.GetUserId();
            Staff  s1     = StaffDepartmentDAO.GetStaffByUserId(userId);

            if (s1 == null)
            {
                return(null);
            }
            Department dep = DepartmentDAO.GetDepartmentByUserId(userId);

            return(StaffDepartmentDAO.ConvertDepartmentToDepartmentViewModel(dep));
        }
Example #22
0
        public EmployeeProjectsDto GetEmployeeProjectsDto(int EmployeeId)
        {
            EmployeeProjectsDto dto = new EmployeeProjectsDto();

            EmployeeDAO empDao = new EmployeeDAO();

            dto.Employee = empDao.GetFiltered("id", EmployeeId.ToString());

            DepartmentDAO depDao = new DepartmentDAO();

            dto.Departments = depDao.GetAll();

            return(dto);
        }
Example #23
0
        public List <WCFDept> getAllDept()
        {
            DepartmentDAO     deptDAO = new DepartmentDAO();
            List <Department> ldept   = deptDAO.findAll();
            List <WCFDept>    ld_wcf  = new List <WCFDept>();

            foreach (var i in ldept)
            {
                WCFDept wcfdept = new WCFDept(i.deptID, i.deptName, i.collectionPointID);
                ld_wcf.Add(wcfdept);// add in department list
            }

            return(ld_wcf);
        }
Example #24
0
 public Facade()
 {
     _contingencyFundDAO    = FactoryDAO.CreateContigencyFundDAO();
     _monetaryFundDAO       = FactoryDAO.CreateMonetaryFundDAO();
     _extraFundDAO          = FactoryDAO.CreateExtraFundDAO();
     _employeeDAO           = FactoryDAO.CreateEmployeeDAO();
     _roleDAO               = FactoryDAO.CreateRoleDAO();
     _bankDAO               = FactoryDAO.CreateBankDAO();
     _departmentDAO         = FactoryDAO.CreateDepartmentDAO();
     _contractDAO           = FactoryDAO.CreateContractDAO();
     _employeeHistoryDAO    = FactoryDAO.CreateEmployeeHistoryDAO();
     _contingencyPastDAO    = FactoryDAO.CreateContigencyPastDAO();
     _contingencyAliquotDAO = FactoryDAO.createContingencyAliquotDAO();
 }
Example #25
0
        public ProjectDepartmentsDTO GetProjectDepartmentsDTO(int ProjectId)
        {
            ProjectDepartmentsDTO output = new ProjectDepartmentsDTO();

            ProjectDAO projectDao = new ProjectDAO();

            output.Project = projectDao.GetFiltered("id", ProjectId.ToString());

            DepartmentDAO departmentDAO = new DepartmentDAO();

            output.Departments = departmentDAO.GetAll();

            return(output);
        }
Example #26
0
    public void TestUpdateShouldReturnOk()
    {
        DepartmentDAO dao  = new DepartmentDAO();
        Department    dep  = dao.GetById(id_string);
        string        name = dep.DepartmentName;

        dep.DepartmentName = "another name";
        Assert.IsTrue(dao.Update(dep) == UpdateStatus.Ok);

        // now revert back to original name!
        dep = dao.GetById(id_string);
        dep.DepartmentName = name;
        Assert.IsTrue(dao.Update(dep) == UpdateStatus.Ok);
    }// TestUpdateShouldReturOk
        public List <int> ExtractSalesReports( )
        {
            int year = DateTime.Now.Year;

            EmployeeDAO employeeDAO = new EmployeeDAO();

            RequestDAO requestDAO = new RequestDAO();

            DepartmentDAO departmentDAO = new DepartmentDAO();

            List <Department> departments = departmentDAO.GetDepartments();

            List <int> monthlySales = new List <int>(); //{paper,pen,stapler}

            foreach (Department d in departments)
            {
                List <RequestReport> requestReports = requestDAO.GetRequestsByDepartment(d.Id);

                if (requestReports != null)
                {
                    int[] sales = new int[3];

                    foreach (RequestReport request in requestReports)
                    {
                        if (request.ReqYear == year)     //DateTime.Today.year)
                        {
                            if (request.CategoryID == 1) //paper
                            {
                                sales[0] += request.Qty;
                            }
                            else if (request.CategoryID == 2) //pen
                            {
                                sales[1] += request.Qty;
                            }
                            else //stapler
                            {
                                sales[2] += request.Qty;
                            }
                        }
                    }
                    //monthlySales.Add(DateTime.Today.Month);
                    monthlySales.Add(sales[0]);
                    monthlySales.Add(sales[1]);
                    monthlySales.Add(sales[2]);
                }
            }
            System.Diagnostics.Debug.WriteLine(monthlySales);
            return(monthlySales);
        }
Example #28
0
        private void LoadDepartment()
        {
            DepartmentDAO d = new DepartmentDAO();
            DataSet       s = d.GetAllDepartment();

            tabDepartment = s.Tables[0];

            comboBoxDep.DisplayMember = "Name";
            comboBoxDep.ValueMember   = "Id";
            if (comboBoxDep.Items.Count > 0)
            {
                comboBoxDep.SelectedIndex = 0;
            }
            comboBoxDep.DataSource = tabDepartment;
        }
Example #29
0
        private void LoadData()
        {
            treeList.Nodes.Clear();
            comboBoxEditParent.Properties.Items.Clear();
            DepartmentDAO d   = new DepartmentDAO();
            DataSet       set = d.GetAllDepartment();

            tabData             = set.Tables[0];
            treeList.DataSource = tabData;
            foreach (DataRow r in tabData.Rows)
            {
                comboBoxEditParent.Properties.Items.Add(r["Name"]);
            }
            treeList.ExpandAll();
        }
        public void TestInsertSqlBuilder()
        {
            DepartmentDAO dep = new DepartmentDAO();



            string actual = dep.InsertSqlBuilder("departments",
                                                 new List <string>()
            {
                "name", "address"
            }
                                                 );

            Assert.Equal("insert into departments (name, address) values (@name, @address);", actual);
        }
Example #31
0
 public StoreManagerController()
 {
     _itemDAO                 = new ItemDAO();
     _supplieritemDAO         = new SupplierItemDAO();
     _purchaseOrderDAO        = new PurchaseOrderDAO();
     _purchaseOrderDetailsDAO = new PurchaseOrderDetailsDAO();
     _disbursementDAO         = new DisbursementDAO();
     _disbursementItemDAO     = new DisbursementItemDAO();
     _stockRecordDAO          = new StockRecordDAO();
     _notificationChannelDAO  = new NotificationChannelDAO();
     _requisitionDAO          = new RequisitionDAO();
     _requisitionItemDAO      = new RequisitionItemDAO();
     _categoryDAO             = new CategoryDAO();
     _departmentDAO           = new DepartmentDAO();
 }
Example #32
0
        public void DepartmentDAOCreateAndDeleteShouldReturnTrue()
        {
            bool          deleteOk = false;
            Department    dep      = new Department();
            DepartmentDAO dao      = new DepartmentDAO();

            dep.DepartmentName = "Human Resources";  // and some hardcoded data

            string newid = dao.Create(dep);

            if (newid.Length == 24) // new id's are a 24 byte hex string
            {
                deleteOk = dao.Delete(newid);
            }
            Assert.IsTrue(deleteOk);
        }
 private void cbFirm_SelectedIndexChanged(object sender, EventArgs e)
 {
     DepartmentDAO daoDepartment = new DepartmentDAO();
     if (cbFirm.SelectedIndex >= 0)
     {
         cbDepartment.Items.Clear();
         cbDepartment.Items.AddRange(daoDepartment.getComboBox(Convert.ToInt32(((KeyValuePair)cbFirm.SelectedItem).Key)).ToArray());
         cbDepartment.Enabled = true;
     }
 }
Example #34
0
 public DepartmentBUS()
 {
     dpmDAO = new DepartmentDAO();
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (isValid())
     {
         generateBookMark();
         if (addUser)
         {
             User user = new User();
             user.FirstName = tbFirstName.Text;
             user.SecondName = tbSecondName.Text;
             user.ThirdName = tbThirdName.Text;
             user.Appointment = tbAppointment.Text;
             DepartmentDAO daoDepartment = new DepartmentDAO();
             user.Department = daoDepartment.getById(Convert.ToInt32(((KeyValuePair)(cbDepartment.SelectedItem)).Key));
             user.Login = tbLogin.Text;
             user.Password = tbPassword.Text;
             user.HashPass = Encoding.ASCII.GetString(new SHA1CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(tbPassword.Text)));
             user.TypeUser = (rbUser.Checked) ? (int)AdvanceUtil.typeUser.USER : (int)AdvanceUtil.typeUser.ADMIN;
             user.Email = tbEmail.Text;
             user = dao.insert(user);
             if (user.Id == 0)
             {
                 MessageBox.Show("Пользователь не добавлен");
             }
         }
         else
         {
             User user = new User();
             user = (User)((BindingSource)gridUsers.DataSource).Current;
             user.FirstName = tbFirstName.Text;
             user.SecondName = tbSecondName.Text;
             user.ThirdName = tbThirdName.Text;
             user.Appointment = tbAppointment.Text;
             DepartmentDAO daoDepartment = new DepartmentDAO();
             user.Department = daoDepartment.getById(Convert.ToInt32(((KeyValuePair)(cbDepartment.SelectedItem)).Key));
             user.Login = tbLogin.Text;
             user.Password = tbPassword.Text;
             user.HashPass = Encoding.ASCII.GetString(new SHA1CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(tbPassword.Text)));
             user.TypeUser = (rbUser.Checked) ? (int)AdvanceUtil.typeUser.USER : (int)AdvanceUtil.typeUser.ADMIN;
             user.Email = tbEmail.Text;
             dao.update(user);
         }
         initializationData();
     }
 }
 public void InitializationDataBox()
 {
     DepartmentDAO daoDepartment = new DepartmentDAO();
     cbDepartment.Items.AddRange(daoDepartment.getComboBox().ToArray());
 }