You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/Import/DAL/GridPanelShow/GridPanelShowDAL.cs

117 lines
4.4 KiB
C#

2 years ago
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.Areas.Import.Models.GridPanelShow;
using Microsoft.Practices.EnterpriseLibrary.Data;
using HcUtility.Comm;
namespace DSWeb.Areas.Import.DAL.GridPanelShowDAL
{
public partial class GridPanelShowDAL
{
#region 合同基础信息列表
static public List<GridPanelShowmb> GetDataList(string USERID, string FORMNAME)
{ //合同信息/商品信息
var strSql = new StringBuilder();
strSql.Append(" select id,USERID,FORMNAME,DATAORDER,dataIndex,header,width,hidden,sortable ");
strSql.Append(" from IMPORT_TableCustomize ");
if (!string.IsNullOrEmpty(USERID))
{
strSql.Append(" where USERID='" + USERID + "' and FORMNAME='" + FORMNAME + "'");
}
else strSql.Append(" where USERID= '' ");
strSql.Append(" order by DATAORDER ");
return SetData(strSql);
}
private static List<GridPanelShowmb> SetData(StringBuilder strSql)
{
var headList = new List<GridPanelShowmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
GridPanelShowmb data = new GridPanelShowmb();
#region Set DB data to Object
data.id = Convert.ToString(reader["id"]);
//data.USERID = Convert.ToString(reader["USERID"]);
//data.FORMNAME = Convert.ToString(reader["FORMNAME"]);
data.DATAORDER = Convert.ToString(reader["DATAORDER"]);
data.dataIndex = Convert.ToString(reader["dataIndex"]);
data.header = Convert.ToString(reader["header"]);
data.width = Convert.ToString(reader["width"]);
data.hidden = Convert.ToString(reader["hidden"]);
data.sortable = Convert.ToString(reader["sortable"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
public static DBResult SaveDetail(List<GridPanelShowmb> bodyList, string userid,string formname)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
if (bodyList != null)
{
var cmddelete = db.GetSqlStringCommand(@"delete from IMPORT_TableCustomize where USERID='" + userid + "' and FORMNAME='"+formname+"'");
db.ExecuteNonQuery(cmddelete, tran);
foreach (var enumValue in bodyList)
{
var awidth = "0";
if (enumValue.width == "")
{
awidth = "100";
}
else awidth = enumValue.width;
var cmdInsert = db.GetSqlStringCommand(@"insert into IMPORT_TableCustomize (USERID,FORMNAME,DATAORDER,dataIndex,header,width,hidden,sortable) values ('" + userid + "','" + formname + "'," + enumValue.DATAORDER + ",'" + enumValue.dataIndex + "','" + enumValue.header + "'," + awidth + "," + enumValue.hidden + "," + enumValue.sortable + ")");
db.ExecuteNonQuery(cmdInsert, tran);
}
}
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "保存出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "保存成功" + result.Message;
return result;
}
#endregion
#region 明细部分
#endregion
#region 参照部分
#endregion
}
}