目录
1、 SalescustomerController
1.1、 /// 修改
1.2、 /// 新增
1.2.1、 //判断销售客户表中是否已经存在新增的销售客户信息
using QXQPS.Models;
using QXQPS.Vo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace QXQPS.Areas.BasicdataManagment.Controllers
{
public class SalescustomerController : Controller
{
// GET: BasicdataManagment/Salescustomer
Models.QXQPEntities myModels = new Models.QXQPEntities();
-
- /// 修改
/// </summary>
/// <param name="SalesCustomerID"></param>
/// <returns></returns>
public ActionResult SelectSale(int SalesCustomerID)
{
var list = myModels.SYS_SalesCustomer.Where(m => m.SalesCustomerID == SalesCustomerID).Select(m => new
{
SalesCustomerID = m.SalesCustomerID,
RegionID = m.RegionID,
CustomerCode = m.CustomerCode,
CustomerName = m.CustomerName,
CustomerSouID = m.CustomerSouID,
Address = m.Address,
ZipCode = m.ZipCode,
FullName = m.FullName,
PinYinCode = m.PinYinCode,
IdNumber = m.IdNumber,
Contacts = m.Contacts,
Facsimile = m.Facsimile,
TelePhone = m.TelePhone,
MobilePhone = m.MobilePhone,
Emai = m.Emai,
CustomerLevelID = m.CustomerLevelID,
CustomerTypeID = m.CustomerTypeID,
PaymentID = m.PaymentID,
Remark = m.Remark,
UserID = m.UserID,
InputPerson = m.InputPerson,
ToDeactivate = m.ToDeactivate,
});
return Json(list, JsonRequestBehavior.AllowGet);
}
-
- /// 新增
/// </summary>
/// <param name="Sales"></param>
/// <returns></returns>
public ActionResult InsertSales(SYS_SalesCustomer Sales)
{
string strMsg = "failed";
try
{
-
-
- //判断销售客户表中是否已经存在新增的销售客户信息
-
var SalesCount = (from tbSales in myModels.SYS_SalesCustomer
where tbSales.SalesCustomerID == Sales.SalesCustomerID ||
tbSales.IdNumber == Sales.IdNumber
select tbSales).Count();
if (SalesCount == 0)
{
if (Sales.CustomerName != null)
{
if (Sales.IdNumber != null)
{
if (Sales.CustomerCode != null)
{
myModels.SYS_SalesCustomer.Add(Sales);
myModels.SaveChanges();
strMsg = "success";
}
else
{
strMsg = "编号不能为空,请输入完整信息";
}
}
else
{
strMsg = "身份证不能为空,请输入完整信息";
}
}
else
{
strMsg = "客户名称不能为空,请输入完整信息";
}
}
else
{
strMsg = "该销售客户信息已经存在,不需要重复输入数据!";
}
}
catch (Exception e)
{
strMsg = "failed";
}
return Json(strMsg, JsonRequestBehavior.AllowGet);
}
/// <summary>