You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
719 lines
28 KiB
719 lines
28 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using System.Data;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
namespace ICSSoft.Frame.Data.DAL
|
|
{
|
|
public class ICSPickingDAL
|
|
{
|
|
public static List<FormICSStorageUIModel> SearchStorageInfoList(string dsconn)
|
|
{
|
|
try
|
|
{
|
|
List<FormICSStorageUIModel> returns = new List<FormICSStorageUIModel>();
|
|
string sql = @"select [Serial],[StorageCode],[StorageName]
|
|
from [ICSStorage]";
|
|
sql = string.Format(sql);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
FormICSStorageUIModel smodel = new FormICSStorageUIModel();
|
|
smodel.Serial = dr["Serial"].ToString();
|
|
smodel.StorageCode = dr["StorageCode"].ToString();
|
|
smodel.StorageName = dr["StorageName"].ToString();
|
|
|
|
if (!returns.Contains(smodel))
|
|
returns.Add(smodel);
|
|
}
|
|
return returns;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static List<FormICSVendorUIModel> SearchVendorInfoList(string dsconn)
|
|
{
|
|
try
|
|
{
|
|
List<FormICSVendorUIModel> returnv = new List<FormICSVendorUIModel>();
|
|
string sql = @"select [ID],[VendorCode],[VendorName]
|
|
from [ICSVendor]";
|
|
sql = string.Format(sql);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
FormICSVendorUIModel vmodel = new FormICSVendorUIModel();
|
|
vmodel.ID = dr["ID"].ToString();
|
|
vmodel.VendorCode = dr["VendorCode"].ToString();
|
|
vmodel.VendorName = dr["VendorName"].ToString();
|
|
|
|
if (!returnv.Contains(vmodel))
|
|
returnv.Add(vmodel);
|
|
}
|
|
return returnv;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#region 新增和修改
|
|
|
|
public static string Add(List<FormICSPickingModel> INVInfoList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
string guid = "";
|
|
foreach (FormICSPickingModel info in INVInfoList)
|
|
{
|
|
bool isNew = false;
|
|
var line = db.ICSMaterial.SingleOrDefault(a => a.ID == info.ID);
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSMaterial();
|
|
line.ID = AppConfig.GetGuid();
|
|
line.VouchCode = info.VouchCode;
|
|
line.PickingSTATUS = "新建";
|
|
line.ISALLINSTORAGE = "N";
|
|
line.IsMROItem = info.IsMROItem;
|
|
line.AuditMan = info.AuditMan;
|
|
line.AuditTime = info.AuditTime;
|
|
|
|
line.IsMROItem = info.IsMROItem;
|
|
|
|
line.IsPickingOrBack = info.IsPickingOrBack;
|
|
|
|
guid = line.ID;
|
|
}
|
|
line.PickingTYPE = info.PickingTYPE;
|
|
|
|
//if (info.ven != null)
|
|
// line.VENDORCODE = info.ven.ID;
|
|
//else
|
|
// line.VENDORCODE = null;
|
|
|
|
line.MEMO = info.MEMO;
|
|
line.CreateTIME = info.CreateTIME;
|
|
line.CreateUSER = info.CreateUSER;
|
|
line.MUSER = AppConfig.UserId;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
line.AuditMan = info.AuditMan;
|
|
line.AuditTime = info.AuditTime;
|
|
line.PickingSTATUS = info.PickingSTATUS;
|
|
//20190708ZM
|
|
line.IsMROItem = info.IsMROItem;
|
|
line.IsPickingOrBack = info.IsPickingOrBack;
|
|
//line.OutCategory = info.OutCategory;
|
|
|
|
if (isNew)
|
|
{
|
|
db.ICSMaterial.InsertOnSubmit(line);
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
db.Transaction.Commit();
|
|
return guid;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增明细 MRO领料单
|
|
/// </summary>
|
|
public static string AddAndEditDetail(FormICSPickingModel Picking, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
bool isNew = false;
|
|
|
|
#region 201907705注释 ZM表头信息变更没有保存
|
|
//var line = db.ICSMaterial.SingleOrDefault(a => a.ID == Picking.ID);
|
|
//if (line == null)
|
|
//{
|
|
// isNew = true;
|
|
// line = new ICSMaterial();
|
|
// line.ID = AppConfig.GetGuid();
|
|
// line.VouchCode = Picking.VouchCode;
|
|
// line.PickingSTATUS = "新建";
|
|
// line.ISALLINSTORAGE = "N";
|
|
// line.CreateTIME = Picking.CreateTIME;
|
|
// line.CreateUSER = Picking.CreateUSER;
|
|
// line.MUSER = AppConfig.UserId;
|
|
// line.MUSERName = AppConfig.UserName;
|
|
// line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
|
|
// line.WorkPoint = AppConfig.WorkPointCode;
|
|
// line.IsMROItem = Picking.IsMROItem;
|
|
// line.AuditMan = Picking.AuditMan;
|
|
// line.AuditTime = Picking.AuditTime;
|
|
// line.MEMO = Picking.MEMO;
|
|
//}
|
|
#endregion
|
|
|
|
var line = db.ICSMaterial.SingleOrDefault(a => a.ID == Picking.ID);
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSMaterial();
|
|
line.ID = AppConfig.GetGuid();
|
|
}
|
|
line.VouchCode = Picking.VouchCode;
|
|
line.PickingSTATUS = "新建";
|
|
line.ISALLINSTORAGE = "N";
|
|
line.CreateTIME = Picking.CreateTIME;
|
|
line.CreateUSER = Picking.CreateUSER;
|
|
line.MUSER = AppConfig.UserId;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
line.IsMROItem = Picking.IsMROItem;
|
|
line.AuditMan = Picking.AuditMan;
|
|
line.AuditTime = Picking.AuditTime;
|
|
line.MEMO = Picking.MEMO;
|
|
line.IsPickingOrBack = Picking.IsPickingOrBack;
|
|
line.OutCategory = Picking.OutCategory;
|
|
line.VENDORCODE = Picking.VENDORCODE;
|
|
//line.IsMROItem = Picking.IsMROItem;
|
|
//line.IsPickingOrBack = Picking.IsPickingOrBack;
|
|
|
|
if (isNew)
|
|
{
|
|
db.ICSMaterial.InsertOnSubmit(line);
|
|
}
|
|
foreach (FormICSPickingDetailModel ICSMaterialPick in Picking.FormICSPickingDetail)
|
|
{
|
|
//20191111之前的
|
|
//var codes = db.ICSMaterialPick.Where(a => a.SubInvCode == ICSMaterialPick.SubInvCode && a.VouchCode == ICSMaterialPick.VouchCode && a.ID != Convert.ToInt32(ICSMaterialPick.ID));
|
|
//if (codes != null && codes.Count() > 0)
|
|
//{
|
|
// throw new Exception("该物料已存在,不能重复添加");
|
|
//}
|
|
//20191111修改
|
|
var codes = db.ICSMaterialPick.Where(a => a.SubInvCode == ICSMaterialPick.SubInvCode && a.VouchCode == ICSMaterialPick.VouchCode && a.ID != Convert.ToInt32(ICSMaterialPick.ID)&&a.VoucherNO==ICSMaterialPick.VoucherNO);
|
|
if (codes != null && codes.Count() > 0)
|
|
{
|
|
throw new Exception("该物料已存在,不能重复添加");
|
|
}
|
|
|
|
|
|
bool detailIsNew = false;
|
|
var detailLine = db.ICSMaterialPick.SingleOrDefault(a => a.ID == Convert.ToInt32(ICSMaterialPick.ID));
|
|
if (detailLine == null)
|
|
{
|
|
detailIsNew = true;
|
|
detailLine = new ICSMaterialPick();
|
|
}
|
|
detailLine.VoucherNO = ICSMaterialPick.VoucherNO;
|
|
detailLine.VouchRow = ICSMaterialPick.VouchRow;
|
|
detailLine.VouchCode = ICSMaterialPick.VouchCode;
|
|
detailLine.SubInvCode = ICSMaterialPick.SubInvCode;
|
|
detailLine.InvCode = ICSMaterialPick.SubInvCode;
|
|
detailLine.WHCode = ICSMaterialPick.WHCode;
|
|
detailLine.HasQuantity = 0;
|
|
detailLine.SupplyQuantity = ICSMaterialPick.SupplyQuantity;//20190911新增总单重
|
|
if (line.IsPickingOrBack == 3)
|
|
{
|
|
detailLine.MoveType = "退料";//"退料"; 退料单可能关联工单
|
|
detailLine.MOCode = ICSMaterialPick.MOCode;
|
|
detailLine.MORow = ICSMaterialPick.MORow;
|
|
|
|
}
|
|
else
|
|
{
|
|
detailLine.MoveType = "领料";//"领料不关联工单
|
|
//detailLine.MOCode = ICSMaterialPick.MOCode; //20190705ZM拿掉关联工单
|
|
//detailLine.MORow = ICSMaterialPick.MORow; //20190705ZM拿掉
|
|
detailLine.MOCode = "";
|
|
detailLine.MORow = "";
|
|
}
|
|
|
|
//detailLine.MOCode = ICSMaterialPick.MOCode; //20190705ZM拿掉关联工单
|
|
//detailLine.MORow = ICSMaterialPick.MORow; //20190705ZM拿掉
|
|
//detailLine.MOCode = "";
|
|
//detailLine.MORow = "";
|
|
detailLine.Quantity = Convert.ToDecimal(ICSMaterialPick.Quantity);//应退数量
|
|
//detailLine.HasQuantity = Convert.ToInt32(ICSMaterialPick.HasQuantity);//已退数量
|
|
//detailLine.MUSERName = AppConfig.UserName;//入库用户
|
|
detailLine.MUSER = AppConfig.UserCode;
|
|
detailLine.MUSERName = AppConfig.UserName;
|
|
detailLine.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
|
|
detailLine.VoucherDate = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
|
|
detailLine.WorkPoint = AppConfig.WorkPointCode;
|
|
detailLine.Remarks = ICSMaterialPick.Remarks;
|
|
detailLine.DDNo = ICSMaterialPick.DDNo;
|
|
//ZM增加部门、出库类型
|
|
detailLine.Dept = ICSMaterialPick.Dept;
|
|
detailLine.OutCategory = ICSMaterialPick.OutCategory;
|
|
detailLine.RDCode = ICSMaterialPick.RDCode;
|
|
|
|
if (detailIsNew)
|
|
{
|
|
db.ICSMaterialPick.InsertOnSubmit(detailLine);
|
|
}
|
|
}
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
return line.ID;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取领料单号
|
|
/// </summary>
|
|
/// <param name="dsconn"></param>
|
|
/// <returns></returns>
|
|
public static string GetOutInNo(string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
DateTime now = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
string date = now.Year.ToString() + (now.Month < 10 ? "0" + now.Month : now.Month.ToString()) + (now.Day < 10 ? "0" + now.Day : now.Day.ToString());
|
|
var ITEMLot = db.ICSMaterial.Where(a => a.VouchCode.Contains(date)).OrderByDescending(a => a.VouchCode);
|
|
string count = "001";
|
|
if (ITEMLot != null && ITEMLot.Count() > 0)
|
|
{
|
|
string VouchCode = ITEMLot.First().VouchCode;
|
|
count = (Convert.ToInt64(VouchCode) + 1).ToString().PadLeft(2, '0');
|
|
}
|
|
else
|
|
{
|
|
count = date + "001";
|
|
}
|
|
|
|
db.Connection.Close();
|
|
return count;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取领料单行号
|
|
/// </summary>
|
|
/// <param name="dsconn"></param>
|
|
/// <returns></returns>
|
|
public static string GetPickingRowNo(string VouchCode, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
string count = "1";
|
|
if (!string.IsNullOrWhiteSpace(VouchCode))
|
|
{
|
|
var ITEMLot = db.ICSMaterialPick.Where(a => a.VouchCode.Contains(VouchCode)).OrderByDescending(a => a.VouchRow);
|
|
if (ITEMLot != null && ITEMLot.Count() > 0)
|
|
{
|
|
count = (Convert.ToInt64(ITEMLot.First().VouchRow) + 1).ToString();
|
|
}
|
|
}
|
|
db.Connection.Close();
|
|
return count;
|
|
}
|
|
#endregion
|
|
|
|
#region 入库单代码是否存在
|
|
public static bool IsIncluding(string noCODE, string workpoint, string dsconn)
|
|
{
|
|
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSMaterial.SingleOrDefault(a => a.VouchCode == noCODE && a.WorkPoint == workpoint);
|
|
if (line == null)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 通过入库代码查询
|
|
public static List<FormICSPickingModel> SearchInfoByID(string Rguid, string dsconn)
|
|
{
|
|
List<FormICSPickingModel> INVR = new List<FormICSPickingModel>();
|
|
string sql = @"select DISTINCT(i.ID),
|
|
i.[VouchCode] as VouchCode,
|
|
j.WHCode,
|
|
i.MUSERName as MUSER,
|
|
j.Dept,
|
|
--j.OutCategory,
|
|
i.MEMO,
|
|
i.OutCategory,
|
|
i.IsMROItem,
|
|
i.IsPickingOrBack,
|
|
i.MTIME,j.RDCode,i.VENDORCODE
|
|
from ICSMaterial i
|
|
LEFT JOIN ICSMaterialPick j ON i.VouchCode=j.VouchCode
|
|
where i.ID='{0}'";
|
|
sql = string.Format(sql, Rguid);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
FormICSPickingModel returnInfo = new FormICSPickingModel();
|
|
returnInfo.WHCode = dr["WHCode"].ToString();
|
|
returnInfo.VouchCode = dr["VouchCode"].ToString();
|
|
returnInfo.MTIME = Convert.ToDateTime(dr["MTIME"].ToString());
|
|
returnInfo.MUSERName = dr["MUSER"].ToString();
|
|
//20190705 ZM
|
|
|
|
returnInfo.Dept = dr["Dept"].ToString();
|
|
returnInfo.OutCategory = dr["OutCategory"].ToString();
|
|
returnInfo.MEMO = dr["MEMO"].ToString();
|
|
returnInfo.IsMROItem = bool.Parse(dr["IsMROItem"].ToString());
|
|
returnInfo.RDCode = dr["RDCode"].ToString();
|
|
returnInfo.VENDORCODE = dr["VENDORCODE"].ToString();
|
|
if (!INVR.Contains(returnInfo))
|
|
{
|
|
INVR.Add(returnInfo);
|
|
}
|
|
}
|
|
//}
|
|
return INVR;
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
public static void deleteInfo(List<ICSMaterial> RIDList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
//foreach (ICSMaterial item2route in RIDList)
|
|
//{
|
|
// var lines = db.ICSMaterial.Where(a => a.VouchCode == item2route.VouchCode);
|
|
// db.ICSMaterial.DeleteAllOnSubmit(lines);
|
|
// db.SubmitChanges();
|
|
//}
|
|
//db.Transaction.Commit();
|
|
|
|
foreach (ICSMaterial item2route in RIDList)
|
|
{
|
|
var lines = db.ICSMaterial.Where(a => a.VouchCode == item2route.VouchCode);
|
|
var _lines = db.ICSMaterialPick.Where(a => a.VouchCode == item2route.VouchCode);
|
|
|
|
db.ICSMaterial.DeleteAllOnSubmit(lines);
|
|
db.ICSMaterialPick.DeleteAllOnSubmit(_lines);
|
|
|
|
db.SubmitChanges();
|
|
}
|
|
db.Transaction.Commit();
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除入库单明细
|
|
/// </summary>
|
|
/// <param name="RIDList"></param>
|
|
/// <param name="dsconn"></param>
|
|
public static void deleteDetailInfo(List<string> RIDList, string dsconn)
|
|
{
|
|
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSMaterialPick.Where(a => RIDList.Contains(a.ID.ToString()));
|
|
db.ICSMaterialPick.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static bool IsIncludingDetail(List<string> RIDList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
bool flag = false;
|
|
var lines = db.ICSMaterialPick.Where(a => RIDList.Contains(a.ID.ToString()));
|
|
if (lines.Count() != 0)
|
|
flag = true;
|
|
|
|
return flag;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 子件资料信息
|
|
public static DataTable GetDetail(string MoSql)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT
|
|
a.ID,
|
|
a.VouchCode,
|
|
A.VouchRow,
|
|
a.MOCODE,
|
|
a.MORow,
|
|
a.SubInvCode,
|
|
a.Quantity,
|
|
a.HasQuantity,
|
|
a.WHCode,
|
|
c.StorageName,
|
|
b.INVNAME,
|
|
b.INVSTD,
|
|
b.INVUOM,
|
|
a.MTIME,
|
|
a.MUSERName as MUSER,
|
|
a.VoucherNO as MoverCode, a.RDCode
|
|
FROM
|
|
ICSMaterialPick a
|
|
LEFT JOIN ICSINVENTORY b ON a.InvCode=b.INVCODE AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN ICSStorage c ON a.WHCode=c.StorageCode AND a.WorkPoint = c.WorkPoint
|
|
|
|
where VouchCode IN (SELECT a.VouchCode FROM(" + MoSql + ")a) AND a.WorkPoint ='" + AppConfig.WorkPointCode + @"'
|
|
order by VouchCode,VouchRow ";
|
|
sql = string.Format(sql);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static DataTable GetDetailList(string VouchCode)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT a.ID,'' as isSelect,
|
|
a.WHCode,
|
|
m.StorageName,
|
|
j.OutCategory,
|
|
k.cRdName,
|
|
a.Dept,
|
|
n.cDepName,
|
|
a.Remarks,
|
|
a.SupplyQuantity,
|
|
|
|
a.VouchCode,
|
|
a.VouchRow,
|
|
a.MOCode as MOCode,
|
|
a.MORow as MORow,
|
|
a.SubInvCode as cInvCode,
|
|
a.Quantity as iQuantity,
|
|
a.HasQuantity as HasQuantity,
|
|
b.INVNAME as cInvName,
|
|
b.INVSTD as cInvStd,
|
|
b.INVUOM as INVUOM,
|
|
a.MUSERName as cMaker,
|
|
a.MTIME as dDate,
|
|
a.VoucherNO as MoverCode, a.RDCode
|
|
FROM
|
|
ICSMaterialPick a
|
|
LEFT JOIN ICSINVENTORY b ON a.SubInvCode=b.INVCODE AND a.WorkPoint=b.WorkPoint
|
|
|
|
LEFT JOIN ICSMaterial j ON a.VouchCode=j.VouchCode
|
|
LEFT JOIN ICSRdStyle k ON k.cRdCode=j.OutCategory
|
|
LEFT JOIN ICSStorage m ON m.StorageCode=a.WHCode
|
|
LEFT JOIN ICSDepartment n ON n.cDepCode=a.Dept
|
|
|
|
where a.VouchCode = '{0}' AND a.WorkPoint ='" + AppConfig.WorkPointCode + @"'
|
|
order by VouchRow";
|
|
sql = string.Format(sql, VouchCode);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static DataTable GetDetailInfo(string id)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT a.ID,'' as isSelect,
|
|
a.WHCode,
|
|
c.OutCategory,
|
|
|
|
a.VoucherNO,--零件号
|
|
a.DDNo,--钉钉审核单号
|
|
a.Remarks,
|
|
a.VouchCode,
|
|
a.VouchRow,
|
|
a.SubInvCode as cInvCode,
|
|
a.Quantity iQuantity,
|
|
a.MOCode as MOCode,
|
|
a.MORow as MORow,
|
|
a.WHCode as iWHCode,
|
|
b.INVNAME cInvName,
|
|
b.INVSTD cInvStd,
|
|
b.INVUOM INVUOM,
|
|
a.MUSERName cMaker,
|
|
a.MTIME dDate,
|
|
a.SupplyQuantity,a.RDCode FROM
|
|
ICSMaterialPick a
|
|
LEFT JOIN ICSINVENTORY b ON a.SubInvCode=b.INVCODE AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN ICSMaterial c ON c.VouchCode=a.VouchCode AND c.WorkPoint=a.WorkPoint
|
|
|
|
where a.ID = '{0}' AND a.WorkPoint ='" + AppConfig.WorkPointCode + "'";
|
|
sql = string.Format(sql, id);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region MRO领料单审核
|
|
public static void Check(string id, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSMaterial.SingleOrDefault(a => a.ID == id);
|
|
line.PickingSTATUS = "已审核";
|
|
line.AuditMan = AppConfig.UserCode;
|
|
line.AuditTime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 弃审
|
|
public static void DiscardedTrialCheck(string id, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSMaterial.SingleOrDefault(a => a.ID == id);
|
|
line.PickingSTATUS = "新增";
|
|
line.AuditMan = null;
|
|
line.AuditTime = null;
|
|
//line.AuditMan = AppConfig.UserCode;
|
|
//line.AuditTime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
//RefuseCheck
|
|
|
|
|
|
#region 拒绝
|
|
public static void RefuseCheck(string id, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSMaterial.SingleOrDefault(a => a.ID == id);
|
|
line.PickingSTATUS = "拒绝";
|
|
line.AuditMan = AppConfig.UserCode;
|
|
line.AuditTime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 通过ID查询
|
|
public static DataTable searchInfoByID(string ID, string dsconn)
|
|
{
|
|
#region 原SQL
|
|
// string sql = @"
|
|
//SELECT A.ID, A.VouchCode, A.WHCode, A.PickingSTATUS, A.VENDORCODE, A.PickingTYPE, A.MEMO, A.CreateTIME,
|
|
//A.CreateUSER, A.WorkPoint, A.MUSER, A.MUSERName, A.MTIME, A.EATTRIBUTE1, A.ISALLINSTORAGE, A.AuditMan, A.AuditTime, B.HasQuantity
|
|
//FROM ICSMaterial A INNER JOIN ICSMaterialPick B ON A.VouchCode = B.VouchCode WHERE A.ID = '{0}' ";
|
|
#endregion
|
|
#region 现SQL
|
|
string sql = @"
|
|
SELECT A.ID, A.VouchCode, A.WHCode, A.PickingSTATUS, A.VENDORCODE, A.PickingTYPE, A.MEMO, A.CreateTIME,
|
|
A.CreateUSER, A.WorkPoint, A.MUSER, A.MUSERName, A.MTIME, A.EATTRIBUTE1, A.ISALLINSTORAGE,
|
|
A.AuditMan, A.AuditTime, SUM(ISNULL(B.HasQuantity, 0)) HasQuantity
|
|
FROM ICSMaterial A INNER JOIN ICSMaterialPick B ON A.VouchCode = B.VouchCode WHERE A.ID = '{0}'
|
|
GROUP BY A.ID, A.VouchCode, A.WHCode, A.PickingSTATUS, A.VENDORCODE, A.PickingTYPE, A.MEMO, A.CreateTIME,
|
|
A.CreateUSER, A.WorkPoint, A.MUSER, A.MUSERName, A.MTIME, A.EATTRIBUTE1, A.ISALLINSTORAGE,
|
|
A.AuditMan, A.AuditTime ORDER BY A.VouchCode ";
|
|
#endregion
|
|
sql = string.Format(sql, ID);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|