using DBUtility;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Net;
|
using System.Net.Http;
|
using System.Web.Http;
|
using WebAPI.Models;
|
|
namespace WebAPI.Controllers.SBGL
|
{
|
public class Gy_EquipTypeController : ApiController
|
{
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
|
private json objJsonResult = new json();
|
public DataSet ds = new DataSet();
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
public DLL.ClsGy_EquipTypeBill BillNew0 = new DLL.ClsGy_EquipTypeBill(); //模具报废入库对应单据类
|
public DLL.ClsGy_EquipTypeBill BillOld0 = new DLL.ClsGy_EquipTypeBill(); //模具报废入库对应单据类
|
|
#region 设备分类列表
|
|
[Route("Gy_EquipType/GetList")]
|
[HttpGet]
|
public object GetList(string sWhere)
|
{
|
try
|
{
|
ds = Sc_GetEquipTypeList(sWhere);
|
if (ds == null)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "查询数据异常,请与管理员联系!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "返回记录成功!";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "查询数据异常,请与管理员联系!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
public static DataSet Sc_GetEquipTypeList(string sWhere)
|
{
|
string sql1 = string.Format(@"select * from h_v_Gy_EquipTypeList");
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
return new SQLHelper.ClsCN().RunProcReturn(sql1 + sWhere + " order by HItemID desc", "h_v_Gy_EquipTypeList");
|
}
|
else
|
{
|
string sql = sql1 + sWhere + " order by HItemID desc";
|
return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Gy_EquipTypeList");
|
}
|
|
}
|
|
#endregion
|
|
#region [设备分类删除功能]
|
[Route("Gy_EquipType/Delete_EquipType")]
|
[HttpGet]
|
public object Delete_EquipType(string HItemID)
|
{
|
string s = "";
|
Int64 lngBillKey = 0;
|
lngBillKey = DBUtility.ClsPub.isLong(HItemID);
|
if (lngBillKey == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据ID为空!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
DLL.ClsGy_EquipTypeBill oBill = new DLL.ClsGy_EquipTypeBill();
|
if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
bool IsDete = oBill.DeleteBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo);
|
if (IsDete)
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未找到";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
#endregion
|
|
#region 设备分类保存/编辑
|
[Route("Gy_EquipType/SaveEquipTypeList")]
|
[HttpPost]
|
public object SaveEquipTypeList([FromBody] JObject msg)
|
{
|
var _value = msg["msg"].ToString();
|
string msg1 = _value.ToString();
|
string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string msg2 = sArray[0].ToString();
|
string refSav = sArray[1].ToString();
|
|
ListModels oListModels = new ListModels();
|
try
|
{
|
DLL.ClsGy_EquipTypeBill oBill = new DLL.ClsGy_EquipTypeBill();
|
List<Models.ClsGy_EquipFileType> lsmain = new List<Models.ClsGy_EquipFileType>();
|
msg2 = msg2.Replace("\\", "");
|
msg2 = msg2.Replace("\n", ""); //\n
|
lsmain = oListModels.getObjectByJson_Gy_EquipFileType(msg2);
|
|
long HItemID = lsmain[0].HItemID;
|
string HNumber = lsmain[0].HNumber;
|
string HName = lsmain[0].HName;
|
string HShortNumber = lsmain[0].HNumber;
|
long HParentID = lsmain[0].HParentID;
|
long HLevel = lsmain[0].HLevel;
|
string HHelpCode = lsmain[0].HHelpCode;
|
string HRemark = lsmain[0].HRemark;
|
bool HStopflag = lsmain[0].HStopflag;
|
string HUseFlag = lsmain[0].HUseFlag;
|
bool HEndFlag = lsmain[0].HEndFlag;
|
|
if (refSav == "Add")
|
{
|
//若MAINDI重复则重新获取
|
oCN.BeginTran();
|
//主表
|
oCN.RunProc("Insert into Gy_EquipFileType " +
|
" (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
|
",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime) " +
|
" Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID +
|
"," + HLevel + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "',getdate())", ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
oCN.RunProc("Update Gy_EquipFileType set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCN.Commit();
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "新增成功!";
|
//objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (refSav == "Update")
|
{
|
oCN.BeginTran();
|
//主表
|
oCN.RunProc("Update Gy_EquipFileType set " +
|
" HNumber='" + HNumber + "'" +
|
",HName='" + HName + "'" +
|
",HShortNumber='" +HShortNumber + "'" +
|
",HHelpCode='" + HHelpCode + "'" +
|
",HParentID=" + HParentID +
|
",HStopflag='" + HStopflag + "'" +
|
",HRemark= '" + HRemark + "' Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改子项目代码
|
//oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_RepairCheck,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo);
|
//将上级 为非末级
|
oCN.RunProc("Update Gy_EquipFileType set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
//
|
oCN.Commit();
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "修改成功!";
|
//objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + e.ToString();
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
return false;
|
}
|
#endregion
|
|
#region[设备分类编辑时获取表头数据]
|
[Route("Gy_EquipType/Gy_EquipTypeCheckDetai")]
|
[HttpGet]
|
public object Gy_EquipTypeCheckDetai(long HInterID)
|
{
|
try
|
{
|
ds = oCN.RunProcReturn("select * from Gy_EquipFileType where HItemID=" + HInterID, "Gy_EquipFileType");
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
}
|
}
|