コード例 #1
0
        public BookTicketInfoExModel getByIdAndTypes1(int id)
        {
            string       sql = @"SELECT bti.Id
                                ,TrainNumber
                                ,StartStation
                                ,EndStation
                                ,BookDate
                                ,StudentId
                                ,Phone
                                ,Remark
	                            ,TicketSate
                            FROM dbo.BookTicketInfo bti
                            INNER JOIN dbo.BookTicketState bts
                            ON bti.Id = bts.BookTicketInfoId
                            INNER JOIN dbo.Student s
                            ON bti.StudentId = s.Id
                            INNER JOIN dbo.SysRole sr
                            ON s.RoleId = sr.RoleId
                            WHERE Types = 1
                            AND bti.Id = @Id";
            SqlParameter par = new SqlParameter("@Id", SqlDbType.Int);

            par.Value = id;
            BookTicketInfoExModel model = null;
            DataTable             dt    = MSSQL.query(sql, par);

            if (dt.Rows.Count > 0)
            {
                model = Utils.dataTable2List <BookTicketInfoExModel>(dt)[0];
            }
            return(model);
        }
コード例 #2
0
ファイル: ApplyBookTicket.aspx.cs プロジェクト: yiyungent/TOS
        protected void btnSave_Click(object sender, EventArgs e)
        {
            this.model              = new BookTicketInfoExModel();
            this.model.TrainNumber  = this.txtTrainNumber.Text.Trim();
            this.model.StartStation = this.txtStartStation.Text.Trim();
            this.model.EndStation   = this.txtEndStation.Text.Trim();
            if (DateTime.TryParse(this.txtBookDate.Text.Trim(), out DateTime bookDate))
            {
                this.model.BookDate = bookDate;
            }
            else
            {
                this.Message = "预定日期格式不正确";
                return;
            }
            this.model.Phone  = this.txtPhone.Text.Trim();
            this.model.Remark = this.txtRemark.Text.Trim();

            if (Request["type"] == "add")
            {
                // 新增
                // 获取当前登录账户
                VwUserModel vwUserModel = (VwUserModel)Session["User"];
                // 当前登录学生的票,所以该页面只允许普通学生或学生管理员登录
                model.StudentId = vwUserModel.Id;
                // 最后的操作人这里也算作 该申请学生
                if (bookTicketInfoBll.bookTicket(model, vwUserModel.Id))
                {
                    this.Message = "订票成功";
                    initControl();
                }
                else
                {
                    this.Message = "订票失败";
                }
            }
            else if (Request["type"] == "edit")
            {
                // 编辑
                this.model.Id = Convert.ToInt32(Request["id"]);
                if (bookTicketInfoBll.editModel(model) > 0)
                {
                    Response.Redirect("BookTicketList.aspx");
                }
                else
                {
                    this.Message = "修改失败,请稍后再试";
                }
            }
        }
コード例 #3
0
ファイル: ApplyBookTicket.aspx.cs プロジェクト: yiyungent/TOS
 private void loadBookTicketInfo(int id)
 {
     this.model = this.bookTicketInfoBll.getByIdAndTypes1(id);
     if (model != null)
     {
         this.txtTrainNumber.Text  = this.model.TrainNumber;
         this.txtStartStation.Text = this.model.StartStation;
         this.txtEndStation.Text   = this.model.EndStation;
         this.txtBookDate.Text     = this.model.BookDate.ToString("yyyy-MM-dd");
         this.txtPhone.Text        = this.model.Phone;
         this.txtRemark.Text       = this.model.Remark;
         this.txtState.Text        = this.model.TicketSate.ToString();
     }
     else
     {
         this.Message = "不存在此普通学生及学生管理员";
     }
 }