using GameBackup3H3.DbOp; using ryCommon; using ryCommonDb; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using 开发辅助工具.Manager; namespace 开发辅助工具.Manager.Site { public partial class FrmAddSite : Form { public string tableName = "Site"; public int isAdd = 1; public string selectId = "-1"; public FrmAddSite() { InitializeComponent(); } public void GetInfo(string id) { selectId = id; IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1) { DataSet ds = db.ReadData(tableName, id); if (ds.HaveData()) { DataRow reader = ds.Tables[0].Rows[0]; #region 读取信息 var ftpid = reader["ftpId"].ToInt(); var ds_ftp = db.ReadData("select * from Ftp where id="+ftpid); if (ds_ftp.HaveData()) { DtFtp.Text = ds_ftp.GetRow(0)["name"].ToString(); } else { DtFtp.Text = "无"; } TxtName.Text = reader["name"].ToString(); TxtLocalPath.Text = reader["localPath"].ToString(); DtFtp.selectId = reader["ftpId"].ToString(); TxtFtpDir.Text = reader["ftpDir"].ToString(); #endregion } ds.Dispose(); } db.Free(); } private void BtnOK_Click(object sender, EventArgs e) { if (TxtName.Text == "") { MessageBox.Show("名称不能为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!System.IO.Directory.Exists(TxtLocalPath.Text)) { MessageBox.Show("本地路径不存在。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } RyQuickSQL mySQL = new RyQuickSQL(tableName); mySQL.AddField("name", TxtName.Text); mySQL.AddField("localPath", TxtLocalPath.Text.Trim('\\')); mySQL.AddField("ftpId",DtFtp.selectId.ToInt()); mySQL.AddField("ftpDir", TxtFtpDir.Text); //DataProvider mydb = new DataProvider(); IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1) { if (isAdd >= 1) { mySQL.AddField("addTime", DateTime.Now); mySQL.AddField("editTime", DateTime.Now); db.ExecuteNonQuery(mySQL.GetInsertSQL(), db.GetParameter(mySQL)); } else { mySQL.AddField("editTime", DateTime.Now); db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + selectId, db.GetParameter(mySQL)); } } db.Free(); DialogResult = DialogResult.OK; } private void BtnCancel_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; } private void BtnBrowserFolder_Click(object sender, EventArgs e) { if(folderBrowserDialog1.ShowDialog()==DialogResult.OK) { TxtLocalPath.Text = folderBrowserDialog1.SelectedPath; } } private void DtFtp_OnSelected(object sender, EventArgs e) { FrmFTPView frm = new FrmFTPView { SelectModeOn = true }; if (frm.ShowDialog()==DialogResult.OK) { DtFtp.selectId = frm.SelectedItem.Id.ToString(); DtFtp.Text = frm.SelectedItem.Name; } } private void BtnClearFtp_Click(object sender, EventArgs e) { DtFtp.selectId = "-1"; DtFtp.Text ="无"; } } }