コード例 #1
0
        public StudentLoanInfo PopulateStudentLoanInfo(DataRow row)
        {
            StudentLoanInfo studentLoanInfo = new StudentLoanInfo();

            studentLoanInfo.ResourceID   = Convert.ToInt32(row["ResourceID"]);
            studentLoanInfo.Title        = row["Title"].ToString();
            studentLoanInfo.ResourceType = (ResourceType)row["Type"];
            studentLoanInfo.CheckOutDate = Convert.ToDateTime(row["CheckOutDate"]);
            studentLoanInfo.DueDate      = Convert.ToDateTime(row["DueDate"]);
            studentLoanInfo.ImagePath    = row["ImagePath"].ToString();
            studentLoanInfo.LoanID       = Convert.ToInt32(row["LoanID"]);
            studentLoanInfo.LoanStatus   = (LoanStatus)row["LoanStatus"];

            return(studentLoanInfo);
        }
コード例 #2
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            //by wygdove start
            UserAccountInfo accountinfo = new UserAccountInfo();

            using (var context = new BMS_DBEntities())
            {
                accountinfo.UAccountNumber = this.AccountId.Text;
                accountinfo.UName          = this.SName.Text;
                accountinfo.UPhone         = this.Phone.Text;
                accountinfo.Balance        = decimal.Parse(this.LoanAmount.Text);

                var q = from t in context.UserAccountInfoes
                        where t.UAccountNumber == accountinfo.UAccountNumber
                        select t;
                if (q.Count() == 0)
                {
                    CustomOperation.CreateLoan(accountinfo, "教学贷款");
                    context.SaveChanges();
                    context.Dispose();
                }
            }
            //by wygdove end

            //将贷款信息添置数据库
            using (var context = new BMS_DBEntities())
            {
                StudentLoanInfo student = new StudentLoanInfo()
                {
                    SlSchool        = this.School.Text,
                    SlInstitute     = this.Academy.Text,
                    SlProfession    = this.Major.Text,
                    SlAccountNumber = this.AccountId.Text
                };
                try
                {
                    context.StudentLoanInfoes.Add(student);
                    context.SaveChanges();
                    MessageBox.Show("贷款成功");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("贷款失败!" + ex.Message);
                }
            }
            this.Close();
        }