Esempio n. 1
0
        void accept(List <Object> selectItemsID)
        {
            DatabaseDAO dao = new DatabaseDAO();

            objMyContest = new BUS.BUS_MyContest(dao);
            BUS.BUS_Notification   objNoti   = new BUS.BUS_Notification(dao);
            BUS.BUS_MyNotification objMyNoti = new BUS.BUS_MyNotification(dao);
            try
            {
                long acceptBy = CGlobal.GetUserID();

                if (selectItemsID.Count <= 0)
                {
                    HELPER.Client.Alert(this, "Bạn chưa chọn đơn nào!");
                }
                else
                {
                    dao.BeginTransaction();
                    long idNoti = objNoti.Insert(acceptBy, "Đã phê duyệt đơn xin vào khóa học của bạn", 3);
                    foreach (object selectItemId in selectItemsID)
                    {
                        string[] re          = selectItemId.ToString().Split('|');
                        long     idMyContest = long.Parse(re[0]);
                        long     userId      = long.Parse(re[1]);
                        objMyContest.UpdateAcepted(idMyContest, acceptBy);
                        objMyNoti.Insert(idNoti, userId);
                    }
                    dao.EndTransaction();

                    Response.Redirect(Request.RawUrl, false);
                }
            }
            catch (Exception ex)
            {
                dao.RollBack();
                HELPER.Client.Alert(this, "Lỗi cập nhật CSDL! " + ex.Message);
            }
        }
Esempio n. 2
0
        void clickMulti(int clickType)
        {
            List <Object> selectItemsID = new List <object>();

            selectItemsID = grvData.GetSelectedFieldValues(grvData.KeyFieldName);
            DatabaseDAO dao = new DatabaseDAO();

            objUser = new BUS.BUS_Users(dao);
            BUS.BUS_Notification   objNoti   = new BUS.BUS_Notification(dao);
            BUS.BUS_MyNotification objMyNoti = new BUS.BUS_MyNotification(dao);
            try
            {
                long acceptBy = CGlobal.GetUserID();

                if (selectItemsID.Count <= 0)
                {
                    HELPER.Client.Alert(this, "Bạn chưa chọn người dùng nào!");
                }
                else
                {
                    long idNoti = 0;
                    switch (clickType)
                    {
                    case 1:     // del , xóa
                        break;

                    case 2:     // accept, kích hoạt
                        idNoti = objNoti.Insert(acceptBy, "Đã kích hoạt tài khoản của bạn", 3);
                        break;

                    case 3:     // un accept, bỏ kích hoạt
                        break;

                    case 4:     // to Usertype 1, sinh viên
                        idNoti = objNoti.Insert(acceptBy, "Đã chuyển tài khoản của bạn thành tài khoản Sinh Viên", 3);
                        break;

                    case 5:     // to Usertype 2. Giáo viên
                        idNoti = objNoti.Insert(acceptBy, "Đã chuyển tài khoản của bạn thành tài khoản Giáo Viên", 3);
                        break;

                    default:
                        break;
                    }

                    foreach (object selectItemId in selectItemsID)
                    {
                        long userId = long.Parse(selectItemId.ToString());

                        switch (clickType)
                        {
                        case 1:     // del , xóa
                            objUser.Delete(userId);

                            break;

                        case 2:     // accept, kích hoạt
                            objUser.UpdateByAdminEnable(userId, 1);
                            objMyNoti.Insert(idNoti, userId);
                            break;

                        case 3:     // un accept, bỏ kích hoạt
                            objUser.UpdateByAdminEnable(userId, 0);
                            break;

                        case 4:     // to Usertype 1, sinh viên
                            objUser.UpdateByAdminType(userId, 1);
                            objMyNoti.Insert(idNoti, userId);
                            break;

                        case 5:     // to Usertype 2. Giáo viên
                            objUser.UpdateByAdminType(userId, 2);
                            objMyNoti.Insert(idNoti, userId);
                            break;

                        default:
                            break;
                        }
                    }

                    Response.Redirect(Request.RawUrl, false);
                }
            }
            catch (Exception ex)
            {
                HELPER.Client.Alert(this, "Lỗi cập nhật CSDL! " + ex.Message);
            }
        }
Esempio n. 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DatabaseDAO dao = new DatabaseDAO();

            objNoti = new BUS.BUS_Notification(dao);
            BUS.BUS_MyNotification objMyNoti = new BUS.BUS_MyNotification(dao);
            try
            {
                dao.BeginTransaction();
                HELPER.CWebPage.BindProperty(objNoti, pnEdit);
                objNoti.NotiType = int.Parse(cboNotiType.Value.ToString());
                FMode            = getMode();

                long NotiID = 0;
                if (FMode == CGlobal.FunctionMode.AddMode)
                {
                    NotiID = objNoti.Insert();
                    setHdf(hdfID, NotiID);
                    objMyNoti.NotificationID = NotiID;
                    switch (objNoti.NotiType)
                    {
                    case 1:    //khoa hoc
                        foreach (ListEditItem item in cblContestID.Items)
                        {
                            if (item.Selected)
                            {
                                objMyNoti.ContestID = long.Parse(item.Value.ToString());
                                objMyNoti.Insert();
                            }
                        }
                        break;

                    case 2:    //bt
                        foreach (ListEditItem item in cblProblemID.Items)
                        {
                            if (item.Selected)
                            {
                                objMyNoti.ProblemID = long.Parse(item.Value.ToString());
                                objMyNoti.Insert();
                            }
                        }
                        break;

                    case 3:     // user
                        foreach (ListEditItem item in cblUserID.Items)
                        {
                            if (item.Selected)
                            {
                                objMyNoti.UserID = long.Parse(item.Value.ToString());
                                objMyNoti.Insert();
                            }
                        }
                        break;

                    default:
                        throw new Exception("Chọn loại thông báo!");
                        break;
                    }
                }


                dao.EndTransaction();

                setMode(CGlobal.FunctionMode.SearchMode);
                initFuncMode();
            }
            catch (Exception ex)
            {
                dao.RollBack();
                HELPER.CError.ErrorType err = HELPER.CError.Parse(ex.Message);
                if (err == CError.ErrorType.Duplicate)
                {
                    HELPER.Client.Alert(this, "Dữ liệu đã tồn tại!");
                }
                else
                {
                    HELPER.Client.Alert(this, "Lỗi cấp nhật CSDL!" + err.ToString());
                }
            }
        }