民工心事 发表于 2024-10-15 15:02:47

AppointmentController

目录
1、 AppointmentController
1.1、 预约安排
1.1.1、 //ViewBag:获取动态视图数据字典
1.1.2、 //无法获取session 重定向到登录界面 重新登录
1.2、 生成预约单号


[*] AppointmentController 
using QXQPS.Models;
using QXQPS.Vo;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace QXQPS.Areas.MechanicsManagment.Controllers
{
    public class AppointmentController : Controller
    {
        // GET: MechanicsManagment/Appointment
        Models.QXQPEntities myModels = new Models.QXQPEntities();

[*]
[*] 预约安排

        public ActionResult Appointment()//预约安排
        {
            try
            {
                ViewBag.UserName = Session["UserName"].ToString().Trim();

[*]
[*]
[*] //ViewBag:获取动态视图数据字典


                return View();
            }
            catch (Exception)
            {


[*]
[*]
[*]                //无法获取session 重定向到登录界面 重新登录


                return Redirect("/Home/Login");
            }
        }

[*]
[*] 生成预约单号

        public ActionResult PredateNum()//生成预约单号
        {
            string PredateNum = "";
            var date = DateTime.Now.ToString("yyyyMMdd");
            var datetime = DateTime.Now.ToString("yyyyMMddHHmmss");
            try
            {
                var list = myModels.PW_Predate.Where(m => m.PredateNum.Contains(date)).OrderBy(m=>m.PredateNum).ToList();
                if (list.Count != 0)
                {
                    int num = Convert.ToInt32(list.Last().PredateNum.Trim().Substring(15)) + 1;
                    if (num < 10)
                    {
                        PredateNum = "BJ" + datetime + "000" + num;
                    }
                    else if (num > 9 && num < 100)
                    {
                        PredateNum = "BJ" + datetime + "00" + num;
                    }
                    else if (num > 99 && num < 1000)
                    {
                        PredateNum = "BJ" + datetime + "0" + num;
                    }
                }
                else {
                    PredateNum = "BJ" + datetime + "0001";
                }
            }
            catch (Exception)
            {
                return Json(PredateNum, JsonRequestBehavior.AllowGet);
            }
            return Json(PredateNum, JsonRequestBehavior.AllowGet);
        }

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: AppointmentController