Example #1
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();
            }
        }
Example #2
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;
            }
        }
Example #3
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();
            }
        }
Example #4
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();
            }
        }
Example #5
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);
        }
Example #6
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();
            }
        }
Example #7
0
        private void RefreshData()
        {
            string no         = this.textBox1.Text;
            string domitoryNo = this.textBox2.Text;

            var result = APIHelper.Post <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;
        }
Example #8
0
        private void RefreshData()
        {
            string no    = this.textBox1.Text;
            string phone = this.textBox2.Text;

            List <Domitory> list   = new List <Domitory>();
            var             result = APIHelper.Post <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;
        }
Example #9
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 "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;
                            }
                        }
                    }
                }
            }
        }