ToB企服应用市场:ToB评测及商务社交产业平台

标题: AppointmentController [打印本页]

作者: 民工心事    时间: 2024-10-15 15:02
标题: AppointmentController
目录

1、 AppointmentController

1.1、 预约安排

1.1.1、 //ViewBag:获取动态视图数据字典

1.1.2、 //无法获取session 重定向到登录界面 重新登录

1.2、 生成预约单号


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();
                return View();
            }
            catch (Exception)
            {

                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企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4