/// <summary>
        /// An item is being added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties)
        {
            base.ItemAdded(properties);
            try
            {
                SPListItem curItem = properties.ListItem;

                var departmentRepo = new DepartmentDAL(properties.Site.Url);
                departmentRepo.CreateDepartmentSite(properties.SiteId, properties.Web.ID, curItem);

                // Add bod approver to BOD group
                var userBodString = Convert.ToString(properties.ListItem[StringConstant.DepartmentList.BODField]);
                if (!string.IsNullOrEmpty(userBodString))
                {
                    var employeeInfoRepo = new EmployeeInfoDAL(properties.Site.Url);
                    employeeInfoRepo.AddUserToGroup(properties.Site.ID, properties.Web.ID, curItem, StringConstant.Group.BODGroupName, userBodString);
                }
            }
            catch (Exception ex)
            {
                ULSLogging.Log(new SPDiagnosticsCategory("STADA - Department Event Receiver - ItemAdded fn",
                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
            }
        }
        public void GetById()
        {
            DepartmentDAL dal        = new DepartmentDAL();
            Department    department = dal.GetById(1);

            log.Debug(department);
        }
Exemple #3
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //using (TransactionScope ts = new TransactionScope())
            //{
            //    DepartmentDAL deptDal = new DepartmentDAL();
            //    deptDal.Insert("aaa");
            //    deptDal.Insert("fffffffffffffffffffffffffff");
            //    test2();//嵌套事务
            //    throw new Exception();

            //    ts.Complete();
            //}

            using (TransactionScope ts = new TransactionScope())
            {
                DepartmentDAL dal = new DepartmentDAL();
                dal.Insert("测试1");

                //EmployeeDAL employeeDAl = new EmployeeDAL();
                //Employee emp = new Employee();
                //emp.
                //employeeDAl.Insert(emp);
                Operator op = new Operator();
                op.UserName = "******";
                op.Password = "******";
                op.RealName = "haha";
                new OperatorDAL().Insert(op);

                ts.Complete();
            }
        }
Exemple #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            EmployeeInformationDAL EmpInforDAL = new EmployeeInformationDAL();
            RankDAL       rankDAL   = new RankDAL();
            DepartmentDAL departDAL = new DepartmentDAL();

            cmbGender.ItemsSource     = EmpInforDAL.GetNameByCategory("Gender");
            cmbRank.ItemsSource       = rankDAL.ListAll();
            cmbDepartment.ItemsSource = departDAL.ListAll();

            Employee employee = new Employee();

            employee.Birthday          = DateTime.Today;
            employee.ContractStartDate = DateTime.Today;
            employee.ContractEndDate   = DateTime.Today.AddYears(1);
            employee.RankID            = rankDAL.GetRankIDByRankName("Staff");
            //employee.Password = pwdPassword.Password;
            employee.DepartmentID = EditerDptID;
            employee.PaidFreq     = txtPaidFreq.Text;

            if (IsEdited == false)
            {
                gridEdit.DataContext = employee;
            }
            else
            {
                Employee newemployee = new EmployeeDAL().GetByUerName(SelectedUserName);
                gridEdit.DataContext = newemployee;
            }
        }
        private void Admin_UpdateCourse_Load(object sender, EventArgs e)
        {
            textBox1.Text = MyCourse.C.Name;
            depts         = DepartmentDAL.GetAll();

            for (int i = 0; i < depts.Count; i++)
            {
                ComboboxItem item = new ComboboxItem();
                item.Text  = depts[i].Name;
                item.Value = depts[i].Id;
                comboBox1.Items.Add(item);
            }

            String text;
            int    id;
            int    super = 0;

            for (int i = 0; i < depts.Count; i++)
            {
                if (depts[i].Id == MyCourse.C.Deparment.Id)
                {
                    super = i;
                    break;
                }
            }

            comboBox1.SelectedText  = MyCourse.C.Deparment.Name;
            comboBox1.SelectedValue = MyCourse.C.Deparment.Id;
            comboBox1.SelectedIndex = super;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            cbDepartment.ItemsSource  = DepartmentDAL.ListALL();
            cbEducation.ItemsSource   = IdNameDAL.GetByCatagory("学历");
            cbGender.ItemsSource      = IdNameDAL.GetByCatagory("性别");
            cbMarriage.ItemsSource    = IdNameDAL.GetByCatagory("婚姻状况");
            cbPartyStatus.ItemsSource = IdNameDAL.GetByCatagory("政治面貌");
            if (IsAddNew)
            {
                Employee employee = new Employee();
                employee.InDate           = DateTime.Today;
                employee.ContractStartDay = DateTime.Today;
                employee.ContractEndDay   = DateTime.Today.AddYears(1);
                employee.Nationality      = "汉族";
                employee.Email            = "*****@*****.**";
                //employee.Number = "Ideas";
                employee.Number          = SettingDAL.GetValue("员工工号前缀");
                gridEmployee.DataContext = employee;
            }
            else
            {
                Employee employee = EmployeeDAL.GetById(EditingId);
                gridEmployee.DataContext = employee;

                if (employee.Photo != null)
                {
                    ShowImage(employee.Photo);
                }
            }
        }
        private void ReadWriteCSVFile()
        {
            string date = System.DateTime.Now.ToString("ddMMyyhhmmss");

            if (File.Exists(Server.MapPath(uppath)))
            {
                StreamReader             sr      = new StreamReader(Server.MapPath(uppath));
                StreamWriter             write   = new StreamWriter(Server.MapPath(output));
                CsvReader                csvread = new CsvReader(sr);
                CsvWriter                csw     = new CsvWriter(write);
                IEnumerable <Department> record  = csvread.GetRecords <Department>();

                foreach (var rec in record) // Each record will be fetched and printed on the screen
                {
                    csw.WriteRecord <Department>(rec);
                    csw.NextRecord();
                    DepartmentDAL departmentDAL = new DepartmentDAL();
                    departmentDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
                    departmentDAL.InsertDepartment(rec);
                }
                sr.Close();
                write.Close();//close file streams

                if (File.Exists(Server.MapPath(uppath)))
                {
                    File.Delete(Server.MapPath(uppath));
                }
            }
        }
Exemple #8
0
 public List <DepartmentInfo> GetDepartmentsByLcid(string lcid, string locationIds)
 {
     try
     {
         List <DepartmentInfo> departments        = new List <DepartmentInfo>();
         DepartmentDAL         departmentDAL      = new DepartmentDAL(SPContext.Current.Web.Url);
         List <int>            locationCollection = locationIds.SplitStringOfLocations().ConvertAll(e => Convert.ToInt32(e));
         var departmentList = departmentDAL.GetByLocations(locationCollection);
         if (departmentList.Any())
         {
             foreach (var item in departmentList)
             {
                 string departmentName = lcid.Equals("1066") ? item.VietnameseName : item.Name;
                 departments.Add(new DepartmentInfo()
                 {
                     Id = item.ID, DepartmentName = departmentName
                 });
             }
         }
         return(departments);
     }
     catch (Exception ex)
     {
         ULSLogging.Log(new SPDiagnosticsCategory("STADA - Department Service - GetDepartmentsByLcid",
                                                  TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                        string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
         return(null);
     }
 }
Exemple #9
0
        private void _Save()
        {
            msg = "";
            DepartmentModel dpt = new DepartmentModel();

            dpt.DepartmentName = txtDepartmentName.Text.Trim();
            dpt.Description    = txtDescription.Text.Trim();
            if (ckbIsActive.Checked == true)
            {
                dpt.IsActive = true;
            }
            else
            {
                dpt.IsActive = false;
            }
            DepartmentDAL objDal = new DepartmentDAL();

            if (btnSave.Text == "Save")
            {
                msg = objDal._insertUpdateDeleteDepartment(dpt, "Insert");
            }
            else
            {
                dpt.DepartmentId = Convert.ToInt32(HdnDepartmentId.Value);
                msg = objDal._insertUpdateDeleteDepartment(dpt, "Update");
            }
            if (msg != "")
            {
                _Refresh();
            }
        }
        /// <summary>
        /// 添加一个部门
        /// </summary>
        /// <returns>返回新部门的ID</returns>
        public int Add()
        {
            DepartmentDAL dal = new DepartmentDAL(connectionString);

            _id = dal.Add(_deptid, _deptname, _state);
            return(_id);
        }
        /// <summary>
        /// Get All Department
        /// </summary>
        /// <returns></returns>
        public ActionResult GetAllDepartment()
        {
            DepartmentDAL departmentDAL = new DepartmentDAL();

            ModelState.Clear();
            return(View(departmentDAL.GetAllDepartment()));
        }
        protected void btnAddNewDept_Click(object sender, EventArgs e)
        {
            string confirmValue = Request.Form["confirm_value"];

            if (confirmValue == "Yes")
            {
                //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked YES!')", true);
            }
            else
            {
                //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked NO!')", true);
            }

            DepartmentDAL departmentDAL = new DepartmentDAL();
            Department    com           = new Department();

            departmentDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
            com.ID          = Convert.ToInt32(tbAddID.Text);
            com.Name        = tbAddDepartmentName.Text;
            com.NameAr      = tbAddArname.Text;
            com.CompanyName = tbAddCompName.Text;


            departmentDAL.InsertDepartment(com);
            gvDept.EditIndex         = -1;
            tbAddID.Text             = string.Empty;
            tbAddDepartmentName.Text = string.Empty;
            tbAddArname.Text         = string.Empty;
            tbAddCompName.Text       = string.Empty;
            GetDepartments();
        }
 public bool IsMemberOfDepartmentByCode(string employeeId, string departmentCode)
 {
     try
     {
         var departmentDal = new DepartmentDAL(SPContext.Current.Web.Url);
         var employeeDal   = new EmployeeInfoDAL(SPContext.Current.Web.Url);
         var department    = departmentDal.GetByCode(departmentCode);
         if (department != null)
         {
             var employee = employeeDal.GetByDepartment(Convert.ToInt32(employeeId), Convert.ToInt32(department.ID), true); //get user active
             if (employee != null)
             {
                 return(true);
             }
         }
         return(false);
     }
     catch (Exception ex)
     {
         SPDiagnosticsService.Local.WriteTrace(0,
                                               new SPDiagnosticsCategory("STADA - Employee Service - IsMemberOfDepartmentByCode fn",
                                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
         return(false);
     }
 }
Exemple #14
0
        private void FillDepartmentDetails(long iDeptId)
        {
            Department    oDepartment    = new Department();
            DepartmentDAL oDepartmentDAL = new DepartmentDAL();

            if (iDeptId > 0)
            {
                oDepartment.Cmd_Name = "SelectSingleDepartment";
                oDepartment.Dept_id  = iDeptId;
                DataTable dt = oDepartmentDAL.GetDepartmentList(oDepartment);
                if (dt.Rows.Count > 0)
                {
                    txtDeptName.Text = dt.Rows[0]["Dept_Name"].ToString().Trim();
                }
                btnAdd.Visible    = false;
                btnDelete.Visible = true;
                btnUpdate.Visible = true;
            }
            else
            {
                oDepartment.Cmd_Name = "SelectAllDepartment";
                DataTable dt = oDepartmentDAL.GetDepartmentList(oDepartment);
                grvDepartment.DataSource = dt;
                grvDepartment.DataBind();
                btnAdd.Visible    = true;
                btnDelete.Visible = false;
                btnUpdate.Visible = false;
            }
        }
        private void LoadDataByID(int iDptID)
        {
            Department    oDpt    = new Department(iDptID);
            DepartmentDAL oDptDAL = new DepartmentDAL();

            Result oResult = new Result();

            oResult = oDptDAL.LoadByID(oDpt);
            ClearTextValue();
            if (oResult.Status)
            {
                oDpt = (Department)oResult.Return;
                if (oDpt != null)
                {
                    txtDepartmentID.Text   = oDpt.DepartmentID.ToString();
                    txtDepartmentName.Text = oDpt.Description.ToString();

                    ucUserDet.UserDetail = oDpt.UserDetails;
                    hdDptID.Value        = iDptID.ToString();
                }
                else
                {
                    ucMessage.OpenMessage(Constants.MSG_ERROR_NOT_FOUND, Constants.MSG_TYPE_INFO);
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(string), Constants.POPUP_WINDOW, Util.OpenPopup("info"), true);
                }
            }
            else
            {
                ucMessage.OpenMessage(Constants.MSG_ERROR_NOT_FOUND, Constants.MSG_TYPE_ERROR);
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(string), Constants.POPUP_WINDOW, Util.OpenPopup("Delete"), true);
            }
        }
        // ok
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(hdDptID.Value))
            {
                DepartmentDAL oDptDAL = new DepartmentDAL();
                Result        oResult = (Result)oDptDAL.Detete(hdDptID.Value);
                if (oResult.Status)
                {
                    this.LoadList();
                    this.ClearTextValue();

                    ucMessage.OpenMessage(Constants.MSG_SUCCESS_DELETE, Constants.MSG_TYPE_SUCCESS);
                }
                else
                {
                    if (oResult.Message.Equals(Constants.TABLE_MAIN))
                    {
                        ucMessage.OpenMessage(Constants.MSG_APPROVED_DELETE_DATA, Constants.MSG_TYPE_ERROR);
                    }
                    else
                    {
                        ucMessage.OpenMessage(Constants.MSG_ERROR_DELETE, Constants.MSG_TYPE_ERROR);
                    }
                }
            }
            else
            {
                ucMessage.OpenMessage(Constants.MSG_ERROR_DELETE, Constants.MSG_TYPE_ERROR);
            }
        }
        /// <summary>
        /// Delete Department
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult DeleteDepartment(int id)
        {
            DepartmentDAL departmentDAL = new DepartmentDAL();
            string        result        = departmentDAL.DeleteDepartment(id);

            ViewData["result"] = result;
            ModelState.Clear();
            return(RedirectToAction("GetAllDepartment"));
        }
Exemple #18
0
    public DataSet Find_Depdet(String str)
    {
        DepartmentDAL PDALF = new DepartmentDAL();
        DataSet       data  = null;

        data = PDALF.Find_dep(str);    //PDAL.Find(str);

        return(data);
    }
        public ActionResult UpdateDepartment(DepartmentCustom data)
        {
            DepartmentDAL departmentDAL = new DepartmentDAL();
            string        result        = departmentDAL.UpdateDepartment(data);

            ViewData["result"] = result;
            ModelState.Clear();
            return(View());
        }
Exemple #20
0
        public void Update()
        {
            DepartmentDAL dal        = new DepartmentDAL();
            Department    department = dal.GetById(1);

            department.Name = "DIT .NET";
            dal.Update(department);
            //department = dal.GetById(1);
        }
 protected void gvDept_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteDepartment")
     {
         DepartmentDAL departmentDAL = new DepartmentDAL();
         departmentDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
         departmentDAL.DeleteDepartment(e.CommandArgument.ToString());
         GetDepartments();
     }
 }
        public EmployeeService()
        {
            var url = SPContext.Current.Web.Url;

            _employeeInfoDAL             = new EmployeeInfoDAL(url);
            _departmentDAL               = new DepartmentDAL(url);
            _overtimeManagementDAL       = new OverTimeManagementDAL(url);
            _overtimeManagementDetailDAL = new OverTimeManagementDetailDAL(url);
            _employeePositionDAL         = new EmployeePositionDAL(url);
        }
        private void GetDepartments(string Name)
        {
            DepartmentDAL departmentDAL = new DepartmentDAL();

            departmentDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
            List <Department> DepartmentsList = departmentDAL.GetDepartment(Name);

            gvDept.DataSource = DepartmentsList;
            gvDept.DataBind();
        }
Exemple #24
0
        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            if (!IsAddNew)
            {
                Department dept = new DepartmentDAL().GetById(EditingId);
                txtName.Text = dept.Name;
            }

            txtName.Focus();
        }
        // 修改验证是否存在
        public static bool IsTrue(string Name, int Id)
        {
            Department model = DepartmentDAL.GetIdByName(Name);

            if (model != null && model.DeptId != 0 && model.DeptId != Id)
            {
                return(true);
            }
            return(false);
        }
 public static IList <Department> DepartmentListInstance(string siteURL)
 {
     // TODO: not thread-safe, should lock object to ensure thread-safe
     if (departments == null)
     {
         departmentDAL = new DepartmentDAL(siteURL);
         departments   = departmentDAL.GetAll();
     }
     return(departments);
 }
Exemple #27
0
        private void _LoadGrid()
        {
            DepartmentDAL Dept = new DepartmentDAL();
            DataTable     dt   = new DataTable();

            dt = Dept._SelectAllDepartment();
            gvDepartment.DataSource = dt;
            gvDepartment.DataBind();
            Session["Ses_Department"] = dt;
        }
Exemple #28
0
        static void Main(string[] args)
        {
            int              studentId        = 3;
            StudentDAL       studentDAL       = new StudentDAL();
            DepartmentDAL    departmentDAL    = new DepartmentDAL();
            CoueseTeacherDAL courseTeacherDAL = new CoueseTeacherDAL();
            var              StudentEnroll    = from s in studentDAL.StudentEnrollListGetAll()
                                                join c in courseTeacherDAL.CourseGetAll() on s.CourseId equals c.CourseId
                                                select new
            {
                StudentId      = s.StudentId,
                StudentName    = s.StudentName,
                StudentEmail   = s.StudentEmail,
                DepartmentName = s.DepartmentName,
                CourseCode     = c.CourseCode,
                CourseName     = c.CourseName,
                CourseId       = c.CourseId,
            };

            var StudentEnrollByStudentId = StudentEnroll.Where(c => c.StudentId == studentId).ToList();
            var StudentResulByStudentId  = studentDAL.SaveStudentResultGetAll().Where(c => c.StudentId == studentId).ToList();

            var result = from e in StudentEnrollByStudentId
                         join d in StudentResulByStudentId
                         on e.CourseId equals d.CourseId into eGroup
                         from d in eGroup.DefaultIfEmpty()
                         select new
            {
                StudentId      = e.StudentId,
                StudentName    = e.StudentName,
                StudentEmail   = e.StudentEmail,
                DepartmentName = e.DepartmentName,
                CourseId       = e.CourseId,
                CourseCode     = e.CourseCode,
                CourseName     = e.CourseName,
                GradeLatter    = d == null ? "Not  Graded  Yet" : d.GradeLetter
            };

            foreach (var c in result)
            {
                Console.WriteLine(c.StudentId + "\t" + c.StudentName + "\t"
                                  + c.StudentEmail + "\t" + c.DepartmentName + "\t"
                                  + c.CourseId + "\t" + c.CourseCode + "\t" + c.CourseName + "\t" + c.GradeLatter
                                  );
            }
            Console.ReadKey();
            //foreach (var c in result)
            //{
            //    Console.WriteLine(c.StudentId + "\t" + c.StudentName + "\t"
            //                      + c.StudentEmail + "\t" + c.DepartmentName + "\t"
            //                      + c.CourseCode + "\t" + c.CourseName + "\t" + c.GradeLatter
            //                      );
            //}
            //Console.ReadKey();
        }
Exemple #29
0
 public static bool DeleteOrganisationComm(int departmentID)
 {
     try
     {
         return(DepartmentDAL.DeleteDepartment(departmentID));
     }
     catch (Exception ex)
     {
         throw new EvolutionBusinessLogic.Exceptions.EvolutionException(ex.Message, ex.InnerException);
     }
 }
Exemple #30
0
 public static bool InsertOrganisationComm(Department department)
 {
     try
     {
         return(DepartmentDAL.InsertDepartment(department));
     }
     catch (Exception ex)
     {
         throw new EvolutionBusinessLogic.Exceptions.EvolutionException(ex.Message, ex.InnerException);
     }
 }