Exemplo n.º 1
0
        /// <summary>
        /// 获取文本框的值赋给实体类里面变量的方法
        /// </summary>
        /// <returns></returns>
        private PlanBook txtText()
        {
            PlanBook plan = new PlanBook();                  //初始化实体类PlanBook

            plan.CourseName     = txtCourseName.Text.Trim(); //为实体类里面的字段赋值
            plan.BookName       = txtBookName.Text.Trim();
            plan.Author         = txtAuthor.Text.Trim();
            plan.ISBN           = txtISBN.Text.Trim();
            plan.Price          = float.Parse(txtPrice.Text.Trim());
            plan.Publish        = txtPublish.Text.Trim();
            plan.StudentBookNum = int.Parse(txtStudentBookNum.Text.Trim());
            plan.TeacherBookNum = int.Parse(txtTeacherBookNum.Text.Trim());

            StudentClass student = common.GetAllCollegeInfo_Class(cmbStudentClass.Text); //以下拉框班级的文本值作参数调用方法GetAllCollegeInfo_Class()并赋值给实体类

            plan.MajorInfoID    = student.MajorInfoID;                                   //获取实体类StudentClass中的专业编号赋值给实体类PlanBook中的专业编号
            plan.StudentClassID = student.StudentClassID;                                //获取实体类StudentClass中的学院编号赋值给实体类PlanBook中的学院编号

            plan.SchoolTermID = cmbSchoolTerm.SelectedIndex;                             //获取下拉框学年学期的索引值并赋值给实体类PlanBook里面的SchoolTermID字段
            plan.CourseID     = cmbCourseType.SelectedIndex;                             //获取下拉框课程类型的索引值并赋值给实体类PlanBook里面的CourseID字段
            plan.CollegeID    = cmbCollege.SelectedIndex;                                //获取下拉框学院名称的索引值并赋值给实体类PlanBook里面的CollegeID字段

            plan.YearMonth    = DateTime.Now;
            plan.BookTotalNum = plan.StudentBookNum + plan.TeacherBookNum;

            return(plan);
        }
Exemplo n.º 2
0
        private void btnAddBook_Click(object sender, EventArgs e)
        {
            try
            {
                if (int.Parse(dgvStockInfo.CurrentRow.Cells[7].Value.ToString()) - int.Parse(txtNum.Text) < 0)
                {
                    MessageBox.Show("输入的数量大于库存数量");
                }
                else
                {
                    GetBook gb = new GetBook();
                    gb.GetBookNum     = int.Parse(txtNum.Text);
                    gb.ISBN           = txtISBN.Text;
                    gb.Signer         = txtSigner.Text;
                    gb.SignerPhone    = txtSignerPhone.Text;
                    gb.SignerIdentity = cmbIdentity.Text;

                    if (cmbIdentity.SelectedItem.ToString() == "学生代表")
                    {
                        StudentClass student = common.GetAllCollegeInfo_Class(cmbStudentClass.Text); //以下拉框班级的文本值作参数调用方法GetAllCollegeInfo_Class()并赋值给实体类
                        gb.MajorInfoID    = student.MajorInfoID;                                     //获取实体类StudentClass中的专业编号赋值给实体类PlanBook中的专业编号
                        gb.StudentClassID = student.StudentClassID;                                  //获取实体类StudentClass中的学院编号赋值给实体类PlanBook中的学院编号

                        gb.SchoolTermID = cmbSchoolTerm.SelectedIndex;                               //获取下拉框学年学期的索引值并赋值给实体类PlanBook里面的SchoolTermID字段
                        gb.CollegeID    = cmbCollege.SelectedIndex;                                  //获取下拉框学院名称的索引值并赋值给实体类PlanBook里面的CollegeID字段
                    }
                    else
                    {
                        gb.CollegeID      = 0;
                        gb.SchoolTermID   = 0;
                        gb.StudentClassID = 0;
                    }
                    bllgb.UpdateGetBook(gb);
                    DgvInfo();
                    text();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("请检查输入的值的类型是否正确");
                //throw;
            }
        }