예제 #1
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            tabid.Value = "1";
            CheckBox cb;
            try
            {
                IList<string> teachercodelist = new List<string>();
                for (int i = 0; i < gvteachercourse.Rows.Count; i++)
                {
                    cb = (CheckBox)gvteachercourse.Rows[i].FindControl("chkSelect");
                    if (cb.Checked)
                    {
                        string teachername = gvteachercourse.DataKeys[i].Value.ToString().Trim();
                        string teachercode = gvteachercourse.Rows[i].Cells[2].Text;

                        bool isexit = false;
                        for (int k = 0; k < teachercodelist.Count; k++)
                        {
                            if (teachercodelist[k] == teachercode)
                            {
                                isexit = true;
                                break;
                            }
                        }
                        if (!isexit)
                        {
                            teachercodelist.Add(teachercode);
                            CY.GFive.Core.Business.Note note = new CY.GFive.Core.Business.Note();
                            CY.GFive.Core.Business.NoteRange noterange = new CY.GFive.Core.Business.NoteRange();

                            string content = "" + teachername + "老师:\n\r";
                            content += "  您好,您本学期的课表如下:\n\r";
                            content += "<table border=\"1\" align=\"center\"><tr><td>课程</td><td>上课时间</td><td>教室</td><td>班级</td></tr>";
                            CY.GFive.Core.Business.StaffInfo teacher = CY.GFive.Core.Business.StaffInfo.GetInstance(teachercode);
                            int teacherid = teacher.Id;
                            IList<CY.GFive.Core.Business.CurriculmArrange> curriculmArrangelist = CY.GFive.Core.Business.CurriculmArrange.GetCurriculmArrangeByTeacherCodeAndTime(teachercode, year.ToString(), term);
                            for (int j = 0; j < curriculmArrangelist.Count; j++)
                            {
                                teachercodelist.Add(curriculmArrangelist[j].TeacherCode);
                                CY.GFive.Core.Business.ClassRoom classroom = CY.GFive.Core.Business.ClassRoom.SelectByCode(curriculmArrangelist[j].ClassRoomCode);
                                string classroomaddress = classroom.Name;
                                CY.GFive.Core.Business.Course course = CY.GFive.Core.Business.Course.GetByCode(curriculmArrangelist[j].CourseCode);
                                string cousename = course.Name;
                                CY.GFive.Core.Business.ClassInfo classinfo = CY.GFive.Core.Business.ClassInfo.GetByCode(curriculmArrangelist[j].ClassCode);
                                string classcode = classinfo.ClassName;
                                int coursetime = curriculmArrangelist[j].CourseTime;
                                content += "<tr><td>" + cousename + "</td><td>" + creatcouseday(coursetime) + "</td><td>" + classroomaddress + "</td><td>" + classcode + "</td></tr>";
                                //content += "上课时间:" + creatcouseday(coursetime) + "" + creatcoursehour(coursetime) + "  地点:" + classroomaddress + "  课程:" + cousename + "  班级:" + classcode + "\n\r";
                            }
                            content += "</table>";
                            content += "请打印或者保存好本消息!";
                            note.NoteTitle = "本学期课表";
                            note.NoteContent = content;
                            note.NoteDate = System.DateTime.Now;
                            note.NoteTimes = 0;
                            note.Save();
                            noterange.NoteKey = note.Id;
                            noterange.ReciverKey = teacherid;
                            noterange.NoteState = 0;
                            noterange.Save();
                        }
                    }
                }

                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('发送成功!');window.location.href='NoticeTeacher.aspx';</script>");
            }
            catch (Exception ex)
            {
                //lbError.Text = ex.Message;
                //lbError.Visible = true;
            }
        }
예제 #2
0
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            errormsg.Text = "";
            try
            {
                CY.GFive.Core.Business.Note message = new CY.GFive.Core.Business.Note();
                CY.GFive.Core.Business.NoteRange usermessage;
                if (MessageTitle.Text.Trim() == "")
                {
                    errormsg.Text = "公告标题不能为空";
                    return;
                }
                if (string.IsNullOrEmpty(MessageContent.Value.Trim()) || MessageContent.Value.Trim().Length > 100000)
                {
                    errormsg.Text = "内容不可以为空,长度只能为1到100000";
                    return;
                }
                message.NoteTitle = MessageTitle.Text.Trim();
                message.NoteContent = Server.HtmlEncode(MessageContent.Value.Trim());
                message.NoteDate = System.DateTime.Now;
                CY.GFive.Core.Business.StaffInfo st = GetUser();
                if (st != null)
                {
                    message.PulisherKey = st.Id;
                    if (st.Moudle != null)
                        message.PulishModule = st.Moudle.Id;
                }
                if (ddl_IsPub.SelectedValue == "")
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "error", "<script>alert('是否为公告不能为空!')</script>");
                    return;
                }
                if (ddl_IsPub.SelectedValue == "1" || ddl_IsPub.SelectedValue == "2")
                {
                    if (ddl_IsFront.SelectedValue == "3")
                    {
                        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "error", "<script>alert('请选择是否在前台显示!')</script>");
                        return;
                    }
                }

                message.NoteType = int.Parse(ddl_IsPub.SelectedValue);

                if (ddl_IsFront.SelectedValue == "1")
                {
                    message.IsFront = true;
                }
                else
                {
                    message.IsFront = false;
                }

                message.Save();

                if (ddl_IsPub.SelectedValue.Equals("0"))
                {
                    if (tb_UserIDs.Text.Trim().Equals(""))
                    {
                        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "AddFailed!", "<script>alert('消息发送对象不能为空!');</script>");
                        return;
                    }
                    string[] userIdList = tb_UserIDs.Text.Split(',');

                    foreach (string item in userIdList)
                    {
                        usermessage = new CY.GFive.Core.Business.NoteRange();
                        usermessage.ReciverKey = int.Parse(item);
                        usermessage.NoteKey = message.Id;
                        usermessage.Save();
                    }
                }
                else if (ddl_IsPub.SelectedValue.Equals("2"))
                {
                    if (tb_DepartCodes.Text.Trim().Equals(""))
                    {
                        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "AddFailed!", "<script>alert('消息发送对象不能为空!');</script>");
                        return;
                    }
                    string[] dCodeList = tb_DepartCodes.Text.Split(',');

                    foreach (string item in dCodeList)
                    {
                        usermessage = new CY.GFive.Core.Business.NoteRange();
                        usermessage.ModuleKey = item;
                        usermessage.NoteKey = message.Id;
                        usermessage.Save();
                    }
                }
                else
                {
                    IList<CY.GFive.Core.Business.StaffInfo> userlist = CY.GFive.Core.Business.StaffInfo.GetAllStaffInfo();

                    foreach (CY.GFive.Core.Business.StaffInfo u in userlist)
                    {
                        usermessage = new CY.GFive.Core.Business.NoteRange();
                        usermessage.ReciverKey = u.Id;
                        usermessage.NoteKey = message.Id;
                        usermessage.Save();
                    }
                }

                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "短信息成功保存!", "<script>alert('保存成功!');</script>");
            }
            catch (Exception ex)
            {
                errormsg.Text = ex.Message;
            }
        }