예제 #1
0
        public void viewIterm(object sender, RoutedEventArgs e)
        {
            int id = 0;
            try
            {

                string a = ((Button)sender).Tag.ToString();
                id = Int16.Parse(a);
            }
            catch (Exception view_e)
            {
                Message ms = new Message("错误提示", "传入参数错误!。");
                ms.ShowDialog();
                return;
            }

            Schedule schedule = this.db.getScheduleById(id);


            ////
            this.vScheduleNumber.Content = schedule.ORDERNUMBER;
         
            this.vUserName.Content = schedule.userName;
            this.vUserNumber.Content = schedule.USER_ID;

            this.vTime.Content = schedule.ADDTIME;
            //this.v_id.Content = schedule._id + "";
            this.vCourseNumber.Content = schedule.COURSE_ID;
            this.vCourseNam.Content = schedule.courseName;

            this.v_time.Content = schedule.time;
            this.show_view();
            //this.view_edit.Tag = id;

        }
예제 #2
0
        private void Edit_Save_Click(object sender, RoutedEventArgs e)
        {
            //Teacher Teacher = this.db.getTeacherById(id);

            Teacher teacher = this.db.getTeacherById(Int16.Parse(this.e_id.Text));
            int age;
            try
            {
                age = Int16.Parse(this.eAge.Text);

            }
            catch (Exception age_e)
            {
                Message ms = new Message("错误提示", "数据类型不符!年龄必须为数字。");
                ms.ShowDialog();
                return;
            }

            teacher.TEACHERNUMBER = this.eTeacherNumber.Content.ToString();
            teacher.DIRECTION = this.eDirection.Text;
            teacher.NAME = this.eName.Text;
            teacher.AGE = age;

            teacher.SEX = this.eSex_nan.IsChecked == true ? "男" : "女";//this.aSex.Text;
            teacher.PHONE = this.ePhone.Text;
            teacher.EMAIL = this.eEmail.Text;
            teacher.POSITION = this.ePosition.Text;
            teacher.REMARK = this.eRemark.Text;

            byte[] photo = Utils.Utils.BitmapImageToByteArray((BitmapImage)(this.ePhoto.Source));
            teacher.PHOTO = photo == null || photo.Length == 0 ? teacher.PHOTO : photo;

            teacher.DETAILS = this.eDetails.Text;
            try
            {

                int res = this.db.updateTeacher(teacher);
                if (res > 0)
                {

                    Message msg = new Message("修改讲师资料", "成功修改讲师" + teacher.NAME + "的资料。");
                    msg.ShowDialog();
                    this.LoadData();
                    // 自动跳转
                    List_Click(sender, e);
                }
                else
                {
                    Message msg = new Message("修改讲师资料", "修改讲师" + teacher.NAME + "的资料失败!");
                    msg.ShowDialog();
                }
            }
            catch (Exception add_e)
            {
                Message msg = new Message("修改讲师资料", "修改讲师资料失败!未能正确连接到数据文件。");
                msg.ShowDialog();
            }

        }
예제 #3
0
        public void deleIterm(object sender, RoutedEventArgs e)
        {
            string RecordId = ((Button)sender).Tag.ToString();
            int _id = 0;
            try
            {
                _id = Int16.Parse(RecordId);
            }
            catch (Exception e_record)
            {
                //
                Message msg = new Message("删除", "找寻记录失败!指定的数据不正确或者记录已经不存在了。");
                msg.ShowDialog();
                return;
            }
            Teacher teacher = this.db.getTeacherById(_id);
            ConfirmDialog dia = new ConfirmDialog("删除讲师资料", "确定要删除讲师" + RecordId + "[" + teacher.NAME + "]" + "的资料吗?删除后数据将不能恢复!");
            //dia.Owner = this;


            if (dia.ShowDialog() == true)
            {

                this.db.Delete("TEACHER", "_id = " + _id);
                this.LoadData();
            }

        }
예제 #4
0
        private void export_Click(object sender, RoutedEventArgs e)
        {

            string dbPath = this.filePath.Text;
            if (dbPath == null || dbPath.Trim().Equals(""))
            {
                this.info.Content = "请选择有效路径!";
                return;
            }
            //获取文件名,不带路径
            string fileNameExt = this.filePath.Text.Substring(this.filePath.Text.LastIndexOf("\\") + 1);
            fileNameExt.Insert(1, "dameng");
            string dir = this.filePath.Text;
            try
            {
                if(File.Exists(dir))
                {
                    ConfirmDialog confirm = new ConfirmDialog("导出数据","当前路径已经存在同名文件,要覆盖吗?");
              
                    if(confirm.ShowDialog() == true)
                    {
                    this.info.Content = "正在导出文件到" + dir + " ......";
                    System.IO.File.Copy(AppDomain.CurrentDomain.BaseDirectory + "/data/ETTS_test.db", dir,true);
                    this.info.Content = "文件已经导出到" + dir + " !";

                    }
                }
                else
                {
                    this.info.Content = "正在导出文件到" + dir + " ......";
                    System.IO.File.Copy(AppDomain.CurrentDomain.BaseDirectory + "/data/ETTS_test.db", dir);
                    this.info.Content = "文件已经导出到" + dir + " !";


                }

            

            }
            catch (Exception)
            {
                Message msg = new Message("导出数据", "导出文件出错!");
                msg.ShowDialog();
            }
            //fs.Close();
        }
예제 #5
0
        /**
         * 导出到Excel
         */
        public void Ecport_excel(object sender, RoutedEventArgs e)
        {
            EX ex = new EX();
            //(System.Data.DataTable dt,string dir,string title,string subject,string category,string company,string author)
            System.Data.DataTable table = dt.Copy();

            table.Columns.Remove("_id");
            table.Columns.Remove("PHOTO");

            table.Columns["COURSENUMBER"].ColumnName = "课程编号";
            table.Columns["NAME"].ColumnName = "课程名";
            table.Columns["CATEGORY"].ColumnName = "类别";
            table.Columns["TEACHER"].ColumnName = "讲师";
            table.Columns["TIME"].ColumnName = "课时";
            table.Columns["PRICE"].ColumnName = "价格";
            table.Columns["DETAILS"].ColumnName = "简介";
            table.Columns["REMARK"].ColumnName = "备注";
            string path = ex.dataTableToExcel(table, "课程信息汇总表", "课程", "课程信息", "电网", "软件自动生成");
            if (path != null && !path.Trim().Equals(""))
            {
                Message msg = new Message("数据导出", "指定的已数据成功导出为Excel文档。路径为:" + path);
                msg.ShowDialog();
            }
        }
예제 #6
0
        /**
         * 添加用户
         */
        private void Add_Save_Click(object sender, RoutedEventArgs e)
        {
            int price;

            try
            {
                price = Int16.Parse(this.aPrice.Text);

            }
            catch (Exception age_e)
            {
                Message ms = new Message("错误提示", "数据类型不符!价格必须为数字。");
                ms.ShowDialog();
                return;
            }

            Course course = new Course();
            course.CATEGORY = this.aCategory.Text;
            course.COURSENUMBER = this.aCourseNumber.Text;
            course.NAME = this.aName.Text;
            course.DETAILS = this.aDetail.Text;
            course.TEACHER = this.aTeacher.Text;
            course.TIME = this.aTime.Text;
            course.PRICE = price;
            course.REMARK = this.aRemark.Text;
            //course.photo = this.currentcourse.photo;//Utils.Utils.BitmapImageToByteArray((BitmapImage)(this.aPhoto.Source));
            course.PHOTO = Utils.Utils.BitmapImageToByteArray((BitmapImage)(this.aPhoto.Source));
            //course._id = Int16.Parse(this.e_id.Text);
            try
            {

                int res = this.db.insertCourse(course);
                if (res > 0)
                {

                    Message msg = new Message("添加课程", "成功添加课程" + course.NAME + "。");
                    msg.ShowDialog();
                    this.LoadData();
                    // 自动跳转
                    List_Click(sender, e);
                }
                else
                {
                    Message msg = new Message("添加客户", "添加课程" + course.NAME + "失败!");
                    msg.ShowDialog();
                }
            }
            catch (Exception insert_Exception)
            {
                Message ms = new Message("错误提示", "新增课程数据时出错!未能正确连接到数据文件。");
                ms.ShowDialog();
            }
        }
예제 #7
0
        private void Edit_Save_Click(object sender, RoutedEventArgs e)
        {
            //course course = this.db.getcourseById(id);

            Course course = new Course();
            float price = 0;
            try
            {
                price = float.Parse(this.ePrice.Text);
            }
            catch (Exception price_parse)
            {
                Message ms = new Message("错误提示", "数据类型不符!价格必须为数字。");
                ms.ShowDialog();
                return;
            }

            course.CATEGORY = this.eCategory.Text;
            course.COURSENUMBER = this.eCourseNumber.Text;
            course.NAME = this.eName.Text;
            course.DETAILS = this.eDetail.Text;
            course.TEACHER = this.eTeacher.Text;
            course.TIME = this.eTime.Text;
            course.PRICE = price;
            course.REMARK = this.eRemark.Text;
            //course.photo = this.currentcourse.photo;//Utils.Utils.BitmapImageToByteArray((BitmapImage)(this.aPhoto.Source));
            course.PHOTO = Utils.Utils.BitmapImageToByteArray((BitmapImage)(this.ePhoto.Source));
            course._id = Int16.Parse(this.e_id.Text);
            try
            {

                int res = this.db.updateCourse(course);
                if (res > 0)
                {

                    Message msg = new Message("修改课程资料", "成功修改课程" + course.NAME + "的资料。");
                    msg.ShowDialog();
                    this.LoadData();
                    // 自动跳转
                    List_Click(sender, e);
                }
                else
                {
                    Message msg = new Message("修改课程资料", "修改课程" + course.NAME + "的资料失败!");
                    msg.ShowDialog();
                }
            }
            catch (Exception updata_Exception)
            {
                Message ms = new Message("错误提示", "更新课程数据时出错!未能正确连接到数据文件。");
                ms.ShowDialog();
            }

        }
예제 #8
0
        private void Edit_Save_Click(object sender, RoutedEventArgs e)
        {
            //Student student = this.db.getStudentById(id);

            Student student = this.db.getStudentById(Int16.Parse(this.e_id.Text));
            int age;
            try
            {
                age = Int16.Parse(this.eAge.Text);

            }
            catch (Exception age_e)
            {
                Message ms = new Message("错误提示", "数据类型不符!年龄必须为数字。");
                ms.ShowDialog();
                return;
            }
            if (if_ePassword.IsChecked == true)
            {
                if (!ePassword.Text.Equals(ePassword2.Text))
                {
                    Message ms = new Message("错误提示", "两次输入的密码不一致!请确认您的新密码。");
                    ms.ShowDialog();
                    return;
                }
            }
            student.USERNAME = this.eUserName.Content.ToString();
            student.password = if_ePassword.IsChecked == true ? this.ePassword.Text : student.password;
            student.NAME = this.eName.Text;
            student.age = age;

            student.sex = this.eSex_nan.IsChecked == true ? "男" : "女";//this.aSex.Text;
            student.phone = this.ePhone.Text;
            student.email = this.eEmail.Text;
            student.address = this.eAddress.Text;
            student.remark = this.eRemark.Text;
            //student.photo = this.currentStudent.photo;//Utils.Utils.BitmapImageToByteArray((BitmapImage)(this.aPhoto.Source));
            byte[] photo = Utils.Utils.BitmapImageToByteArray((BitmapImage)(this.ePhoto.Source));
            
            
            student.photo = photo==null||photo.Length==0?student.photo:photo;//Utils.Utils.BitmapImageToByteArray((BitmapImage)(this.aPhoto.Source))
            
            student.isAdmin = this.eIsadmin.IsChecked == true ? 1 : 0;
            //student.id = Int16.Parse(this.e_id.Text);
            try
            {

            int res = this.db.updateStudent(student);
            if (res > 0)
            {

                Message msg = new Message("修改客户资料", "成功客户讲师" + student.USERNAME + "的资料。");
                msg.ShowDialog();
                this.LoadData();
                // 自动跳转
                List_Click(sender,e);
            }
            else
            {
                Message msg = new Message("修改客户资料", "修改客户" + student.USERNAME + "的资料失败!");
                msg.ShowDialog();
            }
            }
            catch (Exception add_e)
            {
                Message msg = new Message("修改客户资料", "新增客户资料失败!未能正确连接到数据文件。");
                msg.ShowDialog();
            }

        }
예제 #9
0
        public void deleIterm(object sender, RoutedEventArgs e)
        {
            string id ;
            try
            {


                 id = ((Button)sender).Tag.ToString();
            }
            catch (Exception ee)
            {
                Message ms = new Message("错误提示", "传入参数错误!。");
                ms.ShowDialog();
                return;
            }
            //dia.Owner = this;

            int _id = 0;
            try
            {
                _id = Int16.Parse(id);
            }
            catch (Exception e_record)
            {
                //
                Message msg = new Message("删除","找寻记录失败!指定的数据不正确或者记录已经不存在了。");
                msg.ShowDialog();
                return;
            }
            Schedule sc = this.db.getScheduleById(_id);
            ConfirmDialog dia = new ConfirmDialog("删除用户", "确定要删除订单" + sc.ORDERNUMBER +"下的记录" +sc.courseName+"吗?删除后数据将不能恢复!");
            if (dia.ShowDialog() == true)
            {
                this.db.Delete_("ORDERS", "_id = " + _id);
                this.LoadData();
            }
        }
예제 #10
0
 private void dg_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     // 选择行,这个事件会被激活
     //btnQuanFou_Click(sender,e);
     DataGridRow ObjROw = (DataGridRow)sender;
     FrameworkElement objElement = dataGrid1.Columns[0].GetCellContent(ObjROw);
     System.Windows.Controls.CheckBox objChk = (System.Windows.Controls.CheckBox)objElement;
     if (objChk.IsChecked == false)
     {
         objChk.IsChecked = true;
     }
     else
     {
         objChk.IsChecked = false;
     }
     Message m = new Message("select","clicked");
     m.ShowDialog();
 }
예제 #11
0
        /**
         * 导出到Excel
         */
        public void Ecport_excel(object sender, RoutedEventArgs e)
        {
            EX ex = new EX();
            //(System.Data.DataTable dt,string dir,string title,string subject,string category,string company,string author)
           // System.Data.DataTable table = dt.Copy();
            System.Data.DataTable table = this.getSelected();
            table.Columns.Remove("_id");
            table.Columns.Remove("ADDTIME");

            table.Columns["GMT_time"].ColumnName = "订单添加时间";
            
            string path = ex.dataTableToExcel(table, "订单信息汇总表", "订单", "订单信息", "电网", "软件自动生成");
            if (path != null && !path.Trim().Equals(""))
            {
                Message msg = new Message("数据导出", "指定的已数据成功导出为Excel文档。路径为:" + path);
                msg.ShowDialog();
            }
        }
예제 #12
0
        /**
         * 导出到Excel
         */
        public void Ecport_excel(object sender, RoutedEventArgs e)
        {
            EX ex = new EX();
            //(System.Data.DataTable dt,string dir,string title,string subject,string category,string company,string author)
            System.Data.DataTable table = dt.Copy();
            table.Columns.Add("是否管理员");
            for (int i = 0; i < table.Rows.Count; i++)
            {
                table.Rows[i]["是否管理员"] = table.Rows[i]["IS_ADMIN"].ToString().Equals("1") ? "是" : "否";
            }
            table.Columns.Remove("IS_ADMIN");
            table.Columns.Remove("_id");
            table.Columns.Remove("PASSWORD");

            table.Columns["NAME"].ColumnName = "联系人";
            table.Columns.Remove("PHOTO");
            table.Columns["USERNAME"].ColumnName = "客户名";
            table.Columns["AGE"].ColumnName = "年龄";
            table.Columns["SEX"].ColumnName = "性别";
            table.Columns["PHONE"].ColumnName = "联系人电话";
            table.Columns["EMAIL"].ColumnName = "电子邮箱";
            table.Columns["ADDRESS"].ColumnName = "地址";
            table.Columns["REMARK"].ColumnName = "备注";
            string path = ex.dataTableToExcel(table, "客户信息汇总表", "用户", "用户信息", "电网", "软件自动生成");
            if (path != null && !path.Trim().Equals(""))
            {
                Message msg = new Message("数据导出", "指定的已数据成功导出为Excel文档。路径为:" + path);
                msg.ShowDialog();
            }
        }
예제 #13
0
        /**
         * 添加用户
         */
        private void Add_Save_Click(object sender, RoutedEventArgs e)
        {
            int age;

            if (this.aUserName.Text == null || this.aUserName.Text.Trim().Equals(""))
            {
                Message ms = new Message("错误提示", "用户名称不能为空!");
                ms.ShowDialog();
                return;
            }
            if (this.db.getStudentByName(this.aUserName.Text)!=null)
            {
                Message ms = new Message("错误提示", "该名称已经被占用!");
                ms.ShowDialog();
                return;
            }
            try
            {
                age = Int16.Parse(this.aAge.Text);

            }
            catch (Exception age_e)
            {
                Message ms = new Message("错误提示", "数据类型不符!年龄必须为数字。");
                ms.ShowDialog();
                return;
            }

            Student student = new Student();
            student.USERNAME = this.aUserName.Text;
            
            student.password = this.aPassword.Text;
            student.NAME = this.aName.Text;
            student.age = age;

            student.sex = this.aSex_nan.IsChecked == true ? "男" : "女";//this.aSex.Text;
            student.phone = this.aPhone.Text;
            student.email = this.aEmail.Text;
            student.address = this.aAddress.Text;
            student.remark = this.aRemark.Text;
            student.photo = Utils.Utils.BitmapImageToByteArray((BitmapImage)(this.aPhoto.Source));//Utils.Utils.BitmapImageToByteArray((BitmapImage)(this.aPhoto.Source));
            student.isAdmin = this.aIsadmin.IsChecked == true ? 1 : 0;
            DB db = new DB();
            int res = db.insertStudent(student);
            if (res > 0)
            {

                Message msg = new Message("添加客户", "成功添加客户" + student.USERNAME + "。");
                msg.ShowDialog();
                this.LoadData();
                // 自动跳转
                List_Click(sender, e);
            }
            else
            {
                Message msg = new Message("添加客户", "添加客户" + student.USERNAME + "失败!");
                msg.ShowDialog();
            }
        }
예제 #14
0
        /**
         * 添加用户
         */
        private void Add_Save_Click(object sender, RoutedEventArgs e)
        {
            int age;

            try
            {
                age = Int16.Parse(this.aAge.Text);

            }
            catch (Exception age_e)
            {
                Message ms = new Message("错误提示", "数据类型不符!年龄必须为数字。");
                ms.ShowDialog();
                return;
            }

            Teacher teacher = new Teacher();
            teacher.TEACHERNUMBER = this.aTeacherNumber.Text;
            teacher.DIRECTION = this.aDirection.Text;
            teacher.NAME = this.aName.Text;
            teacher.AGE = age;

            teacher.SEX = this.aSex_nan.IsChecked == true ? "男" : "女";//this.aSex.Text;
            teacher.PHONE = this.aPhone.Text;
            teacher.EMAIL = this.aEmail.Text;
            teacher.POSITION = this.aPosition.Text;
            teacher.REMARK = this.aRemark.Text;
            teacher.PHOTO = Utils.Utils.BitmapImageToByteArray((BitmapImage)(this.aPhoto.Source));//Utils.Utils.BitmapImageToByteArray((BitmapImage)(this.aPhoto.Source));
            teacher.DETAILS = this.aDetails.Text;

            try
            {


                int res = this.db.insertTeacher(teacher);
                if (res > 0)
                {

                    Message msg = new Message("添加讲师", "成功添加讲师" + teacher.NAME + "。");
                    msg.ShowDialog();
                    this.LoadData();
                    // 自动跳转
                    List_Click(sender, e);
                }
                else
                {
                    Message msg = new Message("添加讲师", "添加讲师" + teacher.NAME + "失败!");
                    msg.ShowDialog();
                }
            }
            catch (Exception add_e)
            {
                Message msg = new Message("修改讲师资料", "新增讲师资料失败!未能正确连接到数据文件。");
                msg.ShowDialog();
            }
        }
예제 #15
0
        public void viewIterm(object sender, RoutedEventArgs e)
        {
            int id = 0;
            try
            {

                string a = ((Button)sender).Tag.ToString();
                id = Int16.Parse(a);
            }
            catch (Exception view_e)
            {
                Message ms = new Message("错误提示", "传入参数错误!。");
                ms.ShowDialog();
                return;
            }

            Course course = this.db.getCourseById(id);


            ////
            this.vName.Content = course.NAME;
            this.vPhoto.Source = Utils.Utils.ByteArrayToBitmapImage(course.PHOTO);
            this.vRemark.Content = course.REMARK;
            this.vTeacher.Content = course.TEACHER;
            this.vTime.Content = course.TIME;
            //this.v_id.Content = course._id + "";
            this.vDetail.Text = course.DETAILS;
            this.vPrice.Content = course.PRICE + "";
            this.vCategory.Content = course.CATEGORY;
            this.vCourseNumber.Content = course.COURSENUMBER;

            this.show_view();
            this.view_edit.Tag = id;

        }
예제 #16
0
        /**
         * 导出到Excel
         */
        public void Ecport_excel(object sender, RoutedEventArgs e)
        {
            EX ex = new EX();
            //(System.Data.DataTable dt,string dir,string title,string subject,string category,string company,string author)
            System.Data.DataTable table = dt.Copy();

            table.Columns.Remove("_id");
            table.Columns.Remove("PHOTO");

            table.Columns["NAME"].ColumnName = "姓名";
            table.Columns["TEACHERNUMBER"].ColumnName = "用户编号";
            table.Columns["AGE"].ColumnName = "年龄";
            table.Columns["SEX"].ColumnName = "性别";
            table.Columns["PHONE"].ColumnName = "电话";
            table.Columns["EMAIL"].ColumnName = "电子邮箱";
            table.Columns["POSITION"].ColumnName = "地址";
            table.Columns["DIRECTION"].ColumnName = "方向";
            table.Columns["DETAILS"].ColumnName = "简介";
            table.Columns["REMARK"].ColumnName = "备注";
            string path = ex.dataTableToExcel(table, "师资信息汇总表", "师资", "师资信息", "国家电网", "软件自动生成");
            if (path != null && !path.Trim().Equals(""))
            {

                Message msg = new Message("数据导出", "指定的已数据成功导出为Excel文档。路径为:" + path);
                msg.ShowDialog();
            }
        }
예제 #17
0
        public void deleIterm(object sender, RoutedEventArgs e)
        {
            string RecordId = ((Button)sender).Tag.ToString();
            int _id = 0;
            try
            {
                _id = Int16.Parse(RecordId);
            }
            catch (Exception e_record)
            {
                //
                Message msg = new Message("删除", "找寻记录失败!指定的数据不正确或者记录已经不存在了。");
                msg.ShowDialog();
                return;
            }
            Student stu = this.db.getStudentById(_id);
            if (stu.USERNAME.Equals("admin"))
            {
                Message msg = new Message("警告", "用户[ " + stu.USERNAME + "]是系统保留管理员账户,不允许删除!");
                msg.ShowDialog();
                return;
            }
            ConfirmDialog dia = new ConfirmDialog("删除用户", "确定要删除用户" + RecordId + "[" + stu.NAME + "]" + "吗?删除后数据将不能恢复!");
            //dia.Owner = this;


            if (dia.ShowDialog() == true)
            {
                
                this.db.Delete("USER", "_id = " + _id);
                this.LoadData();
            }
            
        }