123 lines
4.7 KiB
C#
123 lines
4.7 KiB
C#
using AllBase;
|
|
using AllBase.Model.Result;
|
|
using NaiBa.Util.Extension;
|
|
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 TemuKJD.BaseForms;
|
|
using Work;
|
|
|
|
namespace TemuKJD.DYForms.AdminForms
|
|
{
|
|
public partial class DYAdminShopAddSubSaForm : LRBaseForm
|
|
{
|
|
List<string> lstShopLoginName = new List<string>();
|
|
|
|
List<ShopSubAccountInfo> lstSubSa = new List<ShopSubAccountInfo>();
|
|
public DYAdminShopAddSubSaForm(List<string> ShopSelectIds = null)
|
|
{
|
|
InitializeComponent();
|
|
if (ShopSelectIds != null)
|
|
lstShopLoginName.AddRange(ShopSelectIds);
|
|
}
|
|
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
{
|
|
var selectRow = this.dgvSaUser.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colSelect"]?.Value.ParseToBool() == true);
|
|
if (selectRow == null)
|
|
{
|
|
BaseMsgForm.ShowError("请选择要分配的二级管理员!");
|
|
return;
|
|
}
|
|
var sub_sa = selectRow.Cells["colSubSaName"].Value.ParseToString();
|
|
|
|
StringBuilder data = new StringBuilder();
|
|
data.Append(UserLogin.GetSignaturex());
|
|
data.Append("&shop_login_name=" + string.Join(",", lstShopLoginName));
|
|
data.Append("&operate_sub_sa_name=" + sub_sa);
|
|
string url = BaseClass.BuildObjString("shop/set_shop_sub_sa");
|
|
string html = GetHtml.PostUtf8(url, data.ToString()).Trim();
|
|
if (!string.IsNullOrEmpty(html))
|
|
{
|
|
if (html.Contains("\"code\":200"))
|
|
{
|
|
OnSaveComplete(sub_sa);
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
var msg = BaseRegex.GetStringJson(ref html, "msg");
|
|
if (string.IsNullOrEmpty(msg))
|
|
msg = html;
|
|
BaseMsgForm.ShowError(msg, "错误");
|
|
}
|
|
}
|
|
else
|
|
BaseMsgForm.ShowError("未知错误,请重试!", "错误");
|
|
}
|
|
|
|
private void AdminShopAddSubSaForm_Load(object sender, EventArgs e)
|
|
{
|
|
dgvSaUser.Rows.Clear();
|
|
lstSubSa.Clear();
|
|
string url = BaseClass.BuildObjString("user/get_all_user");
|
|
StringBuilder data = new StringBuilder();
|
|
data.Append(UserLogin.GetSignaturex());
|
|
data.Append("&sa_level=2");
|
|
string html = GetHtml.PostUtf8(url, data.ToString());
|
|
if (string.IsNullOrEmpty(html))
|
|
return;
|
|
if (html.Contains("\"data\""))
|
|
{
|
|
var userObj = Newtonsoft.Json.Linq.JObject.Parse(html);
|
|
foreach (Newtonsoft.Json.Linq.JObject obj in userObj["data"])
|
|
{
|
|
string oStr = JsonHelper.SerializeObject(obj);
|
|
ShopSubAccountInfo user = new ShopSubAccountInfo();
|
|
user.id = BaseRegex.GetIntJson(ref oStr, "id");
|
|
user.user_name = BaseRegex.GetStringJson(ref oStr, "user_name");
|
|
user.nick_name = BaseRegex.GetStringJson(ref oStr, "nick_name");
|
|
user.mobile = BaseRegex.GetStringJson(ref oStr, "mobile");
|
|
user.group_id = BaseRegex.GetStringJson(ref oStr, "group_id");
|
|
user.shop_count = BaseRegex.GetIntJson(ref oStr, "shop_count");
|
|
user.company_name = BaseRegex.GetStringJson(ref oStr, "company_name");
|
|
user.sa_level = BaseRegex.GetIntJson(ref oStr, "sa_level");
|
|
|
|
lstSubSa.Add(user);
|
|
dgvSaUser.Rows.Add(
|
|
false,
|
|
user.id,
|
|
user.nick_name,
|
|
user.user_name);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void dgvSaUser_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
|
|
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
|
return;
|
|
|
|
//string columnName = dgvSaUser.Columns[e.ColumnIndex].Name;
|
|
//switch (columnName)
|
|
//{
|
|
// case "colSelect":
|
|
var value = dgvSaUser.Rows[e.RowIndex].Cells["colSelect"].Value;
|
|
foreach (DataGridViewRow row in this.dgvSaUser.Rows)
|
|
row.Cells["colSelect"].Value = false;
|
|
dgvSaUser.Rows[e.RowIndex].Cells["colSelect"].Value = !(bool)value;
|
|
// break;
|
|
// default:
|
|
// break;
|
|
//}
|
|
}
|
|
}
|
|
}
|