Example #1
0
        private async void button_Click(object sender, RoutedEventArgs e)//添加
        {
            string  buildingnum;
            string  wnum;
            GetInfo g = new GetInfo();

            buildingnum = comboBox.SelectedValue.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
            int num = g.getMnum(buildingnum) + 1;

            wnum = "00" + buildingnum + "00" + num.ToString();
            string wname = textBox1.Text;
            string pwd   = "111111";

            labelwnum.Content = wnum;
            string s = "insert into worker(wnum,wname,bnum,pwd)values('" + wnum + "','" + wname + "','" + buildingnum + "','" + pwd + "')";

            if (wname == "" || buildingnum == "")
            {
                await this.ShowMessageAsync("提示", "请输入完整的信息");
            }
            MYSql mYSql = new MYSql();

            try
            {
                mYSql.ExecuteQuery(s);
                await this.ShowMessageAsync("提示", "插入成功,新的工号是" + wnum);

                man.dataGrid.ItemsSource = mYSql.ExecuteQuery("select wnum as '工号',wname as '姓名',bnum as '管理栋号' from worker").DefaultView;
                this.Close();
            }
            catch (Exception ex)
            {
                await this.ShowMessageAsync("提示", "未插入成功,已有此工号" + ex);
            }
        }
Example #2
0
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            IntPtr p        = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(this.passid.SecurePassword);
            string password = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(p);

            if (userid.Text == "" || password == "")
            {
                await this.ShowMessageAsync("提示", "用户名和密码不能为空");
            }
            else
            {
                if (selected == 0)
                {
                    await this.ShowMessageAsync("提示", "请选择登陆属性");
                }
                if (selected == 1)                           //弹出普通用户界面
                {
                    string    username = userid.Text.Trim(); //账号
                    string    pw       = password;;          //密码
                    string    s1       = "select wnum,pwd,bnum from worker where wnum='" + username + "' and pwd='" + password + "'";
                    DataTable dt       = new DataTable();
                    dt = mysql.ExecuteQuery(s1);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        GetInfo  getInfo     = new GetInfo();
                        string   buildingnum = getInfo.GetBuildingnum(username);
                        userMain u           = new userMain(buildingnum);
                        Source.build = dt.Rows[0][2].ToString();
                        this.Close();
                        u.Show();
                    }
                    else
                    {
                        await this.ShowMessageAsync("提示", "用户名或密码错误");
                    }
                }
                if (selected == 2)//弹出管理员界面
                {
                    if (userid.Text == "admin" && password == "admin")
                    {
                        manmain man = new manmain();
                        this.Close();
                        man.Show();
                    }
                    else
                    {
                        await this.ShowMessageAsync("提示", "用户名或密码错误");
                    }
                }
                if (selected == 3)//学生界面
                {
                    string    sid = userid.Text.Trim();
                    string    pw  = password;;//密码
                    string    s1  = "select sid,password from student where sid='" + sid + "' and password='******'";
                    DataTable dt  = new DataTable();
                    dt = mysql.ExecuteQuery(s1);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        GetInfo  gf          = new GetInfo();
                        string[] temp        = gf.GetTable(sid);
                        string   buildingnum = temp[0];
                        string   roomnum     = temp[1];
                        if (buildingnum == "error")
                        {
                            await this.ShowMessageAsync("提示", "不存在您的住宿信息");
                        }
                        else
                        {
                            StuMain u = new StuMain(buildingnum, roomnum);
                            this.Close();
                            u.Show();
                        }
                    }
                    else
                    {
                        await this.ShowMessageAsync("提示", "用户不存在或密码错误");
                    }
                }
            }
            //userMain u = new userMain();
            //this.Close();
            //u.Show();
            //manmain man= new manmain();
            //this.Close();
            //man.Show();
        }
Example #3
0
        private async void button2_Click(object sender, RoutedEventArgs e)
        {
            GetInfo getInfo    = new GetInfo();
            string  sid        = textBox.Text.Trim();
            string  newroomnum = textBox1.Text.Trim();


            MYSql  mysql = new MYSql();
            string s;

            if (selected == 0 || selected == 2 || selected == 1)
            {
                if (newroomnum == "" || sid == "")
                {
                    await this.ShowMessageAsync("提示", "您还有属性未填写");
                }
                else
                {
                    if (selected == 0)
                    {
                        await this.ShowMessageAsync("提示", "请先选择更改属性");
                    }
                    if (selected == 1)//修改个人
                    {
                        string newbuildingnum = comboBox1.SelectedValue.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
                        if (Getin(newbuildingnum, newroomnum, 1))
                        {
                            s = "update DS set buildingnum = '" + newbuildingnum + "' ,roomnum = '" + newroomnum + "' where sid = '" + sid + "'";//sql语句
                            MessageDialogResult result = await this.ShowMessageAsync("更改信息", "您真的要修改吗?", MessageDialogStyle.AffirmativeAndNegative);

                            if (result != MessageDialogResult.Negative)//取消
                            {
                                if (getInfo.setin(sid, newbuildingnum))
                                {
                                    try
                                    {
                                        mysql.ExecuteUpdate(s);
                                        await this.ShowMessageAsync("提示", "修改成功");

                                        this.Close();
                                    }
                                    catch
                                    {
                                        await this.ShowMessageAsync("提示", "无此寝室号");
                                    }
                                }
                                else
                                {
                                    await this.ShowMessageAsync("提示", "不同性别学生不能安排在同一寝室");
                                }
                            }
                        }
                        else
                        {
                            await this.ShowMessageAsync("提示", "寝室无空余床位或是无此寝室号");
                        }
                    }
                    if (selected == 2)//修改整个寝室
                    {
                        string newbuildingnum = comboBox1.SelectedValue.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
                        string oldbuildingnum = comboBox2.SelectedValue.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
                        if (Getin(newbuildingnum, newroomnum, 2))
                        {
                            s = "update DS set buildingnum = '" + newbuildingnum + "',roomnum = '" + newroomnum + "'where buildingnum ='" + sid + "'and roomnum ='" + oldbuildingnum + "'";
                            MessageDialogResult result = await this.ShowMessageAsync("更改信息", "您真的要修改吗?", MessageDialogStyle.AffirmativeAndNegative);

                            if (result != MessageDialogResult.Negative)//取消
                            {
                                if ((Convert.ToInt32(newbuildingnum) % 2) != (Convert.ToInt32(oldbuildingnum) % 2))
                                {
                                    await this.ShowMessageAsync("提示", "不同性别不能安排在同一个寝室楼");
                                }
                                else
                                {
                                    try
                                    {
                                        mysql.ExecuteUpdate(s);
                                        await this.ShowMessageAsync("提示", "修改成功");

                                        this.Close();
                                    }
                                    catch
                                    {
                                        await this.ShowMessageAsync("提示", "无此寝室号");
                                    }
                                }
                            }
                        }
                        else
                        {
                            await this.ShowMessageAsync("提示", "寝室无空余床位或是无此寝室号");
                        }
                    }
                }
            }
            else if (selected == 3)
            {
                string year = yeartextbox.Text;
                if (year == "")
                {
                    await this.ShowMessageAsync("提示", "请输入年份");
                }
                else
                {
                    AGSI gs = new AGSI(year);

                    try
                    {
                        Progress1.IsActive = true;
                        gs.DAlloc();
                        Progress1.IsActive = false;
                        await this.ShowMessageAsync("提示", "完成");
                    }
                    catch (Exception ex)
                    {
                        await this.ShowMessageAsync("异常", ex.ToString());
                    }

                    this.Close();
                }
            }
        }