109 lines
4.4 KiB
C#
109 lines
4.4 KiB
C#
using Api.Framework;
|
|
using Api.Framework.Enums;
|
|
using Api.Framework.Model;
|
|
using Api.Framework.Tools;
|
|
using FLSystem.Events;
|
|
using FLSystem.Properties;
|
|
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 UI.Framework.Forms;
|
|
|
|
namespace FLSystem.Forms
|
|
{
|
|
public partial class group_info_form : BaseForm
|
|
{
|
|
string gid = string.Empty;
|
|
string gname = string.Empty;
|
|
public group_info_form(string gid = "", string gname = "")
|
|
{
|
|
InitializeComponent();
|
|
this.gid = gid;
|
|
this.gname = gname;
|
|
}
|
|
|
|
private void simpleButton2_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void simpleButton1_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrWhiteSpace(textEdit1.Text)) throw new Exception("请填写群昵称");
|
|
if (string.IsNullOrWhiteSpace(textEdit2.Text)) throw new Exception("请填写群账号");
|
|
if (textEdit2.Text.Length > 30) throw new Exception("填写的群账号不合法");
|
|
|
|
var session = ApiClient.GetSession();
|
|
|
|
if (!string.IsNullOrWhiteSpace(gid))
|
|
{
|
|
var adzone = session.FindSingle<fl_adzone_info>("select * from fl_adzone_info where group_id = @group_id and custom_type = @custom_type", new { group_id = gid, custom_type = Resources.GroupSoftwareType });
|
|
var pidInfos = session.Queryable<fl_adzone_info>().Where(f => f.group_id == gid && f.custom_type == Resources.GroupSoftwareType).ToList();
|
|
if (pidInfos != null)
|
|
{
|
|
foreach (var item in pidInfos)
|
|
{
|
|
item.group_id = textEdit2.Text.Trim();
|
|
item.extend = textEdit1.Text.Trim();
|
|
session.Updateable(item).ExecuteCommand();
|
|
}
|
|
}
|
|
ShowSuccess("修改成功");
|
|
}
|
|
else
|
|
{
|
|
var adzone = session.FindSingle<fl_adzone_info>("select * from fl_adzone_info where group_id = @group_id and custom_type = @custom_type", new { group_id = textEdit2.Text.Trim(), custom_type = Resources.GroupSoftwareType });
|
|
if (adzone != null) throw new Exception("群号已存在,操作无效");
|
|
//var strs = new string[] { "淘宝推广位名称", "拼多多推广位名称", "京东推广位名称" };
|
|
//var pidSortRemark = Enum.GetNames(typeof(GroupAdzoneType));//pid类别备注,值顺序不能变
|
|
|
|
var pidInfos = session.Queryable<fl_adzone_info>().Where(f => f.group_id == textEdit2.Text.Trim() && f.custom_type == Resources.GroupSoftwareType).ToList();
|
|
if (pidInfos != null && pidInfos.Count == 0)
|
|
{
|
|
for (int i = 1; i <= 3; i++)
|
|
{
|
|
var _adzone = new fl_adzone_info
|
|
{
|
|
custom_type = Resources.GroupSoftwareType,
|
|
extend = textEdit1.Text.Trim(),
|
|
alliance_id = i,
|
|
is_download = false,
|
|
member_id = 0,
|
|
onoff = false,
|
|
robot_id = 0,
|
|
group_id = textEdit2.Text.Trim(),
|
|
adzone_pid_cps_name = string.Empty,
|
|
adzone_pid = string.Empty,
|
|
adzone_name = string.Empty,
|
|
};
|
|
session.Saveable(_adzone).ExecuteReturnEntity();
|
|
}
|
|
}
|
|
ShowSuccess("增加成功");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ShowError(ex);
|
|
}
|
|
}
|
|
|
|
private void group_info_form_Load(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(gid))
|
|
{
|
|
textEdit2.Text = gid;
|
|
textEdit1.Text = gname;
|
|
}
|
|
}
|
|
}
|
|
}
|