Exemplo n.º 1
0
        private void LoadDataByID(int iGpD)
        {
            Group    oGp    = new Group(iGpD);
            GroupDAL oGpDAL = new GroupDAL();

            Result oResult = new Result();

            oResult = oGpDAL.LoadByID(oGp);
            ClearTextValue();
            if (oResult.Status)
            {
                oGp = (Group)oResult.Return;
                if (oGp != null)
                {
                    SetObject(oGp);
                }
                else
                {
                    ucMessage.OpenMessage(Constants.MSG_ERROR_NOT_FOUND, Constants.MSG_TYPE_INFO);
                    ScriptManager.RegisterStartupScript(this.UpdatePanel2, typeof(string), Constants.POPUP_WINDOW, Util.OpenPopup("info"), true);
                }
            }
            else
            {
                ucMessage.OpenMessage(Constants.MSG_ERROR_NOT_FOUND, Constants.MSG_TYPE_ERROR);
                ScriptManager.RegisterStartupScript(this.UpdatePanel2, typeof(string), Constants.POPUP_WINDOW, Util.OpenPopup("Delete"), true);
            }
        }
Exemplo n.º 2
0
        // ok
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(hdGpID.Value))
            {
                GroupDAL oGpDAL  = new GroupDAL();
                Result   oResult = (Result)oGpDAL.Detete(hdGpID.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);
            }
        }
Exemplo n.º 3
0
        private void dataGridViewGroups_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataTable dtGroupStudents = GroupDAL.GetGroupStudents(
                (int)dataGridViewGroups.Rows[dataGridViewGroups.SelectedCells[0].RowIndex].Cells["Group ID"].Value);

            this.dataGridViewGroupStudents.DataSource = dtGroupStudents;
        }
Exemplo n.º 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Group    oGp    = new Group();
            GroupDAL oGpDAL = new GroupDAL();

            oGp.GroupID                 = Util.GetIntNumber(Request[txtGroupID.UniqueID].Trim());
            oGp.GroupName               = txtGroupName.Text;
            oGp.Description             = txtDescription.Text;
            oGp.Department.DepartmentID = Util.GetIntNumber(ddlDepartmentID.SelectedValue);
            oGp.ScreenList              = GetScreenList();

            oGp.UserDetails           = ucUserDet.UserDetail;
            oGp.UserDetails.CheckDate = DateTime.Now;
            oGp.UserDetails.CheckerID = oGp.UserDetails.MakerID;

            Result oResult = (Result)oGpDAL.Save(oGp);

            if (oResult.Status)
            {
                ClearTextValue();
                //LoadList();
                ucMessage.OpenMessage(Constants.MSG_SUCCESS_SAVE, Constants.MSG_TYPE_SUCCESS);
            }
            else
            {
                ucMessage.OpenMessage(Constants.MSG_ERROR_SAVE, Constants.MSG_TYPE_ERROR);
            }
        }
        public static List <Group> GetStubNumber(NameValueCollection querystring)
        {
            string criteria = querystring.Get("Criteria");
            int    branchID = int.TryParse(querystring.Get("BranchID"), out branchID) ? branchID : 0;

            return(GroupDAL.GetGroup(criteria, branchID));
        }
Exemplo n.º 6
0
        public static IEnumerable <GroupInfo> GetGroupsToDisplay(String id)
        {
            var grpList = GroupDAL.GetGroups();
            var groups  = new List <GroupInfo>();
            var joined  = false;

            foreach (var g in grpList)
            {
                foreach (var userG in g.UserGroups)
                {
                    if (userG.UserId.Equals(id))
                    {
                        joined = true;
                        break;
                    }
                }
                var tmp = new GroupInfo();
                tmp.Name   = g.Name;
                tmp.Id     = g.Id;
                tmp.Joined = joined;

                groups.Add(tmp);
                joined = false;
            }

            return(groups);
        }
Exemplo n.º 7
0
        private void MoveAction(string sType)
        {
            GroupDAL oGpDAL  = new GroupDAL();
            Result   oResult = oGpDAL.LoadMoveData(txtGroupName.Text, sType);

            ClearTextValue();
            if (oResult.Status)
            {
                Group oGp = (Group)oResult.Return;
                if (oGp != null)
                {
                    SetObject(oGp);
                    hdGpID.Value = oGp.GroupID.ToString();
                }
                else
                {
                    ucMessage.OpenMessage("Group Name does not exist", Constants.MSG_TYPE_INFO);
                    ScriptManager.RegisterStartupScript(this.UpdatePanel2, typeof(string), Constants.POPUP_WINDOW, Util.OpenPopup("Info"), true);
                }
            }
            else
            {
                ucMessage.OpenMessage("Group Name does not exist", Constants.MSG_TYPE_INFO);
                ScriptManager.RegisterStartupScript(this.UpdatePanel2, typeof(string), Constants.POPUP_WINDOW, Util.OpenPopup("Info"), true);
            }
        }
Exemplo n.º 8
0
        private void TeacherStudyGroups_Load(object sender, EventArgs e)
        {
            DataTable dtGroups = TeacherDAL.GetTeacherGroups(TeacherID);//TeacherDAL.GetTeacherStudents(TeacherID);

            this.dataGridViewGroups.DataSource = dtGroups;

            foreach (DataGridViewColumn dc in dataGridViewGroups.Columns)
            {
                if (dc.Name != "Description")
                {
                    dc.ReadOnly = true;
                }
            }

            this.dataGridViewGroups.Update();

            //bind binging navigator to data grid
            var bs = new BindingSource();

            bs.DataSource = dtGroups.DefaultView;
            bindingNavigator1.BindingSource = bs;
            dataGridViewGroups.DataSource   = bs;


            DataTable dtGroupStudents = GroupDAL.GetGroupStudents((int)dataGridViewGroups.Rows[dataGridViewGroups.SelectedCells[0].RowIndex].Cells["Group ID"].Value);

            this.dataGridViewGroupStudents.DataSource = dtGroupStudents;

            toolStripTeacherID.Text = "Teacher ID: " + TeacherID.ToString();
        }
Exemplo n.º 9
0
        public static void UpdateGroup(GroupInfo groupInfo)
        {
            var grp = GetGroup(groupInfo);

            grp.Name = groupInfo.Name;
            GroupDAL.UpdateGroup(grp);
        }
Exemplo n.º 10
0
        private void btnRemoveStudentFromGroup_Click(object sender, EventArgs e)
        {
            try
            {
                if (studentsDataGridView.CurrentRow.IsNewRow)
                {
                    throw new ArgumentOutOfRangeException("You cannot delete non-existant group student from this group!");
                }
                int rowIndex  = studentsDataGridView.SelectedCells[0].RowIndex;
                int studentID = int.Parse(studentsDataGridView["Student_ID", rowIndex].EditedFormattedValue.ToString());
                int groupID   = int.Parse(studentsDataGridView["Group_ID", rowIndex].EditedFormattedValue.ToString());

                if (MessageBox.Show(string.Format("Do you really want to delete student {0} {1} from group #{2}?",
                                                  studentsDataGridView["Last_name", rowIndex].EditedFormattedValue.ToString(),
                                                  studentsDataGridView["First_name", rowIndex].EditedFormattedValue.ToString(),
                                                  groupID), "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2)
                    == System.Windows.Forms.DialogResult.Yes)
                {
                    GroupDAL.RemoveStudentFromGroup(groupID, studentID);
                    studentsDataGridView.Rows.RemoveAt(rowIndex);

                    MessageBox.Show("Student successfully removed from the group!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Maybe, you haven't selected a student?", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public List <Group> GetGroupListByUserId(int userid)
        {
            List <Group> list = new List <Group>();
            GroupDAL     dal  = new GroupDAL();

            list = dal.GetGroupsByUserid(userid);
            return(list);
        }
        public List <Group> GetGroupList()
        {
            List <Group> list = new List <Group>();
            GroupDAL     dal  = new GroupDAL();

            list = dal.GetAllGroup();
            return(list);
        }
Exemplo n.º 13
0
        public ActionResult Create()
        {
            UserCreateViewModel model    = new UserCreateViewModel();
            GroupDAL            groupDAL = new GroupDAL();

            model.DdlGroupID = groupDAL.DdlGroup();
            return(View("Create", model));
        }
Exemplo n.º 14
0
        public static Group CreateGroup(string name, DateTime startDate, DateTime endDate, int tourId)
        {
            ValidateGroup(name, startDate, endDate);
            var group = new Group(name, startDate, endDate, tourId);

            GroupDAL.Add(group);
            return(group);
        }
Exemplo n.º 15
0
        public static GroupInfo GetGroup(int groupId)
        {
            var group     = GroupDAL.GetGroup(groupId);
            var groupInfo = new GroupInfo();

            groupInfo.Id   = group.Id;
            groupInfo.Name = group.Name;
            return(groupInfo);
        }
Exemplo n.º 16
0
        public static Group EditGroup(int id, string name, DateTime startDate, DateTime endDate, int tourId)
        {
            ValidateGroup(name, startDate, endDate);
            var group = new Group(name, startDate, endDate, tourId)
            {
                Id = id
            };

            GroupDAL.Update(group);
            return(group);
        }
Exemplo n.º 17
0
 private void dataGridViewGroups_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         //at the momment we can only edit "Description" column
         GroupDAL.UpdateGroup((int)dataGridViewGroups.Rows[dataGridViewGroups.SelectedCells[0].RowIndex].Cells["Group ID"].Value,
                              dataGridViewGroups.Rows[dataGridViewGroups.SelectedCells[0].RowIndex].Cells["Description"].Value.ToString());
         MessageBox.Show("Changes successfully saved!");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 18
0
        public static void AddGroup(GroupInfo groupInfo)
        {
            var groups = GetGroups();

            foreach (var g in groups)
            {
                if (g.Name.Equals(groupInfo.Name))
                {
                    return;
                }
            }
            var group = new Group();

            group.Name = groupInfo.Name;
            GroupDAL.AddGroupToDB(group);
        }
Exemplo n.º 19
0
        public static IEnumerable <GroupInfo> GetGroups()
        {
            var grpList = GroupDAL.GetGroups();

            var groups = new List <GroupInfo>();

            foreach (var g in grpList)
            {
                var tmp = new GroupInfo();
                tmp.Name = g.Name;
                tmp.Id   = g.Id;

                groups.Add(tmp);
            }
            return(groups);
        }
Exemplo n.º 20
0
 // To pass 'Group' data in GroupDAL Data Access Layer to show Active and Inactive type records
 public DataTable LoadActiveGroup(bool IsActive,int LoggedInUser, string returnmsg)
 {
     GroupDAL GroupDAL = new GroupDAL();
     try
     {
         return GroupDAL.LoadActiveGroup(IsActive, LoggedInUser, returnmsg);
     }
     catch
     {
         throw;
     }
     finally
     {
         GroupDAL = null;
     }
 }
Exemplo n.º 21
0
 //  To pass 'Group' data in GroupDAL Data Access Layer for insertion
 public int InsertGroup(string GroupName ,string GroupDescription,bool Isactive,int LoginUser, string Ret)
 {
     GroupDAL GroupDAL = new GroupDAL();
     try
     {
         return GroupDAL.InsertGroup(GroupName,GroupDescription, Isactive, LoginUser,Ret);
     }
     catch
     {
         throw;
     }
     finally
     {
         GroupDAL = null;
     }
 }
Exemplo n.º 22
0
 // To pass 'Group' data in GroupDAL Data Access Layer to show Change Status of selected GroupId record
 public int ChangeGroupStatus(int GroupId, int LoggedInUser, string returnmsg, bool IsActive)
 {
     GroupDAL GroupDAL = new GroupDAL();
     try
     {
         return GroupDAL.ChangeGroupStatus(GroupId, LoggedInUser, returnmsg, IsActive);
     }
     catch
     {
         throw;
     }
     finally
     {
         GroupDAL = null;
     }
 }
Exemplo n.º 23
0
 // To pass 'Group' data in GroupDAL Data Access Layer to show Active type records
 public DataTable LoadAllGroup(int LoggedInUser,string returnmsg)
 {
     GroupDAL GroupDAL = new GroupDAL();
     try
     {
         return GroupDAL.LoadAllGroup(LoggedInUser, returnmsg);
     }
     catch
     {
         throw;
     }
     finally
     {
         GroupDAL = null;
     }
 }
Exemplo n.º 24
0
    // To pass 'Group' data in GroupDAL Data Access Layer to show Active and Inactive type records
    public DataTable LoadActiveGroup(bool IsActive, int LoggedInUser, string returnmsg)
    {
        GroupDAL GroupDAL = new GroupDAL();

        try
        {
            return(GroupDAL.LoadActiveGroup(IsActive, LoggedInUser, returnmsg));
        }
        catch
        {
            throw;
        }
        finally
        {
            GroupDAL = null;
        }
    }
Exemplo n.º 25
0
    // To pass 'Group' data in GroupDAL Data Access Layer to show selected GroupId record
    public DataTable SelectGroupID(int GroupId, int LoggedInUser, string returnmsg)
    {
        GroupDAL GroupDAL = new GroupDAL();

        try
        {
            return(GroupDAL.SelectGroupID(GroupId, LoggedInUser, returnmsg));
        }
        catch
        {
            throw;
        }
        finally
        {
            GroupDAL = null;
        }
    }
Exemplo n.º 26
0
    // To pass 'Group' data in GroupDAL Data Access Layer for updation
    public int UpdateGroup(int GroupId, string GroupDescription, bool IsActive, string GroupName, int LoginUser, string Ret)
    {
        GroupDAL GroupDAL = new GroupDAL();

        try
        {
            return(GroupDAL.UpdateGroup(GroupId, GroupDescription, IsActive, GroupName, LoginUser, Ret));
        }
        catch
        {
            throw;
        }
        finally
        {
            GroupDAL = null;
        }
    }
Exemplo n.º 27
0
    // To pass 'Group' data in GroupDAL Data Access Layer to show Active type records
    public DataTable LoadAllGroup(int LoggedInUser, string returnmsg)
    {
        GroupDAL GroupDAL = new GroupDAL();

        try
        {
            return(GroupDAL.LoadAllGroup(LoggedInUser, returnmsg));
        }
        catch
        {
            throw;
        }
        finally
        {
            GroupDAL = null;
        }
    }
Exemplo n.º 28
0
    // To pass 'Group' data in GroupDAL Data Access Layer to show Change Status of selected GroupId record
    public int ChangeGroupStatus(int GroupId, int LoggedInUser, string returnmsg, bool IsActive)
    {
        GroupDAL GroupDAL = new GroupDAL();

        try
        {
            return(GroupDAL.ChangeGroupStatus(GroupId, LoggedInUser, returnmsg, IsActive));
        }
        catch
        {
            throw;
        }
        finally
        {
            GroupDAL = null;
        }
    }
Exemplo n.º 29
0
    //  To pass 'Group' data in GroupDAL Data Access Layer for insertion
    public int InsertGroup(string GroupName, string GroupDescription, bool Isactive, int LoginUser, string Ret)
    {
        GroupDAL GroupDAL = new GroupDAL();

        try
        {
            return(GroupDAL.InsertGroup(GroupName, GroupDescription, Isactive, LoginUser, Ret));
        }
        catch
        {
            throw;
        }
        finally
        {
            GroupDAL = null;
        }
    }
Exemplo n.º 30
0
        private void btnAddStudentToGroup_Click(object sender, EventArgs e)
        {
            try
            {
                if (GroupsDataGridView.CurrentRow.IsNewRow)
                {
                    throw new Exception("You cannot add students to non-existant group!");
                }
                int rowIndex = GroupsDataGridView.SelectedCells[0].RowIndex;
                AddStudentToGroupDialog dialog = new AddStudentToGroupDialog(GroupsDataGridView["Grade", rowIndex].EditedFormattedValue.ToString());
                //dialog.Owner = this;
                dialog.FormClosed += (o, s) =>
                {
                    if (dialog.StudentID != 0)
                    {
                        //studentsDataGridView.Rows.Add(dialog.GradeSection, dialog.LastName, dialog.FirstName, dialog.StudentID);
                        //add new student
                        try
                        {
                            GroupDAL.AddStudentToGroup(
                                int.Parse(GroupsDataGridView["GroupID", rowIndex].Value.ToString()),
                                dialog.StudentID);

                            this.getGroupStudentsTableAdapter.Fill(this.schooljournalDataSet.getGroupStudents, int.Parse(GroupsDataGridView["GroupID", rowIndex].Value.ToString()));
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        finally
                        {
                        }
                    }
                };
                dialog.ShowDialog();
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                if (ex.InnerException != null)
                {
                    msg += "\n" + ex.InnerException.Message;
                }
                MessageBox.Show(msg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public static string ManageGroup(NameValueCollection querystring)
        {
            int intParser;

            UserProfile userProfile = WebCommon.GetUserProfile();

            var group = new Group
            {
                GroupID     = int.TryParse(querystring.Get("GroupID"), out intParser) ? intParser : 0,
                Description = querystring.Get("Description"),
                UserID      = userProfile.UserId
            };

            string isInsert = querystring.Get("TransType");
            string param    = WebCommon.ToXML(group);

            return(GroupDAL.ManageGroup(param, isInsert));
        }
Exemplo n.º 32
0
        private void saveGroups()
        {
            SchoolJournalEntities context = new SchoolJournalEntities();
            var groupIDs = from g in context.Groups select g.GroupID;

            try
            {
                foreach (DataGridViewRow r in GroupsDataGridView.Rows)
                {
                    if (r.IsNewRow)
                    {
                        continue;
                    }
                    int groupID = int.Parse(GroupsDataGridView["GroupID", r.Index].Value.ToString());
                    if (groupIDs.Contains(groupID)) //update
                    {
                        GroupDAL.UpdateGroup(groupID,
                                             int.Parse(GroupsDataGridView["TeacherID", r.Index].Value.ToString()),
                                             GroupsDataGridView["Subject", r.Index].EditedFormattedValue.ToString(),
                                             GroupsDataGridView["Grade", r.Index].EditedFormattedValue.ToString(),
                                             GroupsDataGridView["Description", r.Index].Value.ToString());
                    }
                    else //add new
                    {
                        GroupsDataGridView["GroupID", r.Index].Value =
                            GroupDAL.NewGroup(int.Parse(GroupsDataGridView["TeacherID", r.Index].Value.ToString()),
                                              GroupsDataGridView["Subject", r.Index].EditedFormattedValue.ToString(),
                                              GroupsDataGridView["Grade", r.Index].EditedFormattedValue.ToString(),
                                              GroupsDataGridView["Description", r.Index].Value.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 33
0
        public ActionResult Index(string token = "")
        {
            if (!string.IsNullOrEmpty(token))
            {
                if (token == MTConfig.AdminToken)
                {
                    MTConfig.CurrentUser = UserModel.FirstOrDefault("where Id = 1 ");
                }
            }

            if (MTConfig.CurrentUser == null)
            {
                return(RedirectToAction("Login"));
            }

            //List<NoticeModel> notmodels =
            //    NoticeModel.Fetch("select top 10 * from Notice where userid = @0 and ConfirmTime  is NULL",
            //        MTConfig.CurrentUserID);
            //foreach (var item in notmodels)
            //{
            //    item.SendDate = DateTimeHelper.showTime(item.SendTime);
            //}
            //ViewBag.notmodels = notmodels;
            //int notcount =
            //         NoticeModel.repo.ExecuteScalar<int>(
            //             "select count(*)  from Notice where userid = @0 and ConfirmTime  is NULL", MTConfig.CurrentUserID);
            //ViewBag.notcount = notcount;
            #region 刷新当前用户权限信息
            IndexViewModel model = new IndexViewModel();
            MTConfig.AuthInfo = NodeDAL.GetAccessNodeList(MTConfig.CurrentUserID);

            model.NodeList       = MTConfig.AuthInfo;
            MTConfig.CurrentRole = RoleDAL.GetAllRoleByUserID(MTConfig.CurrentUserID);
            MTConfig.CurrentUser = UserModel.FirstOrDefault("where Id = @0", MTConfig.CurrentUserID);
            model.UserInfo       = MTConfig.CurrentUser;
            model.GroupList      = GroupDAL.GetAllGroup();

            #endregion
            return(View(model));
        }
Exemplo n.º 34
0
        public ActionResult Create(UserCreateViewModel userCreateViewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    GroupDAL groupDAL = new GroupDAL();
                    userCreateViewModel.DdlGroupID = groupDAL.DdlGroup();
                    return(View(userCreateViewModel));
                }

                userDAL.CreateUser(userCreateViewModel);
                return(RedirectToAction("Index", "Users", new { area = "Admin" }));
            }
            catch (Exception ex)
            {
                GroupDAL groupDAL = new GroupDAL();
                userCreateViewModel.DdlGroupID = groupDAL.DdlGroup();
                ModelState.AddModelError("", ex.Message);
                return(View());
            }
        }
Exemplo n.º 35
0
 // To pass 'Group' data in GroupDAL Data Access Layer for updation
 public int UpdateGroup(int GroupId,string GroupDescription, bool IsActive, string GroupName, int LoginUser, string Ret)
 {
     GroupDAL GroupDAL = new GroupDAL();
     try
     {
         return GroupDAL.UpdateGroup(GroupId, GroupDescription,IsActive, GroupName, LoginUser, Ret);
     }
     catch
     {
         throw;
     }
     finally
     {
         GroupDAL = null;
     }
 }
Exemplo n.º 36
0
 // To pass 'Group' data in GroupDAL Data Access Layer to show selected GroupId record
 public DataTable SelectGroupID(int GroupId,int LoggedInUser, string returnmsg)
 {
     GroupDAL GroupDAL = new GroupDAL();
     try
     {
         return GroupDAL.SelectGroupID(GroupId, LoggedInUser, returnmsg);
     }
     catch
     {
         throw;
     }
     finally
     {
         GroupDAL = null;
     }
 }