79 lines
2.5 KiB
C#
79 lines
2.5 KiB
C#
|
using HandyControl.Controls;
|
|||
|
using Microsoft.Win32;
|
|||
|
using Newtonsoft.Json.Linq;
|
|||
|
using ryCommon;
|
|||
|
using ryCommonDb;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows;
|
|||
|
using System.Windows.Controls;
|
|||
|
using System.Windows.Data;
|
|||
|
using System.Windows.Documents;
|
|||
|
using System.Windows.Input;
|
|||
|
using System.Windows.Media;
|
|||
|
using System.Windows.Media.Imaging;
|
|||
|
using System.Windows.Shapes;
|
|||
|
|
|||
|
namespace LiveTools
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// FrmAddDirect.xaml 的交互逻辑
|
|||
|
/// </summary>
|
|||
|
public partial class FrmAddDirect : HandyControl.Controls.Window
|
|||
|
{
|
|||
|
public FrmAddDirect()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
CbbPlatform.Items.Add("抖音");
|
|||
|
CbbPlatform.SelectedIndex = 0;
|
|||
|
}
|
|||
|
public int SelectedId { get; set; } = 0;
|
|||
|
public string PicPath { get; set; } = "";
|
|||
|
public void GetInfo()
|
|||
|
{
|
|||
|
IDbInterface db = new SQLiteDataProvider();
|
|||
|
db.ConnDb(LiveTools.Config.DbFullPath);
|
|||
|
var ds = db.ReadData("select * from Direct where id=" + SelectedId);
|
|||
|
if (ds.HaveData())
|
|||
|
{
|
|||
|
var row = ds.GetRow(0);
|
|||
|
TxtName.Text = row["Name"].ToString();
|
|||
|
CbbPlatform.Text= row["Platform"].ToString();
|
|||
|
TxtDirectId.Text = row["DirectId"].ToString();
|
|||
|
}
|
|||
|
ds?.Dispose();
|
|||
|
db.Free();
|
|||
|
}
|
|||
|
private void BtnOK_Click(object sender, RoutedEventArgs e)
|
|||
|
{
|
|||
|
if (TxtName.Text.Length==0)
|
|||
|
{
|
|||
|
HandyControl.Controls.MessageBox.Show("请输入名称。", "提示");
|
|||
|
return;
|
|||
|
}
|
|||
|
IDbInterface db = new SQLiteDataProvider();
|
|||
|
db.ConnDb(Config.DbFullPath);
|
|||
|
ryCommonDb.RyQuickSQL mySQL = new ryCommonDb.RyQuickSQL("Direct");
|
|||
|
mySQL.AddField("Name", TxtName.Text);
|
|||
|
mySQL.AddField("Platform", CbbPlatform.Text);
|
|||
|
mySQL.AddField("DirectId", TxtDirectId.Text);
|
|||
|
mySQL.AddField("EditTime",DateTime.Now.ToInt64());
|
|||
|
if(SelectedId==-1 || db.Update(mySQL,"id="+ SelectedId)==0)
|
|||
|
{
|
|||
|
mySQL.AddField("AddTime", DateTime.Now.ToInt64());
|
|||
|
db.Insert(mySQL);
|
|||
|
}
|
|||
|
db.Free();
|
|||
|
DialogResult = true;
|
|||
|
}
|
|||
|
|
|||
|
private void BtnCancel_Click(object sender, RoutedEventArgs e)
|
|||
|
{
|
|||
|
DialogResult = false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|