Beispiel #1
0
 public static Boolean CreateDepartment(Department deptartment)
 {
     Boolean flag = false;
     using (TransactionScope scope = new TransactionScope())
     {
         if (!(IsExistingDeptarmentCode(deptartment.DeptCode)))
         {
             using (var context = new SycousCon())
             {
                 try
                 {
                     context.Departments.AddObject(deptartment);
                     context.SaveChanges();
                     scope.Complete();
                     context.AcceptAllChanges();
                     flag = true;
                 }
                 catch (Exception ex)
                 {
                     context.Dispose();
                     throw;
                 }
             }
         }
     }
     return flag;
 }
Beispiel #2
0
        public DepartmentEditDialog(DAL.Department department)
        {
            this.department = department;

            InitializeComponent();
            this.LoadData();
        }
Beispiel #3
0
        public bool CreateRecord(Object dept)
        {
            Boolean flag = false;
            DepartmentClass department = (DepartmentClass)dept;
            try
            {
                Department _department = new Department();
                if (department.DepartmentName != null)
                {
                    _department.DeptName = department.DepartmentName.Trim();
                }
                if (department.DepartmentCode != null)
                {
                    _department.DeptCode = department.DepartmentCode.ToUpper().Trim();
                }
                _department.CreateDate = DateTime.Now;
                _department.CreateBy = department.CreateBy;
                flag = DAL.DALDepartment.CreateDepartment(_department);
            }
            catch (Exception ex)
            {
                throw;
            }

            return flag;
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridViewDepartments.SelectedRows.Count != 0)
                {
                    DAL.Department dep = (DAL.Department)bindingSourceDepartments.Current;

                    var _employeewithdepartmentquery = from br in rep.GetEmployeesWithDepartment(dep)
                                                       select br;
                    List <DAL.Employee> _employees = _employeewithdepartmentquery.ToList();

                    if (_employees.Count > 0)
                    {
                        MessageBox.Show("There is an Employee Associated with this Department\nDelete the Employee first!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    if (DialogResult.Yes == MessageBox.Show("Are you sure you want to delete Department\n" + dep.Description.ToString().Trim().ToUpper(), "Confirm Delete", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                    {
                        rep.DeleteDepartment(dep);
                        RefreshGrid();
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowError(ex);
            }
        }
Beispiel #5
0
        private void btDeleteDepartment_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            DAL.Department department = (DAL.Department)btn.Tag;
            this.DeleteDepartment(department);
        }
Beispiel #6
0
 private static void AddDepartment()
 {
     Department dept = new Department()
     {
         Name = "IT"
     };
     operations.AddDept(dept);
 }
Beispiel #7
0
        private void btnAddEmloyee_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            DAL.Department department = (DAL.Department)btn.Tag;
            new EmloyeeAddDialog(department).ShowDialog();
            this.LoadData();
        }
Beispiel #8
0
        public static bool Execute(DAL.Department department)
        {
            using (var fm = new xfmEditDepartment())
            {
                fm.Department = department;
                var dr = fm.ShowDialog();

                return(dr == DialogResult.OK);
            }
        }
Beispiel #9
0
        private void EditDepartment(DAL.Department department)
        {
            DepartmentEditDialog departmentEditDialog = new DepartmentEditDialog(department);
            DialogResult         dr = departmentEditDialog.ShowDialog();

            if (dr == DialogResult.OK)
            {
                this.LoadData();
            }
        }
        public void CreateDepartment()
        {
            Department department = new Department()
            {
                Name = "Test Department",
            };

            Department newDepartment = Facade.GetDepartmentRepository().Create(department);

            Assert.AreEqual(department.Name, newDepartment.Name);
        }
 public bool deleteDepartment(Department d)
 {
     try
     {
         ContextDB.Departments.DeleteObject(d);
         ContextDB.SaveChanges();
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
Beispiel #12
0
        /// <summary>
        /// Действия при добавлении подразделения
        /// </summary>
        private void DoInsert()
        {
            var department = new DAL.Department()
            {
                Name      = TEName.Text,
                Code      = TECode.Text,
                DtCreated = DateTime.Now,
                ParentId  = (int)LUEDepartment.EditValue,
                IsActive  = CEIsActiv.Checked,
            };

            DataManager.Instance.Departments.Add(department);
            this.Close();
        }
Beispiel #13
0
        private void DeleteDepartment(DAL.Department department)
        {
            DialogResult dr = MessageBox.Show("Are you sure to delete department \"" + department.Name + "\"", "Confirm", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                EmloyeeDepartmentBLL emloyeeDepartmentBLL = new EmloyeeDepartmentBLL();
                EmployeeBLL          employeeBLL          = new EmployeeBLL();
                employeeBLL.DeleteByDepartment(emloyeeDepartmentBLL.ListEmployeeDepartmentByDepartment(department));
                DepartmentBLL departmentBLL = new DepartmentBLL();
                departmentBLL.DeleteDepartment(department);
                this.LoadData();
            }
        }
Beispiel #14
0
 public int CreateDepartment(DepartmentModel department)
 {
     using (geekinsidekmsEntities context =
         new geekinsidekmsEntities())
     {
         Department dbDepartment = new Department
         {
             DepartmentName = department.DepartmentName,
             FolderId = department.FolderId
         };
         context.Departments.AddObject(dbDepartment);
         context.SaveChanges();
         return dbDepartment.Id;
     }
 }
        public EditDepartment(DAL.Department department, string Conn)
        {
            InitializeComponent();

            if (string.IsNullOrEmpty(Conn))
            {
                throw new ArgumentNullException("connection");
            }
            connection = Conn;

            de  = new DataEntry(connection);
            db  = new SBPayrollDBEntities(connection);
            rep = new Repository(connection);

            _department = department;
        }
        public List<Department> getDepartment(Department d)
        {
            var q = from dept in ContextDB.Departments
                    where (dept.Dept_ID == d.Dept_ID || d.Dept_ID == null)
                    && (dept.Dept_Name == d.Dept_Name || d.Dept_Name == null)
                    && (dept.Contact_ID == d.Contact_ID || d.Contact_ID == null)
                    && (dept.Contact_Name == d.Contact_Name || d.Contact_Name == null)
                    && (dept.Phone == d.Phone || d.Phone == null)
                    && (dept.Fax_No == d.Fax_No || d.Fax_No == null)
                    && (dept.Head_ID == d.Head_ID || d.Head_ID == null)
                    && (dept.Head_Name == d.Head_Name || d.Head_Name == null)
                    && (dept.Collection_Point == d.Collection_Point || d.Collection_Point == null)
                    && (dept.Representative_ID == d.Representative_ID || d.Representative_ID == null)
                    && (dept.Representative_Name == d.Representative_Name || d.Representative_Name == null)
                    select dept;

            return q.ToList<Department>();
        }
 private void btnEdit_Click(object sender, EventArgs e)
 {
     try
     {
         if (dataGridViewDepartments.SelectedRows.Count != 0)
         {
             DAL.Department       dep = (DAL.Department)bindingSourceDepartments.Current;
             Forms.EditDepartment f   = new EditDepartment(dep, connection)
             {
                 Owner = this
             };
             f.Text = dep.Description.ToString().Trim().ToUpper();
             f.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         Utils.ShowError(ex);
     }
 }
Beispiel #18
0
        /// <summary>
        /// Действия при добавлении подразделения
        /// </summary>
        private void DoInsert()
        {
            try
            {
                var department = new DAL.Department()
                {
                    Name      = NameTxb.Text,
                    Code      = CodeTxb.Text,
                    DtCreated = DateTime.Now,
                    ParentId  = (int)DepartmentCbBx.SelectedValue,
                    IsActive  = IsActiveDepartmentChb.Checked,
                };

                DataManager.Instance.Departments.Add(department);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #19
0
        /// <summary>
        /// Добавление нового департамента
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SBAddDepartnent_Click(object sender, EventArgs e)
        {
            try
            {
                DAL.Department department = new DAL.Department
                {
                    Id   = 0,
                    Name = "",
                    Code = ""
                };

                if (fmEditDepartment.Execute(department))
                {
                    TLLoadDepartmentsList();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #20
0
        public List <TestRecorder> SelectListByTestID(int testID)
        {
            List <TestRecorder> recorderList = new List <TestRecorder>();

            SqlParameter[] parms =
            {
                new SqlParameter("@testID", SqlDbType.Int, 4)
            };
            parms[0].Value = testID;

            using (SqlDataReader dr = DBHelper.Select("UP_T_TestRecorder_GetListByTestID", parms))
            {
                while (dr.Read())
                {
                    TestRecorder recoder = new TestRecorder();
                    recoder.Test.TestID        = testID;
                    recoder.Test.TestName      = dr["testName"].ToString();
                    recoder.Test.PaperType     = (PaperType)dr["paperType"];
                    recoder.Test.Paper.PaperID = Convert.ToInt32(dr["paperID"]);
                    Tester tester = new Tester();
                    recoder.RecorderID = Convert.ToInt32(dr["recorderID"]);
                    tester.UserID      = dr["userID"].ToString();
                    tester.Name        = dr["Name"].ToString();
                    Department dept = new Department();
                    dept.DeptName     = dr["deptName"].ToString();
                    tester.Department = dept;
                    recoder.Tester    = tester;
                    if (!string.IsNullOrEmpty(dr["BeginTestTime"].ToString()))
                    {
                        recoder.BeginTestTime = Convert.ToDateTime(dr["BeginTestTime"]);
                    }
                    else
                    {
                        recoder.BeginTestTime = new DateTime();
                    }

                    if (!string.IsNullOrEmpty(dr["SubmitTestTime"].ToString()))
                    {
                        recoder.SubmitTestTime = Convert.ToDateTime(dr["SubmitTestTime"]);
                    }
                    else
                    {
                        recoder.SubmitTestTime = new DateTime();
                    }

                    recoder.SubmitType = dr["SubmitType"].ToString();
                    recoder.Marked     = Convert.ToBoolean(dr["marked"]);
                    recoder.HasTested  = Convert.ToBoolean(dr["hasTested"]);

                    if (!dr["totalScore"].ToString().Trim().Equals(""))
                    {
                        recoder.TotalScore = Convert.ToInt32(dr["totalScore"]);
                    }
                    //     recoder.TestMark.TotalScore = Convert.ToUInt16(dr["totalScore"]);
                    //recoder.TestMark.Remark = dr["remark"].ToString();

                    recorderList.Add(recoder);
                }
            }

            return(recorderList);
        }
 /// <summary>
 /// Create a new Department object.
 /// </summary>
 /// <param name="deptID">Initial value of the DeptID property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 /// <param name="deleteStatus">Initial value of the DeleteStatus property.</param>
 public static Department CreateDepartment(global::System.Int32 deptID, global::System.Boolean status, global::System.Int32 deleteStatus)
 {
     Department department = new Department();
     department.DeptID = deptID;
     department.Status = status;
     department.DeleteStatus = deleteStatus;
     return department;
 }
Beispiel #22
0
        public bool UpdateRecord(Object dept)
        {
            Boolean flag = false;
            DepartmentClass department = (DepartmentClass)dept;
            try
            {
                Department _department = new Department();
                _department.DeptID = Convert.ToInt32(department.DepartmentID);
                if (department.DepartmentCode != null)
                {
                    _department.DeptCode = department.DepartmentCode.ToUpper();
                }

                if (department.DepartmentName != null)
                {
                    _department.DeptName = department.DepartmentName;
                }
                _department.Modifydate = DateTime.Now;
                _department.ModifyBy = department.ModifyBy;
                flag = DAL.DALDepartment.UpdateDepartment(_department);

            }
            catch (Exception ex)
            {
                throw;
            }
            return flag;
        }
 /// <summary>
 /// Create a new Department object.
 /// </summary>
 /// <param name="dept_ID">Initial value of the Dept_ID property.</param>
 public static Department CreateDepartment(global::System.String dept_ID)
 {
     Department department = new Department();
     department.Dept_ID = dept_ID;
     return department;
 }
 public EmloyeeAddDialog(DAL.Department department)
 {
     InitializeComponent();
     this.department = department;
 }
        public bool updateDepartment(Department d)
        {
            try
            {
                Department dept = getDepartmentByID(d.Representative_ID);

                dept.Dept_Name = d.Dept_Name == null ? dept.Dept_Name : d.Dept_Name;
                dept.Contact_ID = d.Contact_ID == null ? dept.Contact_ID : d.Contact_ID;
                dept.Contact_Name = d.Contact_Name == null ? dept.Contact_Name : d.Contact_Name;
                dept.Phone = d.Phone == null ? dept.Phone : d.Phone;
                dept.Fax_No = d.Fax_No == null ? dept.Fax_No : d.Fax_No;
                dept.Head_ID = d.Head_ID == null ? dept.Head_ID : d.Head_ID;
                dept.Head_Name = d.Head_Name == null ? dept.Head_Name : d.Head_Name;
                dept.Collection_Point = d.Collection_Point == null ? dept.Collection_Point : d.Collection_Point;
                dept.Representative_ID = d.Representative_ID == null ? dept.Representative_ID : d.Representative_ID;
                dept.Representative_Name = d.Representative_Name == null ? dept.Representative_Name : d.Representative_Name;

                ContextDB.SaveChanges();

                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
Beispiel #26
0
 private DepartmentModel ConvertFromDB(Department dbDepartment)
 {
     return new DepartmentModel
     {
         Id = dbDepartment.Id,
         DepartmentName = dbDepartment.DepartmentName,
         FolderId = dbDepartment.FolderId
     };
 }
Beispiel #27
0
 public void UpdateDepartment(DepartmentModel department)
 {
     using (geekinsidekmsEntities context =
        new geekinsidekmsEntities())
     {
         Department dbDepartment = new Department
         {
             Id = department.Id,
             DepartmentName = department.DepartmentName,
             FolderId = department.FolderId
         };
         context.Departments.AddObject(dbDepartment);
         context.ObjectStateManager.ChangeObjectState(dbDepartment, EntityState.Modified);
         context.SaveChanges();
     }
 }
 public void createDepartment(Department d)
 {
     ContextDB.Departments.AddObject(d);
     ContextDB.SaveChanges();
 }
Beispiel #29
0
        public static Department EditDepartment(Int32 DeptID)
        {
            Department department = new Department();
            try
            {
                using (var context = new SycousCon())
                {
                    department = context.Departments.Single(s => s.DeptID == DeptID && s.DeleteStatus==0);
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            return department;
        }
Beispiel #30
0
        public static Boolean UpdateDepartment(Department department)
        {
            Boolean bol = false;
            using (TransactionScope scope = new TransactionScope())
            {
                using (var context = new SycousCon())
                {
                    try
                    {
                        var departToUpdate = context.Departments.Where(c => c.DeptID == department.DeptID);
                        foreach (Department p in departToUpdate)
                        {
                            if (department.DeptName != null)
                            {
                                p.DeptName = department.DeptName.ToUpper().Trim();
                            }
                            if (department.DeptCode != null)
                            {
                                p.DeptCode = department.DeptCode.ToUpper().Trim();
                            }

                            p.ModifyBy = department.ModifyBy;
                            p.Modifydate = DateTime.Now;
                        }
                        context.SaveChanges();
                        context.AcceptAllChanges();
                        scope.Complete();
                        context.Dispose();
                        bol = true;
                    }
                    catch (Exception ex)
                    {
                        context.Dispose();
                        throw ex;
                    }
                }
            }
            return bol;
        }
 /// <summary>
 /// 用于向 Departments EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToDepartments(Department department)
 {
     base.AddObject("Departments", department);
 }
Beispiel #32
0
 public static Department ViewDepartmentRecord(Int32 deptID)
 {
     Department objDepartment = new Department();
     using (var context = new SycousCon())
     {
         try
         {
             objDepartment = context.Departments.SingleOrDefault(p => p.DeptID == deptID);
             if (objDepartment != null)
             { return objDepartment; }
             else
             {
                 objDepartment = null;
                 return objDepartment;
             }
         }
         catch (Exception ex)
         {
             context.Dispose();
             throw;
         }
     }
 }
 /// <summary>
 /// 创建新的 Department 对象。
 /// </summary>
 /// <param name="id">Id 属性的初始值。</param>
 /// <param name="departmentName">DepartmentName 属性的初始值。</param>
 /// <param name="folderId">FolderId 属性的初始值。</param>
 public static Department CreateDepartment(global::System.Int32 id, global::System.String departmentName, global::System.Int32 folderId)
 {
     Department department = new Department();
     department.Id = id;
     department.DepartmentName = departmentName;
     department.FolderId = folderId;
     return department;
 }