using Api.Framework;
using Api.Framework.Cps;
using Api.Framework.Enums;
using Api.Framework.Model;
using Api.Framework.Tools;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
using FLSystem.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows.Forms;
using UI.Framework.Controls;
using UI.Framework.Forms;
namespace FLSystem.Forms
{
public partial class setting_system_control : DevExpress.XtraEditors.XtraUserControl
{
public setting_system_control()
{
InitializeComponent();
this.tabPane1.SelectedPageIndex = 0;
//tabNavigationPage4.PageVisible = tabNavigationPage5.PageVisible = Util.ShowTgwz();
tabNavigationPage4.PageVisible = Util.ShowTgwz();
}
#region 临时类
///
/// 临时类,显示用
///
class view_fl_member_group : fl_member_group
{
[Browsable(false)]
public string ratio_custom_tb_name { get; set; }
[Browsable(false)]
public string ratio_custom_pdd_name { get; set; }
[Browsable(false)]
public string ratio_custom_jd_name { get; set; }
[Browsable(false)]
public string ratio_custom_wph_name { get; set; }
[Browsable(false)]
public string ratio_custom_dy_name { get; set; }
[Browsable(false)]
public string ratio_custom_sn_name { get; set; }
[Browsable(false)]
public string ratio_custom_ks_name { get; set; }
}
private List GetViewGroups(List data)
{
var results = new List();
try
{
if (data != null && data.Count != 0)
{
var db = ApiClient.GetSession();
var custom_groups = db.Find("select * from fl_ratio_info_custom_group");
foreach (var item in data)
{
var tb = custom_groups.FirstOrDefault(f => f.id == item.ratio_custom_tb);
var pdd = custom_groups.FirstOrDefault(f => f.id == item.ratio_custom_pdd);
var jd = custom_groups.FirstOrDefault(f => f.id == item.ratio_custom_jd);
var wph = custom_groups.FirstOrDefault(f => f.id == item.ratio_custom_wph);
var dy = custom_groups.FirstOrDefault(f => f.id == item.ratio_custom_dy);
var sn = custom_groups.FirstOrDefault(f => f.id == item.ratio_custom_sn);
var ks = custom_groups.FirstOrDefault(f => f.id == item.ratio_custom_ks);
results.Add(new view_fl_member_group()
{
id = item.id,
name = item.name,
ratio_custom_dy = item.ratio_custom_dy,
ratio_custom_dy_name = (dy == null ? string.Empty : dy.name),
ratio_custom_jd = item.ratio_custom_jd,
ratio_custom_jd_name = (jd == null ? string.Empty : jd.name),
ratio_custom_pdd = item.ratio_custom_pdd,
ratio_custom_pdd_name = (pdd == null ? string.Empty : pdd.name),
ratio_custom_tb = item.ratio_custom_tb,
ratio_custom_tb_name = (tb == null ? string.Empty : tb.name),
ratio_custom_wph = item.ratio_custom_wph,
ratio_custom_wph_name = (wph == null ? string.Empty : wph.name),
ratio_custom_sn = item.ratio_custom_sn,
ratio_custom_sn_name = (sn == null ? string.Empty : sn.name),
ratio_custom_ks = item.ratio_custom_ks,
ratio_custom_ks_name = (ks == null ? string.Empty : ks.name),
subsidy = item.subsidy,
subsidy_type = item.subsidy_type,
terms = item.terms,
terms_ordersum = item.terms_ordersum
});
}
}
}
catch (Exception ex)
{
BaseForm.ShowError($"加载数据异常:{ex.Message}");
}
return results;
}
#endregion
public void Initialization()
{
try
{
var session = ApiClient.GetSession();
if (this.tabPane1.SelectedPageIndex == 0)
{
var groups = session.FindGroups(true);
this.gridControl1.DataSource = GetViewGroups(groups);
}
else if (tabPane1.SelectedPageIndex == 1)
{
var groups = session.FindRatios(Util.ConvertEnum(int.Parse(this.radioGroup1.EditValue.ToString())), true);
this.gridControl2.DataSource = groups;
}
else if (tabPane1.SelectedPageIndex == 2)
{
flushCustomGroupView();
}
else if (tabPane1.SelectedPageIndex == 3)
{
var groups = session.FindSleeps(Util.ConvertEnum(int.Parse(this.radioGroup2.EditValue.ToString())), true);
this.gridControl3.DataSource = groups;
}
else if (tabPane1.SelectedPageIndex == 4)
{
var groups = session.FindAdzoneGroups(Util.ConvertEnum(int.Parse(this.radioGroup3.EditValue.ToString())), true).Where(f => string.IsNullOrWhiteSpace(f.remark)).ToList();
foreach (var group in groups)
{
var tgws = (CsharpHttpHelper.HttpHelper.JsonToObject>(group.adzones) as List);
var temp = string.Join(",", tgws.Select(z => z.Member.usernick).GroupBy(f => f).Select(f => f.Key));
group.adzones = temp;
}
this.gridControl4.DataSource = groups;
label2.Visible = groups.Count == 0;
}
else if (tabPane1.SelectedPageIndex == 5)
{
var groups = session.FindAdzoneGroups(Util.ConvertEnum(int.Parse(this.radioGroup4.EditValue.ToString())), true).Where(f => f.remark == fl_alimama_activity_type.天猫精选.ToString()).ToList();
foreach (var group in groups)
{
var tgws = (CsharpHttpHelper.HttpHelper.JsonToObject>(group.adzones) as List);
if (tgws == null) continue;
var temp = string.Join(",", tgws.Select(z => z.Member.usernick).GroupBy(f => f).Select(f => f.Key));
group.adzones = temp;
}
this.gridControl5.DataSource = groups;
label1.Visible = groups.Count == 0;
}
else if (tabPane1.SelectedPageIndex == 6)
{
var list = session.FindUserVariates();
this.gridControl6.DataSource = list;
label3.Visible = list.Count == 0;
}
else if (tabPane1.SelectedPageIndex == 7)
{
pageControl1.Bind((page, size) =>
{
var db = ApiClient.GetSession();
var parm = db.NewParamMap();
parm.setPageParamters(page, size);
var total = 0;
List result = null;
if (string.IsNullOrWhiteSpace(tbox_KeyWord.Text))
{
result = session.Queryable().Where(f => f.custom_type == Resources.GroupSoftwareType).OrderBy(f => f.id, SqlSugar.OrderByType.Desc).GroupBy(f => f.group_id).Select((f) => new group_pid_temp()
{
groupid = f.group_id,
extend = f.extend,
jd_pid_name = string.Empty,
pdd_pid_name = string.Empty,
tb_pid_name = string.Empty
}).ToPageList(page, size, ref total);
}
else
{
result = session.Queryable().Where(f => f.custom_type == Resources.GroupSoftwareType && f.group_id.Contains(tbox_KeyWord.Text.Trim())).OrderBy(f => f.id, SqlSugar.OrderByType.Desc).GroupBy(f => f.group_id).Select((f) => new group_pid_temp()
{
groupid = f.group_id,
extend = f.extend,
jd_pid_name = string.Empty,
pdd_pid_name = string.Empty,
tb_pid_name = string.Empty
}).ToPageList(page, size, ref total);
}
foreach (var item in result)
{
var infos = session.Find("select * from fl_adzone_info where group_id = @group_id and custom_type = @custom_type", new { group_id = item.groupid, custom_type = Resources.GroupSoftwareType });
foreach (var info in infos)
{
var type = (CpsType)Enum.ToObject(typeof(CpsType), info.alliance_id);
switch (type)
{
case CpsType.阿里妈妈:
item.tb_pid_name = info.adzone_name;
break;
case CpsType.多多进宝:
item.pdd_pid_name = info.adzone_name;
break;
case CpsType.京东联盟:
item.jd_pid_name = info.adzone_name;
break;
case CpsType.唯品联盟:
item.jd_pid_name = info.adzone_name;
break;
case CpsType.抖音联盟:
item.jd_pid_name = info.adzone_name;
break;
default:
break;
}
}
}
label4.Visible = result.Count == 0;
return new PageControl.SerchResult() { Result = result, Total = total };
}, gridControl7, 40);
}
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex.Message + "_" + ex.StackTrace);
}
}
private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
{
if (e.Column.Caption == "会员等级")
{
var row = e.Row as fl_member_group;
e.Value = row.GetLevel();
}
}
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
GridView gridview = null;
if (tabPane1.SelectedPageIndex == 0)
{
gridview = gridView1;
var _rows = gridview.GetSelectedRows();
var temp = gridview.GetRow(_rows[0]) as fl_member_group;
if (temp.terms == 0 && temp.terms_ordersum == 0)
{
XtraMessageBox.Show("升级条件为[0]的项,不能删除!", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
else if (tabPane1.SelectedPageIndex == 1) gridview = gridView2;
else gridview = gridView3;
var rows = gridview.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
var row = gridview.GetRow(rows[0]) as base_model;
var session = ApiClient.GetSession();
if (tabPane1.SelectedPageIndex == 0)
{
int rowCount = gridview.RowCount;//获取所有的行数
var memberModels = new List();
//将没有选中的分组,放置集合中.用于用户分组转移使用
for (int i = 0; i < rowCount; i++)
{
if (i != rows[0])
memberModels.Add(gridview.GetRow(i) as fl_member_group);
}
var memberReelectGroupForm = new member_reelect_group(memberModels);
if (memberReelectGroupForm.ShowDialog() == DialogResult.OK)
{
//要删除的分组,分组对应的用户将移至还存在的分组中
var id = memberReelectGroupForm.id;
session.ExcuteSQL("update fl_member_info set group_id = @newgroupid where group_id = @oldgroupid", new { newgroupid = id, oldgroupid = row.id });
session.ExcuteSQL("delete from fl_member_group where id = @id", new { id = row.id });
}
}
else if (tabPane1.SelectedPageIndex == 1)
session.ExcuteSQL("delete from fl_ratio_info where id = @id", new { id = row.id });
else if (tabPane1.SelectedPageIndex == 3)
session.ExcuteSQL("delete from fl_order_sleep where id = @id", new { id = row.id });
Initialization();
}
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
}
private void 修改ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
GridView grid = null;
bool set_group = false;
double tiaojian_pointsum = 0;
double tiaojian_ordersum = 0;
if (this.tabPane1.SelectedPageIndex == 0)
{
set_group = true;
grid = this.gridView1;
}
else if (this.tabPane1.SelectedPageIndex == 1) grid = this.gridView2;
else if (this.tabPane1.SelectedPageIndex == 3) grid = this.gridView3;
var rows = grid.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
var row = grid.GetRow(rows[0]) as base_model;
var temp = set_group ? grid.GetRow(rows[0]) as fl_member_group : null;
tiaojian_pointsum = temp != null ? temp.terms : 0;
tiaojian_ordersum = temp != null ? temp.terms_ordersum : 0;
SettingForm form = new SettingForm(row);
form.ShowDialog();
if (temp != null && tiaojian_pointsum == 0 && tiaojian_ordersum == 0 && (temp.terms != 0 || temp.terms_ordersum != 0))
{
temp.terms_ordersum = 0;
temp.terms = 0;
XtraMessageBox.Show("升级条件为[0]的项,不能修改条件,必须有一个升级条件为[0]!", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
var session = ApiClient.GetSession();
var type = row.GetType();
if (type == typeof(fl_member_group) || type == typeof(view_fl_member_group)) session.SaveOrUpdate(row as fl_member_group);
else if (type == typeof(fl_ratio_info)) session.SaveOrUpdate(row as fl_ratio_info);
else if (type == typeof(fl_order_sleep)) session.SaveOrUpdate(row as fl_order_sleep);
}
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
Initialization();//刷新界面
}
private void tabPane1_SelectedPageIndexChanged(object sender, EventArgs e)
{
Initialization();
}
private void 增加ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var title = string.Empty;
base_model entity = null;
if (this.tabPane1.SelectedPageIndex == 0)
{
entity = new fl_member_group() { subsidy_type = SubsidyType.百分比 };
title = "增加会员组";
}
else if (this.tabPane1.SelectedPageIndex == 1)//公共佣金规则
{
if (radioGroup1.SelectedIndex == 0)
entity = new fl_ratio_info() { cps_type = CpsType.多多进宝, subsidy_type = SubsidyType.百分比 };
else if (radioGroup1.SelectedIndex == 1)
entity = new fl_ratio_info() { cps_type = CpsType.阿里妈妈, subsidy_type = SubsidyType.百分比 };
else if (radioGroup1.SelectedIndex == 2)
entity = new fl_ratio_info() { cps_type = CpsType.京东联盟, subsidy_type = SubsidyType.百分比 };
else if (radioGroup1.SelectedIndex == 3)
entity = new fl_ratio_info() { cps_type = CpsType.唯品联盟, subsidy_type = SubsidyType.百分比 };
else if (radioGroup1.SelectedIndex == 4)
entity = new fl_ratio_info() { cps_type = CpsType.抖音联盟, subsidy_type = SubsidyType.百分比 };
else if (radioGroup1.SelectedIndex == 5)
entity = new fl_ratio_info() { cps_type = CpsType.苏宁易购, subsidy_type = SubsidyType.百分比 };
else if (radioGroup1.SelectedIndex == 6)
entity = new fl_ratio_info() { cps_type = CpsType.快手联盟, subsidy_type = SubsidyType.百分比 };
title = "增加公共分出比例";
}
else if (this.tabPane1.SelectedPageIndex == 2) //独立设置佣金规则
{
if (radioGroup1.SelectedIndex == 0)
entity = new fl_ratio_info_custom() { cps_type = CpsType.多多进宝, subsidy_type = SubsidyType.百分比 };
else if (radioGroup1.SelectedIndex == 1)
entity = new fl_ratio_info_custom() { cps_type = CpsType.阿里妈妈, subsidy_type = SubsidyType.百分比 };
else if (radioGroup1.SelectedIndex == 2)
entity = new fl_ratio_info_custom() { cps_type = CpsType.京东联盟, subsidy_type = SubsidyType.百分比 };
else if (radioGroup1.SelectedIndex == 3)
entity = new fl_ratio_info_custom() { cps_type = CpsType.唯品联盟, subsidy_type = SubsidyType.百分比 };
else if (radioGroup1.SelectedIndex == 4)
entity = new fl_ratio_info_custom() { cps_type = CpsType.抖音联盟, subsidy_type = SubsidyType.百分比 };
else if (radioGroup1.SelectedIndex == 5)
entity = new fl_ratio_info_custom() { cps_type = CpsType.苏宁易购, subsidy_type = SubsidyType.百分比 };
else if (radioGroup1.SelectedIndex == 6)
entity = new fl_ratio_info_custom() { cps_type = CpsType.快手联盟, subsidy_type = SubsidyType.百分比 };
title = "增加独立分出比例";
}
else if (this.tabPane1.SelectedPageIndex == 3)
{
entity = null;
if (radioGroup2.SelectedIndex == 0)
entity = new fl_order_sleep() { cps_type = CpsType.多多进宝 };
else if (radioGroup2.SelectedIndex == 1)
entity = new fl_order_sleep() { cps_type = CpsType.阿里妈妈 };
else if (radioGroup2.SelectedIndex == 2)
entity = new fl_order_sleep() { cps_type = CpsType.京东联盟 };
else if (radioGroup2.SelectedIndex == 3)
entity = new fl_order_sleep() { cps_type = CpsType.唯品联盟 };
else if (radioGroup2.SelectedIndex == 4)
entity = new fl_order_sleep() { cps_type = CpsType.抖音联盟 };
else if (radioGroup2.SelectedIndex == 5)
entity = new fl_order_sleep() { cps_type = CpsType.苏宁易购 };
else if (radioGroup2.SelectedIndex == 6)
entity = new fl_order_sleep() { cps_type = CpsType.快手联盟 };
title = "增加延迟结算";
}
try
{
SettingForm form = new SettingForm(entity);
form.Text = title;
form.ShowDialog();
var session = ApiClient.GetSession();
var type = entity.GetType();
if (type == typeof(fl_member_group)) session.SaveOrUpdate(entity as fl_member_group);
else if (type == typeof(fl_ratio_info)) session.SaveOrUpdate(entity as fl_ratio_info);
else if (type == typeof(fl_order_sleep)) session.SaveOrUpdate(entity as fl_order_sleep);
}
catch
{
if (!this.IsDisposed) BaseForm.ShowError("数据违反唯一性,请勿重复增加");
}
Initialization();//刷新界面
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
}
///
/// 增加
///
///
///
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
try
{
if (radioGroup3.SelectedIndex == 0)
{
var adzoneform = new tb_adzone_group_form();
adzoneform.Text = "增加推广位组";
adzoneform.ShowDialog();
}
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
Initialization();//刷新界面
}
///
/// 修改
///
///
///
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
try
{
var rows = gridView4.GetSelectedRows();
if (rows.Length != 0)
{
var row = gridView4.GetRow(rows[0]) as base_model;
var adzoneform = new tb_adzone_group_form(row.id);
adzoneform.Text = "修改推广位组";
adzoneform.ShowDialog();
Initialization();
}
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
}
///
/// 删除
///
///
///
private void toolStripMenuItem3_Click(object sender, EventArgs e)
{
try
{
var rows = gridView4.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
var row = gridView4.GetRow(rows[0]) as base_model;
var session = ApiClient.GetSession();
session.Deleteable().In(row.id).ExecuteCommand();
Initialization();
}
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
}
private void radioGroup3_SelectedIndexChanged(object sender, EventArgs e)
{
Initialization();
}
#region 强制返利推广位列表右击
///
/// 增加
///
///
///
private void toolStripMenuItem4_Click(object sender, EventArgs e)
{
try
{
if (radioGroup4.SelectedIndex == 0)
{
var adzoneform = new tb_adzone_activity_group_form();
adzoneform.Text = "增加强返推广位组";
adzoneform.ShowDialog();
}
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
Initialization();//刷新界面
}
///
/// 修改
///
///
///
private void toolStripMenuItem5_Click(object sender, EventArgs e)
{
try
{
var rows = gridView5.GetSelectedRows();
if (rows.Length != 0)
{
var row = gridView5.GetRow(rows[0]) as base_model;
var adzoneform = new tb_adzone_activity_group_form(row.id);
adzoneform.Text = "修改强返推广位组";
adzoneform.ShowDialog();
Initialization();
}
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
}
///
/// 删除
///
///
///
private void toolStripMenuItem6_Click(object sender, EventArgs e)
{
try
{
var rows = gridView5.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
var row = gridView5.GetRow(rows[0]) as base_model;
var session = ApiClient.GetSession();
session.Deleteable().In(row.id).ExecuteCommand();
Initialization();
}
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
}
#endregion
private void toolStripMenuItem7_Click(object sender, EventArgs e)
{
try
{
var form = new edit_uservariate_form();
form.Text = "增加全局变量";
form.ShowDialog();
Initialization();
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
}
private void toolStripMenuItem8_Click(object sender, EventArgs e)
{
try
{
var rows = gridView6.GetSelectedRows();
if (rows.Length == 0) return;
var uservariate_info = gridView6.GetRow(rows[0]) as fl_uservariate_info;
if (uservariate_info == null) return;
var form = new edit_uservariate_form(uservariate_info);
form.Text = "修改全局变量";
form.ShowDialog();
Initialization();
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
}
private void toolStripMenuItem9_Click(object sender, EventArgs e)
{
try
{
var rows = gridView6.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
var row = gridView6.GetRow(rows[0]) as base_model;
var session = ApiClient.GetSession();
session.Deleteable().In(row.id).ExecuteCommand();
session.FindUserVariates(true);
Initialization();
}
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
}
private void 增加群pidToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var group_info = new group_info_form();
group_info.ShowDialog();
Initialization();
}
catch (Exception ex)
{
BaseForm.ShowError(ex);
}
}
private void 修改群信息ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var rows = gridView7.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
var group_id = gridView7.GetRowCellValue(rows[0], "groupid").ToString();
var extend = gridView7.GetRowCellValue(rows[0], "extend").ToString();
var group_info = new group_info_form(group_id, extend);
group_info.ShowDialog();
Initialization();
}
}
catch (Exception ex)
{
BaseForm.ShowError(ex);
}
}
private void simpleButton2_Click(object sender, EventArgs e)
{
Initialization();
}
private void gridView7_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
{
try
{
if ((e.Column.FieldName == "pdd_pid_name" || e.Column.FieldName == "tb_pid_name" || e.Column.FieldName == "jd_pid_name") && (e.Value == null || string.IsNullOrEmpty(e.Value.ToString()))) e.DisplayText = "双击设置";
}
catch (Exception ex)
{
BaseForm.ShowError(ex);
}
}
private void gridView7_RowCellClick(object sender, RowCellClickEventArgs e)
{
try
{
#region 双击单元格设置推广位
var selectRow = gridView7.GetSelectedRows()[0];
var groupid = this.gridView7.GetRowCellValue(selectRow, "groupid").ToString();//获取列的数据
//点击数大于2弹出窗体进行推广位的选择
if (e.Clicks >= 2)
{
var session = ApiClient.GetSession();
var strs = new string[] { "淘宝推广位名称", "拼多多推广位名称", "京东推广位名称", "唯品会推广位名称", "抖音推广位名称", "抖客推广位名称" };
if (!strs.Contains(e.Column.Caption)) return;
var pidInfos = session.Queryable().Where(f => f.group_id == groupid && f.custom_type == Resources.GroupSoftwareType).ToList();
fl_adzone_info esbAdzone = null;
object setAdzoneObj = null;
Tuiguangwei setAdzone = null;
if (e.Column.Caption == strs[0])
{
setAdzoneObj = CpsClient.SelectTuiguangwei(CpsType.阿里妈妈);
if (setAdzoneObj != null)
esbAdzone = pidInfos.Where(f => f.alliance_id == (int)CpsType.阿里妈妈).FirstOrDefault();
}
else if (e.Column.Caption == strs[1])
{
setAdzoneObj = CpsClient.SelectTuiguangwei(CpsType.多多进宝);
if (setAdzoneObj != null)
esbAdzone = pidInfos.Where(f => f.alliance_id == (int)CpsType.多多进宝).FirstOrDefault();
}
else if (e.Column.Caption == strs[2])
{
setAdzoneObj = CpsClient.SelectTuiguangwei(CpsType.京东联盟);
if (setAdzoneObj != null)
esbAdzone = pidInfos.Where(f => f.alliance_id == (int)CpsType.京东联盟).FirstOrDefault();
}
else if (e.Column.Caption == strs[3])
{
setAdzoneObj = CpsClient.SelectTuiguangwei(CpsType.唯品联盟);
if (setAdzoneObj != null)
esbAdzone = pidInfos.Where(f => f.alliance_id == (int)CpsType.唯品联盟).FirstOrDefault();
}
else if (e.Column.Caption == strs[4])
{
setAdzoneObj = CpsClient.SelectTuiguangwei(CpsType.抖音联盟);
if (setAdzoneObj != null)
esbAdzone = pidInfos.Where(f => f.alliance_id == (int)CpsType.抖音联盟).FirstOrDefault();
}
else if (e.Column.Caption == strs[5])
{
setAdzoneObj = CpsClient.SelectTuiguangwei(CpsType.抖客联盟);
if (setAdzoneObj != null)
esbAdzone = pidInfos.Where(f => f.alliance_id == (int)CpsType.抖客联盟).FirstOrDefault();
}
if (esbAdzone != null && setAdzoneObj != null)
{
setAdzone = setAdzoneObj as Tuiguangwei;
esbAdzone.adzone_name = setAdzone.Name;
esbAdzone.adzone_pid = setAdzone.Pid;
esbAdzone.adzone_pid_cps_name = setAdzone.Member.username;
session.SaveOrUpdate(esbAdzone);
}
pageControl1.GotoPage(1);
session.FindAdzoneInfos(true);
}
#endregion
}
catch (Exception ex)
{
BaseForm.ShowError(ex);
}
}
private void 删除选中群ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var rows = gridView7.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
var group_id = gridView7.GetRowCellValue(rows[0], "groupid").ToString();
var session = ApiClient.GetSession();
session.Deleteable().Where(f => f.custom_type == Resources.GroupSoftwareType && f.group_id == group_id).ExecuteCommand();
pageControl1.GotoPage(1);
session.FindAdzoneInfos(true);
BaseForm.ShowSuccess("删除成功");
}
}
catch (Exception ex)
{
BaseForm.ShowError(ex);
}
}
private void contextMenuStrip4_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
var rows = gridView7.GetSelectedRows();
修改群信息ToolStripMenuItem.Enabled = 删除选中群ToolStripMenuItem.Enabled = 推广位删除ToolStripMenuItem.Enabled = (rows != null && rows.Length > 0);
}
private void 删除选中推广位ToolStripMenuItem1_Click(object sender, EventArgs e)
{
try
{
if (sender is ToolStripMenuItem)
{
var item = sender as ToolStripMenuItem;
CpsType cps = CpsType.京东联盟;
if (item.Text == "删除选中淘宝推广位")
cps = CpsType.阿里妈妈;
else if (item.Text == "删除选中拼多多推广位")
cps = CpsType.多多进宝;
else if (item.Text == "删除选中京东推广位")
cps = CpsType.京东联盟;
else if (item.Text == "删除选中唯品会推广位")
cps = CpsType.唯品联盟;
else if (item.Text == "删除选中抖音推广位")
cps = CpsType.抖音联盟;
var session = ApiClient.GetSession();
var selectRow = gridView7.GetSelectedRows()[0];
var groupid = this.gridView7.GetRowCellValue(selectRow, "groupid").ToString();//获取列的数据
var adzone = session.FindAdzoneInfos().FirstOrDefault(f => f.alliance_id == (int)cps && f.group_id == groupid && f.custom_type == Resources.GroupSoftwareType);
if (adzone != null)
{
adzone.adzone_name = string.Empty;
adzone.adzone_pid = string.Empty;
adzone.adzone_pid_cps_name = string.Empty;
session.SaveOrUpdate(adzone);
pageControl1.GotoPage(1);
session.FindAdzoneInfos(true);
}
BaseForm.ShowSuccess("执行成功");
}
}
catch (Exception ex)
{
BaseForm.ShowError(ex);
}
}
#region 分组
private void toolStripMenuItem10_Click_1(object sender, EventArgs e)
{
try
{
var title = string.Empty;
base_model entity = null;
if (radioGroup5.SelectedIndex == 0)
entity = new fl_ratio_info_custom_group() { cps_type = CpsType.多多进宝 };
else if (radioGroup5.SelectedIndex == 1)
entity = new fl_ratio_info_custom_group() { cps_type = CpsType.阿里妈妈 };
else if (radioGroup5.SelectedIndex == 2)
entity = new fl_ratio_info_custom_group() { cps_type = CpsType.京东联盟 };
else if (radioGroup5.SelectedIndex == 3)
entity = new fl_ratio_info_custom_group() { cps_type = CpsType.唯品联盟 };
else if (radioGroup5.SelectedIndex == 4)
entity = new fl_ratio_info_custom_group() { cps_type = CpsType.抖音联盟 };
else if (radioGroup5.SelectedIndex == 5)
entity = new fl_ratio_info_custom_group() { cps_type = CpsType.苏宁易购 };
else if (radioGroup5.SelectedIndex == 6)
entity = new fl_ratio_info_custom_group() { cps_type = CpsType.快手联盟 };
title = "增加独立分出比例分组";
try
{
SettingForm form = new SettingForm(entity);
form.Text = title;
form.ShowDialog();
var session = ApiClient.GetSession();
var type = entity.GetType();
if (type == typeof(fl_ratio_info_custom_group))
{
var ricg = entity as fl_ratio_info_custom_group;
if (string.IsNullOrWhiteSpace(ricg.name))
return;
session.SaveOrUpdate(ricg);
}
}
catch
{
if (!this.IsDisposed) BaseForm.ShowError("数据违反唯一性,请勿重复增加");
}
Initialization();//刷新界面
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
}
///
/// 刷新自定义分出比例分组列表
///
private void flushCustomGroupView()
{
try
{
var db = ApiClient.GetSession();
//var groups = db.Queryable().Where(f => f.cps_type == Util.ConvertEnum(int.Parse(this.radioGroup5.EditValue.ToString()))).ToList();
var groups = db.Find("select * from fl_ratio_info_custom_group where cps_type = @cps_type", new { cps_type = this.radioGroup5.EditValue.ToString() }).ToList();
this.gridControl9.DataSource = groups;
if (groups != null && groups.Count != 0)
{
ratioInfoCustomId = groups[0].id;
label6.Visible = false;
}
else
{
ratioInfoCustomId = -1;
label6.Visible = true;
}
}
catch (Exception ex)
{ }
flushCustomView();
}
private void toolStripMenuItem13_Click(object sender, EventArgs e)
{
try
{
if (ratioInfoCustomId == -1)
{
BaseForm.ShowErrorAutoClose("请先添加分组");
return;
}
var title = string.Empty;
base_model entity = null;
if (radioGroup5.SelectedIndex == 0)
entity = new fl_ratio_info_custom() { cps_type = CpsType.多多进宝, subsidy_type = SubsidyType.百分比, cgid = ratioInfoCustomId };
else if (radioGroup5.SelectedIndex == 1)
entity = new fl_ratio_info_custom() { cps_type = CpsType.阿里妈妈, subsidy_type = SubsidyType.百分比, cgid = ratioInfoCustomId };
else if (radioGroup5.SelectedIndex == 2)
entity = new fl_ratio_info_custom() { cps_type = CpsType.京东联盟, subsidy_type = SubsidyType.百分比, cgid = ratioInfoCustomId };
else if (radioGroup5.SelectedIndex == 3)
entity = new fl_ratio_info_custom() { cps_type = CpsType.唯品联盟, subsidy_type = SubsidyType.百分比, cgid = ratioInfoCustomId };
else if (radioGroup5.SelectedIndex == 4)
entity = new fl_ratio_info_custom() { cps_type = CpsType.抖音联盟, subsidy_type = SubsidyType.百分比, cgid = ratioInfoCustomId };
else if (radioGroup5.SelectedIndex == 5)
entity = new fl_ratio_info_custom() { cps_type = CpsType.苏宁易购, subsidy_type = SubsidyType.百分比, cgid = ratioInfoCustomId };
else if (radioGroup5.SelectedIndex == 6)
entity = new fl_ratio_info_custom() { cps_type = CpsType.快手联盟, subsidy_type = SubsidyType.百分比, cgid = ratioInfoCustomId };
title = "增加独立分出比例";
try
{
SettingForm form = new SettingForm(entity);
form.Text = title;
form.ShowDialog();
var session = ApiClient.GetSession();
var type = entity.GetType();
if (type == typeof(fl_ratio_info_custom)) session.SaveOrUpdate(entity as fl_ratio_info_custom);
}
catch
{
if (!this.IsDisposed) BaseForm.ShowError("数据违反唯一性,请勿重复增加");
}
//Initialization();//刷新界面
flushCustomView();
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
}
///
/// 刷新自定义分出比例分组
///
private void flushCustomView()
{
try
{
if (ratioInfoCustomId == -1)
{
gridControl8.DataSource = null;
label5.Visible = true;
return;
}
var db = ApiClient.GetSession();
var groups = db.FindCustomRatios(ratioInfoCustomId, true);
this.gridControl8.DataSource = groups;
if (groups != null && groups.Count != 0)
label5.Visible = false;
}
catch (Exception ex)
{ }
}
///
/// 独立分组选中id
///
private long ratioInfoCustomId = -1;
#endregion
private void radioGroup5_SelectedIndexChanged(object sender, EventArgs e)
{
Initialization();
}
private void gridControl9_Click(object sender, EventArgs e)
{
try
{
var rows = this.gridView9.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
//获取选中数据
var row = this.gridView9.GetRow(rows[0]) as fl_ratio_info_custom_group;
if (gridView9.SelectedRowsCount != 0)
{
ratioInfoCustomId = row.id;
flushCustomView();
}
}
}
catch (Exception ex)
{ }
}
private void toolStripMenuItem11_Click(object sender, EventArgs e)
{
try
{
var rows = gridView9.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
var row = gridView9.GetRow(rows[0]) as fl_ratio_info_custom_group;
SettingForm form = new SettingForm(row);
form.ShowDialog();
var session = ApiClient.GetSession();
var type = row.GetType();
session.SaveOrUpdate(row as fl_ratio_info_custom_group);
}
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
Initialization();//刷新界面
}
private void toolStripMenuItem14_Click(object sender, EventArgs e)
{
try
{
var rows = gridView8.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
var row = gridView8.GetRow(rows[0]) as fl_ratio_info_custom;
SettingForm form = new SettingForm(row);
form.ShowDialog();
var session = ApiClient.GetSession();
var type = row.GetType();
session.SaveOrUpdate(row as fl_ratio_info_custom);
}
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
Initialization();//刷新界面
}
private void toolStripMenuItem12_Click(object sender, EventArgs e)
{
try
{
var rows = gridView9.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
if (XtraMessageBox.Show("确定要删除选中以及相关的数据吗?", "友情提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
return;
var row = gridView9.GetRow(rows[0]) as fl_ratio_info_custom_group;
var db = ApiClient.GetSession();
db.ExcuteSQL("delete from fl_ratio_info_custom where cgid = @id", new { id = row.id });
db.ExcuteSQL("delete from fl_ratio_info_custom_group where id = @id", new { id = row.id });
Initialization();
}
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
}
private void toolStripMenuItem15_Click(object sender, EventArgs e)
{
try
{
var rows = gridView8.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
var row = gridView8.GetRow(rows[0]) as fl_ratio_info_custom;
var session = ApiClient.GetSession();
session.ExcuteSQL("delete from fl_ratio_info_custom where id = @id", new { id = row.id });
flushCustomView();
}
}
catch (Exception ex)
{
if (!this.IsDisposed) BaseForm.ShowError(ex);
}
}
///
/// 行单元格单击事件
///
///
///
private void gridView1_RowCellClick(object sender, RowCellClickEventArgs e)
{
try
{
#region 双击单元格设置推广位
//点击数大于2弹出窗体进行推广位的选择
if (e.Clicks >= 2)
{
if (gridView1.GetSelectedRows().Length != 0)
{
var selectRow = gridView1.GetSelectedRows()[0];
var id = this.gridView1.GetRowCellValue(selectRow, "id").ToString();//获取列的数据
if (e.Column.FieldName == "ratio_custom_tb_name"
|| e.Column.FieldName == "ratio_custom_pdd_name"
|| e.Column.FieldName == "ratio_custom_jd_name"
|| e.Column.FieldName == "ratio_custom_wph_name"
|| e.Column.FieldName == "ratio_custom_dy_name"
|| e.Column.FieldName == "ratio_custom_sn_name"
|| e.Column.FieldName == "ratio_custom_ks_name"
)
{
/*
阿里妈妈 = 1,
多多进宝 = 2,
京东联盟 = 3,
唯品联盟 = 4,
抖音联盟 = 5,
苏宁易购 = 6,
快手联盟 = 7,
*/
var selIndex = 0; //选择选
CpsType cps = CpsType.京东联盟;
if (e.Column.FieldName.Contains("_tb_"))
{
selIndex = 1;
cps = CpsType.阿里妈妈;
}
else if (e.Column.FieldName.Contains("_pdd_"))
{
selIndex = 0;
cps = CpsType.多多进宝;
}
else if (e.Column.FieldName.Contains("_jd_"))
{
selIndex = 2;
cps = CpsType.京东联盟;
}
else if (e.Column.FieldName.Contains("_wph_"))
{
selIndex = 3;
cps = CpsType.唯品联盟;
}
else if (e.Column.FieldName.Contains("_dy_"))
{
selIndex = 4;
cps = CpsType.抖音联盟;
}
else if (e.Column.FieldName.Contains("_sn_"))
{
selIndex = 5;
cps = CpsType.苏宁易购;
}
else if (e.Column.FieldName.Contains("_ks_"))
{
selIndex = 6;
cps = CpsType.快手联盟;
}
var db = ApiClient.GetSession();
var custom_group = db.Find("select * from fl_ratio_info_custom_group where cps_type = @cps_type", new { cps_type = (int)cps });
if (custom_group == null || custom_group.Count == 0)
{
if (XtraMessageBox.Show("当前平台联盟没有设置独立的分出比例分组,是否立即去设置?", "友情提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
{
tabPane1.SelectedPageIndex = 2;
radioGroup5.SelectedIndex = selIndex;
}
return;
}
var rcgf = new RatioCustomGroupForm(custom_group);
rcgf.ShowDialog();
if (rcgf.group != null)
{
var custom = db.FindSingle("select * from fl_member_group where id = @id", new { id = id });
if (custom != null)
{
switch (cps)
{
case CpsType.阿里妈妈:
custom.ratio_custom_tb = rcgf.group.id;
break;
case CpsType.多多进宝:
custom.ratio_custom_pdd = rcgf.group.id;
break;
case CpsType.京东联盟:
custom.ratio_custom_jd = rcgf.group.id;
break;
case CpsType.唯品联盟:
custom.ratio_custom_wph = rcgf.group.id;
break;
case CpsType.抖音联盟:
custom.ratio_custom_dy = rcgf.group.id;
break;
case CpsType.苏宁易购:
custom.ratio_custom_sn = rcgf.group.id;
break;
case CpsType.快手联盟:
custom.ratio_custom_ks = rcgf.group.id;
break;
default:
break;
}
db.SaveOrUpdate(custom);
}
Initialization();
}
}
}
}
#endregion
}
catch (Exception ex)
{
BaseForm.ShowError(ex);
}
}
///
/// 修改显示内容的事件
///
///
///
private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
{
try
{
if ((e.Column.FieldName == "ratio_custom_tb_name" || e.Column.FieldName == "ratio_custom_pdd_name" || e.Column.FieldName == "ratio_custom_jd_name"
|| e.Column.FieldName == "ratio_custom_wph_name" || e.Column.FieldName == "ratio_custom_dy_name" || e.Column.FieldName == "ratio_custom_sn_name" || e.Column.FieldName == "ratio_custom_ks_name") && (e.Value == null || string.IsNullOrEmpty(e.Value.ToString()))) e.DisplayText = "双击设置";
}
catch (Exception ex)
{
BaseForm.ShowError(ex);
return;
}
}
private void contex_1_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
try
{
if (this.tabPane1.SelectedPageIndex == 0)
删除选中独立分出比例ToolStripMenuItem.Visible = true;
else
删除选中独立分出比例ToolStripMenuItem.Visible = false;
}
catch (Exception)
{ }
}
private void 删除选中独立分出比例ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var rows = gridView1.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
var row = gridView1.GetRow(rows[0]) as fl_member_group;
if (gridView1.FocusedColumn.FieldName == "ratio_custom_pdd_name")
row.ratio_custom_pdd = 0;
else if (gridView1.FocusedColumn.FieldName == "ratio_custom_tb_name")
row.ratio_custom_tb = 0;
else if (gridView1.FocusedColumn.FieldName == "ratio_custom_jd_name")
row.ratio_custom_jd = 0;
else if (gridView1.FocusedColumn.FieldName == "ratio_custom_wph_name")
row.ratio_custom_wph = 0;
else if (gridView1.FocusedColumn.FieldName == "ratio_custom_dy_name")
row.ratio_custom_dy = 0;
else if (gridView1.FocusedColumn.FieldName == "ratio_custom_sn_name")
row.ratio_custom_sn = 0;
else if (gridView1.FocusedColumn.FieldName == "ratio_custom_ks_name")
row.ratio_custom_ks = 0;
var db = ApiClient.GetSession();
db.SaveOrUpdate(row);
Initialization();
}
}
catch (Exception)
{ }
}
}
}