Exemple #1
0
        public int update(string tablename,Object ObjMember)
        {
            int SuccessFlag;
            switch (tablename)
            {
                case "Logs_Data":
                    record = (EmailRecordInfo)ObjMember;
                    string dtLog = string.Format(@"UPDATE " + tablename + " SET  Email_Receiver='{0}', Teacher_Identity='{1}',Email_Theme='{2}',Time_Now='{3}',Email_Type='{4}', File_State'{5}',Enclosure_Path='{6}' WHERE Time_Now='{7}'"
                   ,record.Email_Receiver,record.Teacher_Identity,record.Email_Receiver,record.Time_Now,record.Email_Type,record.File_State,record.Enclosure_Path,record.Time_Now);
                    SuccessFlag = Oledbcommand(dtLog);
                    return SuccessFlag;

                case "SpareTime_Data":
                    supervisor = (SupervisorInfo)ObjMember;
                    string dtSpareTime = string.Format(@"insert into " + tablename + " values('{0}','{1}','{2}' ,{3},{4},{5},{6})", supervisor.SpareID,
                        supervisor.SupervisorId, supervisor.SupervisorName, supervisor.SpareWeek, supervisor.SpareDay, supervisor.SpareNumber, supervisor.Isassigned);

                    SuccessFlag = Oledbcommand(dtSpareTime);
                    return SuccessFlag;
                case "Teachers_Data":
                    teacher = (TeacherInfo)ObjMember;
                    string dtTeacher = string.Format(@"UPDATE "+tablename+" SET Teacher_ID ='{0}', Teacher ='{1}', Email ='{2}', Phone ='{3}', Title ='{4}', IsSupervisor ={5}, Teaching_Section ='{6}', Accept_ClassNumber ={7}, Class_Totality ={8}, Class_WeekNumber ={9}, Class_DayNumber ={10} WHERE  Teacher ='{11}'"
                        , teacher.TeacherId.ToString(), teacher.TeacherName.ToString(), teacher.Email.ToString(), teacher.Phone.ToString(), teacher.Title.ToString(), teacher.IsSupervisor, teacher.TeachingSection.ToString(),
                        teacher.AcceptClassNumber, teacher.ClassTotality, teacher.ClassWeekNumber, teacher.ClassDayNumber,teacher.TeacherName
                        );

                    SuccessFlag = Oledbcommand(dtTeacher);
                    return SuccessFlag;
                case "Placement_Data":
                    placement = (PlacementInfo)ObjMember;
                    string dtPlacement = string.Format(@"UPDATE " + tablename + " SET Class_ID='{0}',Teacher_ID='{1}',Teacher='{2}',Class_week={3},Class_Day={4},Class_Number={5},Supervisor_Name='{6}',Class_Address='{7}',Class_Content='{8}',Class_Name='{9}',Class_Type='{10}',Spcialty='{11}',Grade={12} WHERE  Class_ID='{13}'"
                   , placement.ClassId, placement.TeacherId, placement.TeacherName, placement.ClassWeek, placement.ClassDay, placement.ClassNumber, placement.SupervisorsName,
                   placement.ClassAddress, placement.ClassContent, placement.ClassName, placement.ClassType, placement.Spcialty, placement.Grade,placement.ClassId
                  );
                    SuccessFlag = Oledbcommand(dtPlacement);
                    return SuccessFlag;

            }
            return 0;
        }
Exemple #2
0
        private void buttonX4_Click(object sender, EventArgs e)
        {
            //if ( tBName.Text != "" && tBMail.Text != "" && tBTel.Text != "" && tbTitle.Text != "" && tbBelongs.Text != "")
            //{

                string EmailPattern = @"^([A-Za-z0-9]{1}[A-Za-z0-9_]*)@([A-Za-z0-9_]+)[.]([A-Za-z0-9_]*)$";//E-Mail地址格式的正则表达式
                if (tBMail.Text == "" || Regex.IsMatch(tBMail.Text.Trim(), EmailPattern))
                {
                    if (status == 1)
                    {

                        TeacherInfo teacher = new TeacherInfo();
                        teacher.TeacherId = tBID.Text;
                        teacher.TeacherName = tBName.Text;
                        teacher.Email = tBMail.Text;
                        teacher.Phone = tBTel.Text;
                        teacher.Title = tbTitle.Text;
                        teacher.IsSupervisor = cbIsDUDao.Checked;
                        teacher.TeachingSection = tbBelongs.Text;

                        SqlHelper help = new SqlHelper();
                        if (help.update("Teachers_Data", teacher) > 0)
                        {
                            MessageBox.Show("修改成功");
                            listView1.Items.Clear();
                            DataTable dt = pageshow.ListviewShow("select * from Teachers_Data", currentpage, pagesize, "Teachers_Data");
                            UIShow show = new UIShow();
                            show.teachers_listview_write(dt, listView1);
                        }

                    }
                    if (status == 0)
                    {

                        TeacherInfo teacher = new TeacherInfo();
                        teacher.TeacherId = tBID.Text;
                        teacher.TeacherName = tBName.Text;
                        teacher.Email = tBMail.Text;
                        teacher.Phone = tBTel.Text;
                        teacher.Title = tbTitle.Text;
                        teacher.IsSupervisor = cbIsDUDao.Checked;
                        teacher.TeachingSection = tbBelongs.Text;
                        SqlHelper help = new SqlHelper();
                        if (help.Insert(teacher, "Teachers_Data") > 0)
                        {
                            MessageBox.Show("添加成功");
                        }
                        else
                        {
                            MessageBox.Show("操作失败");
                        }
                        clear_listview();
                        totalpage = pageshow.totalpage("select * from Teachers_Data", pagesize, "Teachers_Data");
                        labPageAll.Text = totalpage + "";
                        textBoxNow.Text = currentpage.ToString();
                        DataTable dt = pageshow.ListviewShow("select * from Teachers_Data", currentpage, pagesize, "Teachers_Data");
                        UIShow show = new UIShow();
                        show.teachers_listview_write(dt, listView1);
                    }

                    this.btnsave.Enabled = false;
                }
                else
                {
                    MessageBox.Show("请输入正确的邮箱地址");
                }

               // }

            //else
            //{
            //    MessageBox.Show("请确保数据完整");
            //}
        }
Exemple #3
0
        public int Insert(Object ObjMember,string Flag)
        {
            int SuccessFlag;
            switch (Flag)
            {
                case "Classes_Data":
                    classes = (ClassInfo)ObjMember;
                    string dtClass = string.Format(@"insert into " + Flag +  " values('{0}','{1}','{2}' ,{3},{4},{5},'{6}','{7}','{8}','{9}','{10}')"
                    ,classes.ClassId,classes.TeacherId,classes.TeacherName,classes.ClassWeek,classes.ClassDay,classes.ClassNumber,classes.ClassName,
                    classes.ClassContent,classes.ClassType,classes.Spcialty);
                    SuccessFlag=Oledbcommand(dtClass);
                    return SuccessFlag;

                case "SpareTime_Data":
                    supervisor = (SupervisorInfo)ObjMember;
                    string dtSpareTime = string.Format(@"insert into " + Flag + " values('{0}','{1}','{2}',{3},{4},{5},{6})",supervisor.SpareID,
                        supervisor.SupervisorId,supervisor.SupervisorName,supervisor.SpareWeek,supervisor.SpareDay,supervisor.SpareNumber,supervisor.Isassigned);

                    SuccessFlag = Oledbcommand(dtSpareTime);
                    return SuccessFlag;
                case "Teachers_Data":
                    teacher = (TeacherInfo)ObjMember;
                    string dtTeacher = string.Format(@"insert into " + Flag + " values('{0}','{1}','{2}' ,'{3}','{4}',{5},'{6}',{7},{8},{9},{10})"
                        ,teacher.TeacherId.ToString(),teacher.TeacherName.ToString(),teacher.Email.ToString(),teacher.Phone.ToString(),teacher.Title.ToString(),teacher.IsSupervisor,teacher.TeachingSection.ToString(),
                        teacher.AcceptClassNumber,teacher.ClassTotality,teacher.ClassWeekNumber,teacher.ClassDayNumber
                        );

                    SuccessFlag = Oledbcommand(dtTeacher);
                    return SuccessFlag;
                case "Placement_Data":
                    placement = (PlacementInfo)ObjMember;
                    string dtPlacement = string.Format(@"insert into " + Flag + " values('{0}','{1}','{2}',{3},{4},'{5}','{6}','{7}','{8}','{9}','{10}','{11}',{12})"
                   ,placement.ClassId,placement.TeacherId,placement.TeacherName,placement.ClassWeek,placement.ClassDay,placement.ClassNumber,placement.SupervisorsName,
                   placement.ClassAddress,placement.ClassContent,placement.ClassName,placement.ClassType,placement.Spcialty,placement.Grade
                  );
                    SuccessFlag = Oledbcommand(dtPlacement);
                    return SuccessFlag;
                case "Logs_Data":
                    record = (EmailRecordInfo)ObjMember;
                    string dtLog = string.Format(@"insert into "+Flag+" values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')",record.Email_Receiver,record.Teacher_Identity,record.Email_Theme
                        ,record.Time_Now,record.Email_Type,record.File_State,record.Enclosure_Path);
                    SuccessFlag = Oledbcommand(dtLog);
                    return SuccessFlag;

            }
            return 0;
        }