using LYFZ.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace LYFZ.Software.MainBusiness.MicroApplet
{
public class frmSynchronousData:LYFZ.Software.MicroApplet.frmSynchronousData
{
public frmSynchronousData()
{
this.UcNavigationTool.LabTitle = "微信小程序同步数据";
this.Shown += FrmSynchronousData_Shown;
this.Load += FrmSynchronousData_Load;
this.btnRefresh.Click += BtnRefresh_Click;
this.btnSearch.Click += BtnSearch_Click;
this.cmbStatus.SelectedIndexChanged += CmbStatus_SelectedIndexChanged;
this.cbPutongDingDan.Click += CheckBoxEx_Click;
this.cbPingTuandingdan.Click += CheckBoxEx_Click;
this.cbMiaoShaDingDan.Click += CheckBoxEx_Click;
this.btnUploadUerInfo.Click += BtnUploadUserInfo_Click;
this.btnUploadTaoXi.Click += BtnUploadTaoXi_Click;
this.dgvOrderViwe.CellContentClick += DgvOrderViwe_CellContentClick;
this.comAccountList.SelectedIndexChanged += ComAccountList_SelectedIndexChanged;
this.btnBatchSyncOrders.Click += BtnBatchSyncOrders_Click;
this.chbWeiWanChengTongBuDingDan.Click += ChbWeiWanChengTongBuDingDan_Click;
this.chbYiWanChengTongBuDingDan.Click += ChbYiWanChengTongBuDingDan_Click;
}
bool isChbYiWanChengTongBuDingDan = true;
bool isChbWeiWanChengTongBuDingDan = true;
///
/// 已完成同步订单
///
///
///
private void ChbYiWanChengTongBuDingDan_Click(object sender, EventArgs e)
{
this.isChbYiWanChengTongBuDingDan = this.chbYiWanChengTongBuDingDan.Checked;
TempRefresh();
BindOrderList();
}
///
/// 未完成同步订单
///
///
///
private void ChbWeiWanChengTongBuDingDan_Click(object sender, EventArgs e)
{
this.isChbWeiWanChengTongBuDingDan = this.chbWeiWanChengTongBuDingDan.Checked;
TempRefresh();
BindOrderList();
}
private void BtnBatchSyncOrders_Click(object sender, EventArgs e)
{
int rowIndex = 1;
if (this.dgvOrderViwe.SelectedRows != null && this.dgvOrderViwe.SelectedRows.Count > 0)
{
foreach (DataGridViewRow row in this.dgvOrderViwe.SelectedRows)
{
DataGridViewCellEventArgs cellE = new DataGridViewCellEventArgs(13, row.Index);
if (DgvOrderViwe_CellContentClick(null, cellE, rowIndex))
{
rowIndex++;
}
else {
break;
}
}
}
else {
MessageBoxCustom.Show("请选择要批量同步的订单");
}
}
///
/// 是否初始化完成
///
bool isInitialization = false;
private void ComAccountList_SelectedIndexChanged(object sender, EventArgs e)
{
if (isInitialization)
{
if (this.comAccountList.SelectedItem != null)
{
frmMicroAppletAdmin.MicroAppToken = "";
BLL.MicroApplet.MicroAppletAccount mAccount = (BLL.MicroApplet.MicroAppletAccount)((ItemValue)this.comAccountList.SelectedItem).Value;
frmMicroAppletAdmin.CurrentMicroAppletShopID = mAccount.ShopID;
LoadOrderList();
}
}
}
///
/// 获取订单
///
static string getOrderData = String.Format("{0}/api.php/IvisionBackstage/getOrderData", frmMicroAppletAdmin.microAppInterfaceDomainName);
///
/// 上传员工部门
///
static string importUserGroup = String.Format("{0}/api.php/IvisionBackstage/importUserGroup", frmMicroAppletAdmin.microAppInterfaceDomainName);
///
/// 上传员工信息
///
static string importUserdata = String.Format("{0}/api.php/IvisionBackstage/importUserdata", frmMicroAppletAdmin.microAppInterfaceDomainName);
///
/// 获取套系分类数据
///
public static string categotyData = String.Format("{0}/api.php/IvisionBackstage/categoty", frmMicroAppletAdmin.microAppInterfaceDomainName);
///
/// 上传套系数据
///
public static string addSeriesData = String.Format("{0}/api.php/IvisionBackstage/addSeries", frmMicroAppletAdmin.microAppInterfaceDomainName);
///
/// 上传图片
///
public static string uploadImg= String.Format("{0}/api.php/MeiBackstage/uploadImg", frmMicroAppletAdmin.microAppInterfaceDomainName);
///
/// 订单补齐余款
///
static string orderReplenishment = String.Format("{0}/api.php/IvisionBackstage/orderReplenishment", frmMicroAppletAdmin.microAppInterfaceDomainName);
///
/// 标记订单扩展数据
///
static string orderSignData = String.Format("{0}/api.php/IvisionBackstage/orderSign", frmMicroAppletAdmin.microAppInterfaceDomainName);
private void BtnUploadTaoXi_Click(object sender, EventArgs e)
{
frmPackagesUpload packUpload = new frmPackagesUpload();
packUpload.AppLoginModel = appLoginModel;
packUpload.Show();
}
private void BtnUploadUserInfo_Click(object sender, EventArgs e)
{
MicroAppReturn returnData = new MicroAppReturn();
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
{
try
{
backgroundWorker.ReportProgress(0, "正在上传员工信息...");
returnData = UploadUserDepartment(appLoginModel);
if (returnData.Code == 200)
{
returnData = UploadUserInfo(appLoginModel);
}
}
catch (Exception ex)
{
MessageBoxCustom.Show(String.Format("上传员工信息时错误:{0}", ex.Message));
}
});
if (returnData.Code == 200)
{
MessageBoxCustom.Show(String.Format("员工信息已上传成功"));
}
else {
MessageBoxCustom.Show(String.Format("上传员工信息时失败:{0}", returnData.Message));
}
}
LYFZ.BLL.BLL_ErpDepartment department = new BLL.BLL_ErpDepartment();
MicroAppReturn UploadUserDepartment(MicroAppLoginReturn appLogin)
{
List departmentList= department.GetModelList("1=1");
List