예제 #1
0
        void Init()
        {
            scbProvince.SelectedIndexChanged += (sender, e) =>
            {
                if (scbProvince.SelectedIndex != -1)
                {
                    var value = scbProvince.SelectedItem as Province;
                    if (value.ProvinceID != -1)
                    {
                        scbCity.DisplayMember = "CityName";
                        scbCity.DataSource    = _areaBll.GetCityList(value.ProvinceID);
                    }
                    else
                    {
                        scbCity.DataSource     = null;
                        scbDistrict.DataSource = null;
                    }
                }
                else
                {
                    scbCity.DataSource     = null;
                    scbDistrict.DataSource = null;
                }
            };

            scbCity.SelectedIndexChanged += (sender, e) =>
            {
                if (scbCity.SelectedIndex != -1)
                {
                    var value = scbCity.SelectedItem as City;
                    if (value.CityID != -1)
                    {
                        scbDistrict.DisplayMember = "DistrictName";
                        scbDistrict.DataSource    = _areaBll.GetDistrictList(value.CityID);
                    }
                    else
                    {
                        scbDistrict.DataSource = null;
                    }
                }
                else
                {
                    scbDistrict.DataSource = null;
                }
            };

            RemoveErrorOnControlFocused(
                stbTaoBaoAccount, stbTaoBaoAccount.SkinTxt, errorProvider);
            RemoveErrorOnControlFocused(
                stbTaoBaoPassword, stbTaoBaoPassword.SkinTxt, errorProvider);
            RemoveErrorOnControlFocused(
                stbTaoBaoPayPassword, stbTaoBaoPayPassword.SkinTxt, errorProvider);
            RemoveErrorOnControlFocused(
                scbTaoBaoLevel, scbTaoBaoLevel, errorProvider);
            RemoveErrorOnControlFocused(
                scbConsumptionLevel, scbConsumptionLevel, errorProvider);
            RemoveErrorOnControlFocused(
                slDistrict, scbProvince, errorProvider);
            RemoveErrorOnControlFocused(
                slDistrict, scbCity, errorProvider);
            RemoveErrorOnControlFocused(
                slDistrict, scbDistrict, errorProvider);
            RemoveErrorOnControlFocused(
                stbAge, stbAge.SkinTxt, errorProvider);
            RemoveErrorOnControlFocused(scbSex, scbSex, errorProvider);
            RemoveErrorOnControlFocused(
                stbShippingAddress, stbShippingAddress.SkinTxt, errorProvider);

            sbtnAdd.Click += (sender, e) =>
            {
                if (!CheckControlTextNullOrEmpty(stbTaoBaoAccount,
                                                 stbTaoBaoAccount.SkinTxt, errorProvider, "淘宝帐号不能为空!"))
                {
                    return;
                }
                if (!CheckControlTextNullOrEmpty(stbTaoBaoPassword,
                                                 stbTaoBaoPassword.SkinTxt, errorProvider, "登录密码不能为空!"))
                {
                    return;
                }

                if (!CheckControlTextNullOrEmpty(stbTaoBaoPayPassword,
                                                 stbTaoBaoPayPassword.SkinTxt, errorProvider, "支付密码不能为空!"))
                {
                    return;
                }

                if (!CheckControlTextNullOrEmpty(scbTaoBaoLevel,
                                                 scbTaoBaoLevel, errorProvider, "小号等级不能为空!"))
                {
                    return;
                }

                if (!CheckControlTextNullOrEmpty(scbConsumptionLevel,
                                                 scbConsumptionLevel, errorProvider, "小号信用等级不能为空!"))
                {
                    return;
                }

                if (!CheckControlTextNullOrEmpty(slDistrict,
                                                 scbProvince, errorProvider, "所在地区:省、市、区不能为空!"))
                {
                    return;
                }

                if (!CheckControlTextNullOrEmpty(slDistrict,
                                                 scbCity, errorProvider, "所在地区:省、市、区不能为空!"))
                {
                    return;
                }

                if (!CheckControlTextNullOrEmpty(slDistrict,
                                                 scbDistrict, errorProvider, "所在地区:省、市、区不能为空!"))
                {
                    return;
                }

                if (!CheckControlTextNullOrEmpty(stbAge,
                                                 stbAge.SkinTxt, errorProvider, "年龄不能为空!"))
                {
                    return;
                }

                byte age;
                if (!byte.TryParse(stbAge.SkinTxt.Text, out age))
                {
                    errorProvider.SetError(stbAge, "请输入正确的年龄!");
                    return;
                }

                if (!CheckControlTextNullOrEmpty(scbSex,
                                                 scbSex, errorProvider, "性别不能为空!"))
                {
                    return;
                }

                if (!CheckControlTextNullOrEmpty(stbShippingAddress,
                                                 stbShippingAddress.SkinTxt, errorProvider, "收货地址不能为空!"))
                {
                    return;
                }

                var subAccount = new UserSubAccount
                {
                    TaoBaoAccount    = stbTaoBaoAccount.SkinTxt.Text.Trim(),
                    Password         = stbTaoBaoPassword.SkinTxt.Text.Trim(),
                    PayPassword      = stbTaoBaoPayPassword.SkinTxt.Text.Trim(),
                    HomePage         = stbHomePage.SkinTxt.Text.Trim(),
                    Level            = (scbTaoBaoLevel.SelectedItem as TaoBaoLevel).Id,
                    ConsumptionLevel = (scbConsumptionLevel.SelectedItem as ConsumptionLevel).Id,
                    Province         = scbProvince.Text,
                    City             = scbCity.Text,
                    District         = scbDistrict.Text,
                    Age             = age,
                    Sex             = scbSex.SelectedIndex == 0,
                    ShippingAddress = stbShippingAddress.SkinTxt.Text.Trim(),
                    IsRealName      = scbRealName.Checked,
                    IsBindingMobile = scbBindingMobile.Checked,
                    IsEnabled       = scbEnabled.Checked
                };

                int temp;
                if (int.TryParse(stbUpperLimitAmount.SkinTxt.Text, out temp))
                {
                    subAccount.UpperLimitAmount = temp;
                }

                if (int.TryParse(stbUpperLimitNumber.SkinTxt.Text, out temp))
                {
                    subAccount.UpperLimitNumber = temp;
                }

                if (int.TryParse(stbCommission.SkinTxt.Text, out temp))
                {
                    subAccount.Commission = temp;
                }

                _subAccountBll.Add(subAccount, state =>
                {
                    string info = string.Empty;

                    switch (state)
                    {
                    case UserSubAccountOptState.Failed:
                        info = "服务器异常,添加小号失败!";
                        break;

                    case UserSubAccountOptState.CannotConnectServer:
                        info = "连接服务器失败!";
                        break;

                    case UserSubAccountOptState.InvalidOpt:
                        info = "非法操作!与服务器连接断开,请稍后重试!";
                        break;

                    case UserSubAccountOptState.Successed:
                        info = "添加小号成功!";
                        break;
                    }

                    Invoke(() =>
                    {
                        MessageBoxEx.Show(this, info, "添加小号", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (state == UserSubAccountOptState.Successed)
                        {
                            Clear();
                            var owner = this.Owner as ViewSubAccountManage;
                            if (owner != null)
                            {
                                owner.BindUserSubAccountList();
                            }
                        }
                    });
                });
            };
        }
예제 #2
0
        void Init()
        {
            SetToMax();

            _orderRecordControl      = new OrderRecordListControl(_shopBll, _orderStateBll);
            _orderRecordControl.Dock = DockStyle.Fill;
            tpShippingList.Controls.Add(_orderRecordControl);

            skinTabControl.SelectedIndexChanged += (sender, e) =>
            {
                if (skinTabControl.SelectedIndex == 1 &&
                    !_remoteDeskConnectState.Connected)
                {
                    LoadOrderRecordPageList(1,
                                            _orderRecordControl.PaginationOrderRecordList.PageSize);
                }
            };

            _remoteDeskConnectState = new RemoteDeskConnectState();
            _remoteDeskCheckTimer   = new System.Threading.Timer(
                RemoteDeskCheckTimerCallback, null, Timeout.Infinite, 2000);

            sdgvSubAccountList.AutoGenerateColumns = false;
            sdgvSubAccountList.CellFormatting     += (sender, e) =>
            {
                switch (e.ColumnIndex)
                {
                case 1:
                    string acc = e.Value as string;
                    if (!string.IsNullOrEmpty(acc))
                    {
                        int result;
                        int markCount = Math.DivRem(acc.Length, 2, out result);
                        if (result != 0)
                        {
                            markCount++;
                        }

                        var accArray = acc.ToCharArray();
                        for (int i = 1; i <= markCount; i += 1)
                        {
                            accArray[acc.Length - i] = '*';
                        }

                        e.Value = new string(accArray);
                    }
                    break;

                case 2:
                    byte?index = (byte?)e.Value;
                    if (index.HasValue)
                    {
                        e.Value = ConstData.TaoBaoLevels[index.Value - 1].Name;
                    }
                    break;

                case 3:
                    bool?sex = (bool?)e.Value;
                    if (sex.HasValue)
                    {
                        e.Value = sex.Value ? "男" : "女";
                    }
                    break;

                case 5:
                    var data = sdgvSubAccountList.DataSource as IList <UserSubAccountPageListVM>;
                    if (data != null && data.Count > e.RowIndex)
                    {
                        var vm = data[e.RowIndex];
                        e.Value = string.Format("{0} - {1} - {2}", vm.Province, vm.City, vm.District);
                    }
                    break;

                case 8:
                    if ((bool)e.Value)
                    {
                        e.Value = "在线";
                        e.CellStyle.BackColor          = Color.Green;
                        e.CellStyle.SelectionBackColor = Color.Green;
                    }
                    else
                    {
                        e.Value = "离线";
                        e.CellStyle.BackColor          = Color.Red;
                        e.CellStyle.SelectionBackColor = Color.Red;
                    }
                    break;

                case 9:
                    if (e.Value == null)
                    {
                        e.Value = "未连接";
                    }

                    if (e.Value.ToString().Equals("正在连接"))
                    {
                        e.CellStyle.BackColor          = Color.Yellow;
                        e.CellStyle.SelectionBackColor = Color.Yellow;
                        e.CellStyle.ForeColor          = Color.Red;
                        e.CellStyle.SelectionForeColor = Color.Red;
                    }
                    break;

                case 10:
                    if (e.Value == null)
                    {
                        e.Value = "连接";
                    }
                    break;

                case 11:
                    int?dayCount = e.Value as int?;
                    if (dayCount.HasValue && dayCount.Value >= 3)
                    {
                        e.CellStyle.BackColor =
                            e.CellStyle.SelectionBackColor = Color.Red;
                    }
                    break;

                case 13:
                    var orderTypeDetailsList = e.Value as IList <OrderTypeDetails>;
                    if (orderTypeDetailsList != null && orderTypeDetailsList.Count > 0)
                    {
                        StringBuilder orderTypeSb = new StringBuilder();
                        foreach (var orderTypeDetails in orderTypeDetailsList)
                        {
                            orderTypeSb.AppendFormat("{0}({1}) ",
                                                     orderTypeDetails.Name, orderTypeDetails.Count);
                        }
                        e.Value = orderTypeSb.ToString();
                    }
                    else
                    {
                        e.Value = string.Empty;
                    }
                    break;
                }
            };

            sdgvSubAccountList.CellContentClick += (sender, e) =>
            {
                if (e.RowIndex == -1)
                {
                    return;
                }

                if (e.ColumnIndex == 10)
                {
                    var row   = sdgvSubAccountList.Rows[e.RowIndex];
                    var value = row.Cells[e.ColumnIndex].FormattedValue.ToString();
                    if (string.Equals(value, "连接"))
                    {
                        if (_remoteDeskConnectState.Connected)
                        {
                            MessageBoxEx.Show(this,
                                              "已经连接挂机端操作,不能同时进行多个连接操作!",
                                              "连接挂机端",
                                              MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        //开始连接前,关闭所有连接窗口。
                        while (AnyDesk.IsClientOpened())
                        {
                            AnyDesk.CloseClient();
                        }

                        if ((bool)row.Cells[8].Value)
                        {
                            _remoteDeskConnectState.Connected = true;
                            var view = _viewFactory.GetView <ViewReadyConnectClient>();
                            view.Model = row.DataBoundItem as UserSubAccountPageListVM;
                            if (view.ShowDialog(this) != DialogResult.OK)
                            {
                                _remoteDeskConnectState.Connected = false;
                            }
                        }
                        else
                        {
                            MessageBoxEx.Show(this,
                                              "该挂机端不在线,不能连接!\r\n\r\n可尝试刷新挂机端信息后,再进行操作。",
                                              "连接挂机端",
                                              MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                    else
                    {
                        while (AnyDesk.IsClientOpened())
                        {
                            AnyDesk.CloseClient();
                        }
                        StartOrderRecord();
                    }
                }
            };

            scbProvince.SelectedIndexChanged += (sender, e) =>
            {
                if (scbProvince.SelectedIndex != -1)
                {
                    var value = scbProvince.SelectedItem as Province;
                    if (value.ProvinceID != -1)
                    {
                        scbCity.DisplayMember = "CityName";
                        scbCity.DataSource    = _areaBll.GetCityList(value.ProvinceID);
                    }
                    else
                    {
                        scbCity.DataSource     = null;
                        scbDistrict.DataSource = null;
                    }
                }
                else
                {
                    scbCity.DataSource     = null;
                    scbDistrict.DataSource = null;
                }
            };

            scbCity.SelectedIndexChanged += (sender, e) =>
            {
                if (scbCity.SelectedIndex != -1)
                {
                    var value = scbCity.SelectedItem as City;
                    if (value.CityID != -1)
                    {
                        scbDistrict.DisplayMember = "DistrictName";
                        scbDistrict.DataSource    = _areaBll.GetDistrictList(value.CityID);
                    }
                    else
                    {
                        scbDistrict.DataSource = null;
                    }
                }
                else
                {
                    scbDistrict.DataSource = null;
                }
            };

            tsmiSubAccManage.Click += (sender, e) =>
            {
                var view = _viewFactory.GetView <ViewSubAccountManage>();
                view.ShowDialog(this);
            };

            tsmiShopManage.Click += (sender, e) =>
            {
                var view = _viewFactory.GetView <ViewShopManage>();
                view.ShowDialog(this);
            };

            tsmiAccountInfo.Click += (sender, e) =>
            {
                var view = _viewFactory.GetView <ViewUserInfo>();
                view.ShowDialog(this);
            };

            tsmiChangePwd.Click += (sender, e) =>
            {
                var view = _viewFactory.GetView <ViewChangePassword>();
                view.ShowDialog(this);
            };

            tsmiAbout.Click += (sender, e) =>
            {
                var view = _viewFactory.GetView <ViewAbout>();
                view.ShowDialog(this);
            };

            paginationSubAccount.Reload += (sender, e) =>
            {
                LoadSubAccountPageList(
                    paginationSubAccount.PageIndex, paginationSubAccount.PageSize);
            };

            sbtnSearch.Click += (sender, e) =>
            {
                LoadSubAccountPageList(
                    1, paginationSubAccount.PageSize);
            };
        }