Beispiel #1
0
        protected override void OnShown(EventArgs e)
        {
            List <Domitory> list = new List <Domitory>();
            var             res  = APIHelper.Get <ApiResult <List <Domitory> > >(WebSetting.GetUrl("domitory/list"));

            if (res != null && res.Code == 0)
            {
                list = res.Data;
            }

            if (list.Count < 1)
            {
                MessageBox.Show("not have domitory");
            }

            this.comboBox1.DisplayMember = "No";
            this.comboBox1.ValueMember   = "No";
            this.comboBox1.DataSource    = list;

            this.textBox1.Text = Student.No;
            this.textBox2.Text = Student.Name;
            this.textBox3.Text = Student.Sex;
            this.textBox4.Text = Student.SubjectName;
            this.textBox5.Text = Student.ClassName;
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string domitoryNo = comboBox1.SelectedValue.ToString();

            if (string.IsNullOrEmpty(domitoryNo))
            {
                MessageBox.Show("not select domitoryNo");
                return;
            }

            var res = APIHelper.Get <ApiResult>(WebSetting.GetUrl("user/checkIn"),
                                                new Dictionary <string, object>()
            {
                { "no", Student.No }, { "domitoryNo", domitoryNo }
            });

            if (res == null || res.Code != 0)
            {
                MessageBox.Show("check in failed!" + (res != null ? res.Msg : ""));
                return;
            }
            else
            {
                MessageBox.Show("success");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string domitoryNo = this.comboBox1.SelectedValue != null?this.comboBox1.SelectedValue.ToString() : "";

            if (string.IsNullOrEmpty(domitoryNo))
            {
                MessageBox.Show("请选择宿舍");
                return;
            }

            Student.DomitoryID  = domitoryNo;
            Student.CheckInTime = this.dateTimePicker1.Value;


            var result = APIHelper.Post <ApiResult>(WebSetting.GetUrl("Student/CheckIn"),
                                                    new Dictionary <string, object>()
            {
                { "id", Student.StudentID },
                { "DomitoryID", Student.DomitoryID },
                { "CheckInTime", Student.CheckInTime },
            });

            if (result.Code == 0)
            {
                MessageBox.Show(result.Msg);
            }
            else
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Beispiel #4
0
        protected override void OnShown(EventArgs e)
        {
            List <Domitory> list   = new List <Domitory>();
            var             result = APIHelper.Post <ApiResult <List <Domitory> > >(WebSetting.GetUrl("Domitory/List"));

            if (result.Code == 0)
            {
                list = result.Data;
            }
            if (list.Count < 1)
            {
                MessageBox.Show("没有宿舍可选择");
            }

            this.comboBox1.DisplayMember = "DomitoryID";
            this.comboBox1.ValueMember   = "DomitoryID";
            this.comboBox1.DataSource    = list;

            this.textBox1.Text         = Student.No;
            this.textBox2.Text         = Student.Name;
            this.textBox3.Text         = Student.PhoneNumber;
            this.textBox4.Text         = Student.SubjectName;
            this.textBox5.Text         = Student.ClassName;
            this.dateTimePicker1.Value = DateTime.Now;

            if (!string.IsNullOrEmpty(Student.DomitoryID))
            {
                this.comboBox1.SelectedValue = Student.DomitoryID;
            }

            if (Student.CheckInTime.HasValue)
            {
                this.dateTimePicker1.Value = Student.CheckInTime.Value;
            }
        }
Beispiel #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            string no        = this.textBox1.Text;
            string name      = this.textBox2.Text;
            string sex       = this.comboBox2.SelectedValue.ToString();
            string subject   = this.textBox4.Text;
            string className = this.textBox5.Text;

            var res = APIHelper.Get <ApiResult>(WebSetting.GetUrl("user/add"),
                                                new Dictionary <string, object>()
            {
                { "no", no },
                { "name", name },
                { "sex", sex },
                { "subjectName", subject },
                { "className", className },
            });

            if (res == null || res.Code != 0)
            {
                MessageBox.Show("add failed!" + (res != null ? res.Msg : ""));
                return;
            }
            else
            {
                MessageBox.Show("success");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Beispiel #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            string   no       = this.textBox1.Text;
            string   phone    = this.textBox2.Text;
            Domitory domitory = new Domitory()
            {
                DomitoryID  = no,
                PhoneNumber = phone
            };

            var result = APIHelper.Post <ApiResult>(WebSetting.GetUrl("Domitory/Add"), new Dictionary <string, object>()
            {
                { "DomitoryID", no }, { "PhoneNumber", phone }
            });

            if (result.Code == 0)
            {
                MessageBox.Show(result.Msg);
            }
            else
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Beispiel #7
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dataGridView = sender as DataGridView;

            if (dataGridView != null && e.RowIndex > -1 && e.ColumnIndex > -1)
            {
                var selectedRow    = dataGridView.Rows[e.RowIndex];
                var selectedColumn = dataGridView.Columns[e.ColumnIndex];
                if (selectedRow != null && selectedColumn != null)
                {
                    string no = selectedRow.Cells["No"].Value.ToString();
                    if (!string.IsNullOrEmpty(no))
                    {
                        Student student = null;
                        var     res     = APIHelper.Get <ApiResult <Student> >(WebSetting.GetUrl("user/get"), new Dictionary <string, object>()
                        {
                            { "no", no }
                        });
                        if (res != null && res.Code == 0)
                        {
                            student = res.Data;
                        }

                        if (student == null)
                        {
                            RefreshData();
                        }
                        else
                        {
                            switch (selectedColumn.HeaderText)
                            {
                            case "CheckOut":
                                var res1 = APIHelper.Get <ApiResult>(WebSetting.GetUrl("user/checkout"), new Dictionary <string, object>()
                                {
                                    { "no", no }
                                });
                                if (res1 == null || res1.Code != 0)
                                {
                                    MessageBox.Show("退宿失败!" + (res1 != null ? res1.Msg : ""));
                                    return;
                                }
                                else
                                {
                                    MessageBox.Show("退宿成功");
                                    RefreshData();
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #8
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dataGridView = sender as DataGridView;

            if (dataGridView != null && e.RowIndex > -1 && e.ColumnIndex > -1)
            {
                var selectedRow    = dataGridView.Rows[e.RowIndex];
                var selectedColumn = dataGridView.Columns[e.ColumnIndex];
                if (selectedRow != null && selectedColumn != null)
                {
                    string no = selectedRow.Cells["No"].Value.ToString();
                    if (!string.IsNullOrEmpty(no))
                    {
                        Student student = null;
                        var     result  = APIHelper.Get <ApiResult <Student> >(WebSetting.GetUrl("Student/Single"), new Dictionary <string, object> {
                            { "Id", no }
                        });
                        if (result.Code == 0)
                        {
                            student = result.Data;
                        }
                        else
                        {
                            MessageBox.Show(result.Msg);
                        }

                        if (student == null)
                        {
                            RefreshData();
                        }
                        else
                        {
                            switch (selectedColumn.Name)
                            {
                            case "Modify":
                                ModifyStudent modify = new ModifyStudent(student);
                                if (modify.ShowDialog() == DialogResult.OK)
                                {
                                    MessageBox.Show("修改成功");
                                    RefreshData();
                                }
                                else
                                {
                                    MessageBox.Show("修改失败");
                                    return;
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
Beispiel #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            string no         = this.textBox1.Text;
            string name       = this.textBox2.Text;
            string phone      = this.textBox3.Text;
            string subject    = this.textBox4.Text;
            string className  = this.textBox5.Text;
            string domitoryNo = this.comboBox1.SelectedValue != null?this.comboBox1.SelectedValue.ToString() : "";

            DateTime checkInTime = this.dateTimePicker1.Value;

            if (string.IsNullOrEmpty(domitoryNo))
            {
                MessageBox.Show("请选择宿舍");
                return;
            }
            Student student = new Student()
            {
                StudentID   = no,
                Name        = name,
                PhoneNumber = phone,
                SubjectName = subject,
                ClassName   = className,
                DomitoryID  = domitoryNo,
                CheckInTime = checkInTime
            };

            var result = APIHelper.Post <ApiResult>(WebSetting.GetUrl("Student/Add"),
                                                    new Dictionary <string, object>()
            {
                { "StudentID", student.StudentID },
                { "Name", student.Name },
                { "PhoneNumber", student.PhoneNumber },
                { "SubjectName", student.SubjectName },
                { "ClassName", student.ClassName },
                { "DomitoryID", student.DomitoryID },
                { "CheckInTime", student.CheckInTime },
            });

            if (result.Code == 0)
            {
                MessageBox.Show(result.Msg);
            }
            else
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Beispiel #10
0
        private void RefreshData()
        {
            string no         = this.textBox1.Text;
            string name       = this.textBox2.Text;
            string subject    = this.textBox3.Text;
            string className  = this.textBox4.Text;
            string domitoryNo = this.textBox5.Text;

            Dictionary <string, object> queryParams = new Dictionary <string, object>()
            {
                { "isHaveDomitory", true }
            };

            if (!string.IsNullOrEmpty(no))
            {
                queryParams.Add("no", no);
            }

            if (!string.IsNullOrEmpty(name))
            {
                queryParams.Add("name", name);
            }

            if (!string.IsNullOrEmpty(subject))
            {
                queryParams.Add("subjectName", subject);
            }

            if (!string.IsNullOrEmpty(className))
            {
                queryParams.Add("className", className);
            }

            if (!string.IsNullOrEmpty(domitoryNo))
            {
                queryParams.Add("domitoryNo", domitoryNo);
            }


            List <Student> students = new List <Student>();
            var            res      = APIHelper.Get <ApiResult <List <Student> > >(WebSetting.GetUrl("user/list"), queryParams);

            if (res != null && res.Code == 0)
            {
                students = res.Data;
            }

            this.dataGridView1.DataSource = students;
        }
Beispiel #11
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dataGridView = sender as DataGridView;

            if (dataGridView != null && e.RowIndex > -1 && e.ColumnIndex > -1)
            {
                var selectedRow    = dataGridView.Rows[e.RowIndex];
                var selectedColumn = dataGridView.Columns[e.ColumnIndex];
                if (selectedRow != null && selectedColumn != null)
                {
                    string no = selectedRow.Cells["No"].Value.ToString();
                    if (!string.IsNullOrEmpty(no))
                    {
                        Student student = null;
                        var     res     = APIHelper.Get <ApiResult <Student> >(WebSetting.GetUrl("user/get"), new Dictionary <string, object>()
                        {
                            { "no", no }
                        });
                        if (res != null && res.Code == 0)
                        {
                            student = res.Data;
                        }

                        if (student == null)
                        {
                            RefreshData();
                        }
                        else
                        {
                            switch (selectedColumn.HeaderText)
                            {
                            case "CheckIn":
                                CheckIn checkInForm = new CheckIn(student);
                                checkInForm.StartPosition = FormStartPosition.CenterScreen;
                                if (checkInForm.ShowDialog() == DialogResult.OK)
                                {
                                    MessageBox.Show("分配宿舍成功");
                                    RefreshData();
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
Beispiel #12
0
        protected override void OnShown(EventArgs e)
        {
            List <Domitory> list   = new List <Domitory>();
            var             result = APIHelper.Post <ApiResult <List <Domitory> > >(WebSetting.GetUrl("Domitory/List"));

            if (result.Code == 0)
            {
                list = result.Data;
            }

            if (list.Count < 1)
            {
                MessageBox.Show("没有宿舍可选");
            }

            this.comboBox1.DisplayMember = "DomitoryID";
            this.comboBox1.ValueMember   = "DomitoryID";
            this.comboBox1.DataSource    = list;

            this.dateTimePicker1.Value = DateTime.Now;
            base.OnShown(e);
        }
Beispiel #13
0
        private void button1_Click(object sender, EventArgs e)
        {
            string no    = this.textBox1.Text;
            string phone = this.textBox2.Text;

            var res = APIHelper.Get <ApiResult>(WebSetting.GetUrl("domitory/add"),
                                                new Dictionary <string, object>()
            {
                { "no", no }, { "phone", phone }
            });

            if (res == null || res.Code != 0)
            {
                MessageBox.Show("add failed!" + (res != null ? res.Msg : ""));
                return;
            }
            else
            {
                MessageBox.Show("success");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Beispiel #14
0
        private void RefreshData()
        {
            string no    = this.textBox1.Text;
            string phone = this.textBox2.Text;

            List <Domitory> list   = new List <Domitory>();
            var             result = APIHelper.Get <ApiResult <List <Domitory> > >(WebSetting.GetUrl("Domitory/List"),
                                                                                   new Dictionary <string, object>()
            {
                { "Id", no },
                { "Phone", phone },
            });

            if (result.Code == 0)
            {
                list = result.Data;
            }
            else
            {
                MessageBox.Show(result.Msg);
            }

            this.dataGridView1.DataSource = list;
        }
        private void RefreshData()
        {
            string no         = this.textBox1.Text;
            string domitoryNo = this.textBox2.Text;

            var result = APIHelper.Get <ApiResult <List <Student> > >(WebSetting.GetUrl("Student/List"),
                                                                      new Dictionary <string, object> {
                { "Id", no },
                { "DomitoryId", domitoryNo }
            });

            List <Student> list = new List <Student>();

            if (result.Code == 0)
            {
                list = result.Data;
            }
            else
            {
                MessageBox.Show(result.Msg);
            }

            this.dataGridView1.DataSource = list;
        }
Beispiel #16
0
        private void button1_Click(object sender, EventArgs e)
        {
            string  no        = this.textBox1.Text;
            string  name      = this.textBox2.Text;
            string  phone     = this.textBox3.Text;
            string  subject   = this.textBox4.Text;
            string  className = this.textBox5.Text;
            Student student   = new Student()
            {
                StudentID   = no,
                Name        = name,
                PhoneNumber = phone,
                SubjectName = subject,
                ClassName   = className
            };

            var result = APIHelper.Post <ApiResult>(WebSetting.GetUrl("Student/Modify"),
                                                    new Dictionary <string, object>()
            {
                { "StudentID", student.StudentID },
                { "Name", student.Name },
                { "PhoneNumber", student.PhoneNumber },
                { "SubjectName", student.SubjectName },
                { "ClassName", student.ClassName }
            });

            if (result.Code == 0)
            {
                MessageBox.Show(result.Msg);
            }
            else
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Beispiel #17
0
        private void RefreshData()
        {
            string no    = this.textBox1.Text;
            string phone = this.textBox2.Text;

            Dictionary <string, object> queryParams = new Dictionary <string, object>()
            {
                //{ "isHaveDomitory",false }
            };

            if (!string.IsNullOrEmpty(no))
            {
                queryParams.Add("no", no);
            }

            if (!string.IsNullOrEmpty(phone))
            {
                queryParams.Add("phone", phone);
            }


            List <Domitory> domitorys = new List <Domitory>();
            var             res       = APIHelper.Get <ApiResult <List <Domitory> > >(WebSetting.GetUrl("domitory/list"), queryParams);

            if (res != null && res.Code == 0)
            {
                domitorys = res.Data;
            }

            this.dataGridView1.DataSource = domitorys;
        }
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dataGridView = sender as DataGridView;

            if (dataGridView != null && e.RowIndex > -1 && e.ColumnIndex > -1)
            {
                var selectedRow    = dataGridView.Rows[e.RowIndex];
                var selectedColumn = dataGridView.Columns[e.ColumnIndex];
                if (selectedRow != null && selectedColumn != null)
                {
                    string no = selectedRow.Cells["No"].Value.ToString();
                    if (!string.IsNullOrEmpty(no))
                    {
                        Student student = null;
                        var     result  = APIHelper.Get <ApiResult <Student> >(WebSetting.GetUrl("Student/Single"), new Dictionary <string, object> {
                            { "Id", no }
                        });
                        if (result.Code == 0)
                        {
                            student = result.Data;
                        }
                        else
                        {
                            MessageBox.Show(result.Msg);
                        }

                        if (student == null)
                        {
                            RefreshData();
                        }
                        else
                        {
                            switch (selectedColumn.Name)
                            {
                            case "CheckOut":

                                if (student.RoomNumber < 1)
                                {
                                    MessageBox.Show("此学生未入住宿舍");
                                    return;
                                }

                                bool success        = false;
                                var  checkOutResult = APIHelper.Post <ApiResult>(WebSetting.GetUrl("Student/CheckOut"), new Dictionary <string, object> {
                                    { "Id", no }
                                });
                                if (checkOutResult.Code == 0)
                                {
                                    success = true;
                                }

                                if (success)
                                {
                                    MessageBox.Show("退宿成功");
                                    RefreshData();
                                }
                                else
                                {
                                    MessageBox.Show("退宿失败");
                                    return;
                                }
                                break;

                            case "CheckIn":
                                CheckIn checkIn = new CheckIn(student);
                                if (checkIn.ShowDialog() == DialogResult.OK)
                                {
                                    MessageBox.Show("分配宿舍成功");
                                    RefreshData();
                                }
                                else
                                {
                                    MessageBox.Show("分配宿舍失败");
                                    return;
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }