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.
68 lines
2.6 KiB
C#
68 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Controls.Base;
|
|
using System.Windows.Forms;
|
|
using Mesnac.Codd.Session;
|
|
|
|
namespace Mesnac.Action.Default.SynchroData
|
|
{
|
|
public class Delete : DatabaseAction, IAction
|
|
{
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
if (MessageBox.Show(Language(7), Language(1), MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
|
{
|
|
return;
|
|
}
|
|
base.RunIni(runtime); //必须调用
|
|
|
|
ShowMsg(Language(0));
|
|
foreach (DbMCSource dbsource in GetAllDbMCSources())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(dbsource.DesignSource) ||
|
|
string.IsNullOrWhiteSpace(dbsource.DataTable.ToString()))
|
|
{
|
|
continue;
|
|
}
|
|
string source = dbsource.DesignSource;
|
|
string table = dbsource.DataTable;
|
|
DbHelper dbHelper = NewDbHelper(source);
|
|
if (dbHelper == null)
|
|
{
|
|
continue;
|
|
}
|
|
dbHelper.ClearParameter();
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
DbMCControlDesignKeyConfig config = new DbMCControlDesignKeyConfig();
|
|
List<DbMCControl> objidcontrols = GetDbMCControlByKey(config.ToString(new string[] { source, table, "ObjID" }));
|
|
foreach (DbMCControl control in objidcontrols)
|
|
{
|
|
if (control.BaseControl.MCValue == null ||
|
|
string.IsNullOrWhiteSpace(control.BaseControl.MCValue.ToString()))
|
|
{
|
|
continue;
|
|
}
|
|
if ((base.DbOptionTypesIsModify(control.BaseControl)))
|
|
{
|
|
string objid = control.BaseControl.MCValue.ToString();
|
|
string sqlstr = "DELETE FROM [" + table + "] WHERE ObjID=" + objid;
|
|
if (dbHelper.DbSession.ProviderFactory.GetType().FullName.Contains("OracleClientFactory"))
|
|
{
|
|
sqlstr = "DELETE FROM " + table + " WHERE ObjID=" + objid;
|
|
}
|
|
dbHelper.ClearParameter();
|
|
dbHelper.CommandText = sqlstr;
|
|
dbHelper.ExecuteNonQuery();
|
|
ShowMsg(Language(8));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|