152 lines
5.7 KiB
C#
152 lines
5.7 KiB
C#
using AllBase;
|
|
using AllBase.Model.Result;
|
|
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.KJDForms.BaseForms;
|
|
using Work;
|
|
|
|
namespace TemuKJD.KJDForms.AccountForms
|
|
{
|
|
public partial class AccountForm : Form
|
|
{
|
|
public static List<DouShopSubAccountInfo> AllUsers { get; set; } = new List<DouShopSubAccountInfo>();
|
|
public MainForm Mf { get; set; } = null;
|
|
public string Uid { get; set; } = "";
|
|
|
|
public AccountForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void btnOpUser_Click(object sender, EventArgs e)
|
|
{
|
|
if (passwordtextBox.Text != repasstextBox.Text)
|
|
{
|
|
BaseMsgForm.ShowInfo("两次密码不正确", "提示");
|
|
return;
|
|
}
|
|
if (btnOpUser.Text == "添加用户" && passwordtextBox.Text.Length < 6)
|
|
{
|
|
BaseMsgForm.ShowInfo("密码最少6位", "提示");
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(txtNickName.Text) || string.IsNullOrEmpty(mobiletextBox.Text) ||
|
|
mobiletextBox.Text.Length != 11)
|
|
{
|
|
BaseMsgForm.ShowInfo("信息不正确", "提示");
|
|
return;
|
|
}
|
|
|
|
StringBuilder data = new StringBuilder();
|
|
data.Append(UserLogin.GetSignaturex());
|
|
data.Append("&sub_nick_name=" + GetHtml.UrlEncodeUtf8(txtNickName.Text));
|
|
data.Append("&sub_name=" + GetHtml.UrlEncodeUtf8(mobiletextBox.Text));
|
|
data.Append("&sub_mobile=" + GetHtml.UrlEncodeUtf8(mobiletextBox.Text));
|
|
data.Append("&card_id=");
|
|
if (groupIdcomboBox.Text == "客服")
|
|
data.Append("&group_id=4");
|
|
else if (groupIdcomboBox.Text == "采购")
|
|
data.Append("&group_id=9");
|
|
else if (groupIdcomboBox.Text == "主管")
|
|
{
|
|
data.Append("&group_id=3");
|
|
}
|
|
else
|
|
{
|
|
BaseMsgForm.ShowInfo("分组不正确", "提示");
|
|
return;
|
|
}
|
|
//if (groupIdcomboBox.Text == "上货")
|
|
// data.Append("&group_id=10");
|
|
//if (groupIdcomboBox.Text == "数据")
|
|
// data.Append("&group_id=11");
|
|
//if (groupIdcomboBox.Text == "登录")
|
|
// data.Append("&group_id=8");
|
|
if (!string.IsNullOrEmpty(passwordtextBox.Text))
|
|
data.Append("&sub_password=" + Md5Base.GetMd5(passwordtextBox.Text).ToLower());
|
|
string url = BaseClass.BuildObjString("user/add_user");
|
|
if (btnOpUser.Text != "添加用户" && !string.IsNullOrEmpty(Uid))
|
|
{
|
|
data.Append("&id=" + Uid);
|
|
url = BaseClass.BuildObjString("user/update_user");
|
|
}
|
|
string html = GetHtml.PostUtf8(url, data.ToString()).Trim();
|
|
|
|
if (html == "had" || html == "error had")
|
|
{
|
|
BaseMsgForm.ShowInfo("手机号被占用,请换一个", "提示");
|
|
return;
|
|
}
|
|
if (!string.IsNullOrEmpty(html))
|
|
{
|
|
if (html.Contains("\"code\":200"))
|
|
{
|
|
btnOpUser.Text = "添加用户";
|
|
EmptyInput();
|
|
btnCancel.Visible = false;
|
|
GetUser();
|
|
return;
|
|
}
|
|
var msg = BaseRegex.GetStringJson(ref html, "msg");
|
|
if (string.IsNullOrEmpty(msg))
|
|
msg = html;
|
|
BaseMsgForm.ShowError(msg, "错误");
|
|
return;
|
|
}
|
|
BaseMsgForm.ShowError("出现异常,添加失败", "错误");
|
|
}
|
|
|
|
private void GetUser()
|
|
{
|
|
dgvUser.Rows.Clear();
|
|
AllUsers.Clear();
|
|
string url = BaseClass.BuildObjString("user/get_user");
|
|
string data = UserLogin.GetSignaturex();
|
|
string html = GetHtml.PostUtf8(url, data);
|
|
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);
|
|
DouShopSubAccountInfo user = new DouShopSubAccountInfo();
|
|
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");
|
|
|
|
AllUsers.Add(user);
|
|
dgvUser.Rows.Add(user.id, user.nick_name, user.user_name, user.group_id, user.group_name, user.shop_count, "编辑", "删除");
|
|
}
|
|
}
|
|
}
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
btnOpUser.Text = "添加用户";
|
|
Uid = "";
|
|
EmptyInput();
|
|
btnCancel.Visible = false;
|
|
}
|
|
|
|
private void EmptyInput()
|
|
{
|
|
txtNickName.Clear();
|
|
passwordtextBox.Clear();
|
|
repasstextBox.Clear();
|
|
mobiletextBox.Clear();
|
|
}
|
|
}
|
|
}
|