目录
1、 PurchaseorderController
1.1、 采购订货
1.1.1、 //登录用户
1.2、 订单号
1.3、 供应商号
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.AccessoriessalesManagment.Controllers
{
public class PurchaseorderController : Controller
{
QXQPEntities myModels = new Models.QXQPEntities();
// GET: AccessoriessalesManagment/Purchaseorder
public ActionResult Purchaseorder()//采购订货
{
try
{
ViewBag.UserName = Session["UserName"].ToString().Trim();
return View();
}
catch (Exception)
{
return Redirect("/Home/Login");
}
}
public ActionResult MaintenanceNum()//订单号
{
string MaintenanceNum = "";
var date = "J" + DateTime.Now.ToString("yyyyMMdd");
try
{
var list = myModels.PW_Procurement.Where(m => m.IndentNumber.Contains(date)).OrderBy(m => m.IndentNumber).ToList();
if (list.Count != 0)
{
int num = Convert.ToInt32(list.Last().IndentNumber.Trim().Substring(9)) + 1;
if (num < 10)
{
MaintenanceNum = date + "000" + num;
}
else if (num > 9 && num < 100)
{
MaintenanceNum = date + "00" + num;
}
else if (num > 99 && num < 1000)
{
MaintenanceNum = date + "0" + num;
}
}
else
{
MaintenanceNum = date + "0001";
}
}
catch (Exception)
{
return Json("", JsonRequestBehavior.AllowGet);
}
return Json(MaintenanceNum, JsonRequestBehavior.AllowGet);
}
public ActionResult SuppliNum()//供应商号
{
string SuppliNum = "";
var date = "GYSH-" + DateTime.Now.ToString("yyyyMMdd")+"-";
try
{
var listxdas = myModels.SYS_Suppliers.Where(m => m.SuppliersFirm.Contains(date)).OrderBy(m => m.SuppliersFirm).ToList();
if (listxdas.Count != 0)
{
int num = Convert.ToInt32(listxdas.Last().SuppliersFirm.Trim().Substring(14)) + 1;
if (num < 10)
{
SuppliNum = date + "000" + num;
}
else if (num > 9 && num < 100)
{
SuppliNum = date + "00" + num;
}
else if (num > 99 && num < 1000)
{
SuppliNum = date + "0" + num;
}
}
else
{
SuppliNum = date + "0001";
}
}
catch (Exception)
{
return Json("", JsonRequestBehavior.AllowGet);
}
return Json(SuppliNum, JsonRequestBehavior.AllowGet);
}