SVN r1123

SVN-Revision: r1123
This commit is contained in:
tdx
2026-02-25 06:32:40 +00:00
parent d564f77ee0
commit fcf7cf8d16
@@ -286,10 +286,7 @@ namespace Lskj.Control.Model
MessageUtil.Show(string.Format(ResourceKeys.ExecRightMenuOnlyOne, model.MenuName));
return;
}
if (model.AllowNullExec && rowArray.Length == 0)
{
rowArray = new DataRow[] { new DataTable().NewRow() };
}
if (rowArray.Length == 0 && model.IsMustSelectRow())
{
MessageUtil.Show(ResourceKeys.SelectRowIsNull);
@@ -687,12 +684,7 @@ namespace Lskj.Control.Model
return resultValue;
}
/// <summary>
/// 导入数据或者反写到界面
/// </summary>
/// <param name="model"></param>
/// <param name="paramList"></param>
/// <returns></returns>
public bool OpenFrmcCover(GridRightMenuModel model, List<string> paramList)
{
@@ -727,33 +719,7 @@ namespace Lskj.Control.Model
//外部数据
DataTable table = GetDataTable();
// 提取 ReverseData 中所有的主键值
HashSet<object> reversePrimaryKeys = new HashSet<object>(
ReverseData.AsEnumerable()
.Select(dr => dr[primaryKey])
.Where(val => val != DBNull.Value && val != null)
);
// 获取table中,没有更新的行(在ReverseData中没有对应主键)
IEnumerable<DataRow> noUpdateRows = table.AsEnumerable()
.Where(dr => dr[primaryKey] != DBNull.Value && dr[primaryKey] != null
&& !reversePrimaryKeys.Contains(dr[primaryKey]));
//提示存在没有更新的行
if (noUpdateRows.Any())
{
// 提示没有反写的数据
string noUpdateIds = string.Join("、", noUpdateRows.Select(dr => dr[primaryKey].ToString()));
string text = string.Format("有 {0} 条数据未更新,主键为:{1} \r\n请确认是否要继续", noUpdateRows.Count(), noUpdateIds);
DialogResult result = MessageUtil.Show(text, MessageBoxButtons.YesNo);
if (result != DialogResult.Yes)
{
return false;
}
}
//筛选出 ReverseData 和 table 中名称和数据类型都相同的列(排除主键列,避免重复赋值)
// 2. 筛选出 ReverseData 和 table 中名称和数据类型都相同的列(排除主键列,避免重复赋值)
var commonColumns = ReverseData.Columns.Cast<DataColumn>()
.Where(col1 => col1.ColumnName != primaryKey // 跳过 id 列(无需更新)
&& table.Columns.Contains(col1.ColumnName) // 列名存在于 table2
@@ -937,7 +903,7 @@ namespace Lskj.Control.Model
MessageUtil.Show(Message, sex.Message);
return false;
}
catch (Exception)
catch (Exception ex)
{
result = 0;
if (result == 0)
@@ -955,7 +921,8 @@ namespace Lskj.Control.Model
}
}
int rValue = Convert.ToInt32(returnValue.Value);
int.TryParse(returnValue.Value + "", out int rValue);
switch (rValue)
{
@@ -2059,4 +2026,28 @@ namespace Lskj.Control.Model
DataRow[] dataRows = columnsTab.Select().Where(n => (n["name"] + "").Equals(colunmField.Key)).ToArray();
if (dataRows.Length == 0)
{
string a
string addColSql = string.Format("alter table P_PrivateDllTab add {0} {1}", colunmField.Key, colunmField.Value);
SqlHelper.ExecuteNonQuery(addColSql);//添加列
}
}
}
else
{
string createTabSql = "create table P_PrivateDllTab(id int IDENTITY(1,1) NOT NULL,{0})";
string createCol = string.Empty;
foreach (KeyValuePair<string, string> colunmField in colDic)
{
createCol += string.Format("{0} {1},", colunmField.Key, colunmField.Value);
}
createTabSql = string.Format(createTabSql, createCol.TrimEnd(','));
SqlHelper.ExecuteNonQuery(createTabSql);//创建表
}
return true;
}
catch (Exception)
{
return false;
}
}
}
}