using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace NewMyFormDesigner
{
public partial class RunForm : Form
{
public string FrmKey { get; set; }
public string SQL { get; set; }
public string DllCoid { get; set; }
public int Modtype { get; set; }
public RunForm()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
string msg = string.Empty;
int rValue = RebirthInterface(DllCoid, 2, out msg);
if (rValue == 1)
{
DataTable dt = SqlHelper.ExecuteDataTable("select * from p_systemControlLocation where formkey='" + FrmKey + "'");
foreach (DataRow row in dt.Rows)
{
string fieldid = row["fieldid"].ToString();
string username = row["username"].ToString();
string fieldtypeid = row["fieldtypeid"].ToString();
string fieldname = row["fieldname"].ToString();
string defaultValue = row["defaultValue"].ToString();
Control ctr = ControlHelper.CreateControl(username, fieldname, Convert.ToInt32(fieldtypeid));
int posX = Convert.ToInt32(row["controlLeft"]);
int posY = Convert.ToInt32(row["controlTop"]);
int width = Convert.ToInt32(row["controlWidth"]);
int height = Convert.ToInt32(row["controlHeight"]);
ctr.Location = (new Point(posX, posY));//屏幕坐标转换成控件容器坐标
ctr.Width = width;
ctr.Height = height;
ctr.Tag = new string[] { fieldid, username, fieldtypeid, fieldname, defaultValue };
ctr.Parent = this;
}
}
else
{
MessageBox.Show(msg);
}
}
///
/// 执行保存时候的存储过程
///
///
///
///
///
public int RebirthInterface(string modid, int operType, out string msg)
{
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
pMsg.Direction = ParameterDirection.Output;
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
returnValue.Direction = ParameterDirection.ReturnValue;
SqlParameter[] param =
{
new SqlParameter("@modid",SqlDbType.VarChar,100),
new SqlParameter("@modtype",SqlDbType.Int),
new SqlParameter("@operType",SqlDbType.Int),
pMsg,
returnValue
};
param[0].Value = modid;
param[1].Value = Modtype;
param[2].Value = operType;
param[3].Value = "";
SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "[P_System_AUTOCreateMod]", param);
msg = pMsg.Value + "";
return Convert.ToInt32(returnValue.Value.ToString());
}
private void simpleButton1_Click(object sender, EventArgs e)
{
string connectionStr = @"Server=222.179.101.22\sql2008;Database=lserpVP;Persist Security Info=True;User ID=lserpAdmin;Password=lserp110";
SqlConnection conn = new SqlConnection(connectionStr);
conn.Open();
}
}
}