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.
 
 
 
 
 

142 lines
5.7 KiB

using Newtonsoft.Json;
using NFine.Code;
using NFine.Domain._03_Entity.SystemManage;
using NFine.Domain.Entity.SystemManage;
using NFine.Domain.IRepository.SystemManage;
using NFine.Repository;
using NFine.Repository.SystemManage;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace NFine.Application.SystemManage
{
public class ModuleApp : RepositoryFactory<ModuleEntity>
{
private IModuleRepository service = new ModuleRepository();
public List<ModuleEntity> GetList()
{
return service.IQueryable().Where(a => a.systems == "WMS").OrderBy(t => t.F_SortCode).ToList();
}
public List<ModuleEntity> GetListALL()
{
return service.IQueryable().Where(a => a.systems == "WMS" || a.systems == "SRM").OrderBy(t => t.F_SortCode).ToList();
}
public ModuleEntity GetForm(string keyValue)
{
return service.FindEntity(keyValue);
}
public void DeleteForm(string keyValue)
{
if (service.IQueryable().Count(t => t.F_ParentId.Equals(keyValue)) > 0)
{
throw new Exception("删除失败!操作的对象包含了下级数据。");
}
else
{
service.Delete(t => t.F_Id == keyValue);
}
}
public void SubmitForm(ModuleEntity moduleEntity, string keyValue)
{
if (!string.IsNullOrEmpty(keyValue))
{
moduleEntity.Modify(keyValue);
service.Update(moduleEntity);
}
else
{
moduleEntity.systems = "WMS";
moduleEntity.Create();
service.Insert(moduleEntity);
}
}
public DataTable GetCondition(string SourceID)
{
string sql = @" SELECT con.ID IDStr, '0' IsNew, CSortSeq 排序,CCaption 条件名称,CFiledName 字段名称,CIndex 替代符号
,CValueBegin 默认值,CValueEnd 默认值2,CValueBegin 起始值,CValueEnd 结束值,CDataType AS 数据类型,CDataType AS 数据类型Data
from Sys_FormDataAction con
where con.SourceID='" + SourceID + @"' order by CSortSeq";
return Repository().FindTableBySql(sql);
}
public void SetDataAction(string SourceID, string List_Condition)
{
OperatorModel oo = NFine.Code.OperatorProvider.Provider.GetCurrent();
if (!string.IsNullOrEmpty(List_Condition) && List_Condition != "[]")
{
DataActionClass[] list = JsonConvert.DeserializeObject<DataActionClass[]>(List_Condition);
if (list != null)
{
string sql = "";
string sqldel = "";
string sqldel2 = "";
string sqlinsert = "";
string sqlupdate = "";
//@" delete from Sys_FormFilterCondition where SourceID='" + SourceID + @"' ";
foreach (DataActionClass item in list)
{
if (item.ID == "")//insert
{
sqlinsert += @" INSERT INTO [Sys_FormDataAction]
([ID],[SourceID],[CSortSeq],[CCaption],[CFiledName],
[CIndex],[CLogString],[CValueBegin],[CValueEnd],[CDataType])
select newid(),'" + SourceID + "','" + item.CSortSeq + "','" + item.CCaption + "','" + item.CFiledName + @"'
,'" + item.CIndex + @"','" + item.CLogString + @"'
,'" + item.CValueBegin + "','" + item.CValueEnd + "','" + item.CDataType + "' ";
}
else//update
{
sqlupdate += @" update [Sys_FormDataAction]
set
[CSortSeq]=" + item.CSortSeq + @",
[CCaption]='" + item.CCaption + @"',
[CFiledName]='" + ReSetStringTosql(item.CFiledName) + @"',
[CIndex]='" + item.CIndex + @"',
[CLogString]='" + item.CLogString + @"',
[CValueBegin]='" + item.CValueBegin + @"',
[CValueEnd]='" + item.CValueEnd + @"',
[CDataType]='" + item.CDataType + @"'
where id = '" + item.ID + "' and SourceID = '" + SourceID + @"'
";
sqldel += " and ID!='" + item.ID + "' ";
}
}
sql = @" delete from Sys_FormDataAction where SourceID = '" + SourceID + @"' " +
sqldel + sqlupdate + sqlinsert;
StringBuilder sqlb = new StringBuilder(sql);
Repository().ExecuteBySql(sqlb);
}
}
else
{
string sql = @" delete from Sys_FormDataAction where SourceID='" + SourceID + @"'";
StringBuilder sqlb = new StringBuilder(sql);
Repository().ExecuteBySql(sqlb);
}
}
private string ReSetStringTosql(string sql)
{
sql = sql.Replace("'", "''");
sql = sql.Replace("\r", "\r ");
sql = sql.Replace("\r\n", "\r\n ");
sql = sql.Replace("\n", "\n ");
return sql;
}
}
}