Esempio n. 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            new BackgroundLoading(this, () => this.Invoke(new Action(() =>
            {
                string userName = txtUserName.Text.Trim();
                string pwd      = txtPwd.Text.Trim();
                if (ValidateLogOn(userName, pwd))
                {
                    LoginModel loginModel = new LoginModel()
                    {
                        UserName = userName, Pwd = pwd
                    };
                    var info = InvokeWebApiHelper.PostLogin(loginModel);
                    if (info != null)
                    {
                        LoginHelper.CurrentUserName = userName;

                        if (ckbRemember.Checked)
                        {
                            LoginHelper.SaveUserInfo(userName);
                        }
                        else
                        {
                            LoginHelper.DeleteUserInfo();
                        }
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        lblPwdTip.Text = "用户名或密码错误";
                    }
                }
            })), "登录中...", "正在验证用户名和密码...").Show();
        }
Esempio n. 2
0
        private void btnSureReGoods_Click(object sender, EventArgs e)
        {
            if (listModel.Count <= 0)
            {
                MessageBox.Show("没有可用的数据!");
                return;
            }
            ResponseResultModel responseResult = InvokeWebApiHelper.PostReturnGoodsResult(listModel);

            if (responseResult.IsSuccess)
            {
                listModel.Clear();
                dgvList.Rows.Clear();
                MessageBox.Show(responseResult.Message);
                txtNumber.Text = string.Empty;
                txtWeight.Text = string.Empty;
                txtNumber.Focus();
                this.txtNumber.Text = string.Empty;
                this.txtWeight.Text = null;
                this.lblCount.Text  = this.dgvList.Rows.Count.ToString();
            }
            else
            {
                btnSureReGoods.Enabled = false;
                MessageBox.Show(responseResult.Message);
            }
            i = 1;
        }
Esempio n. 3
0
 /// <summary>
 /// 绑定物流
 /// </summary>
 void BindVenders(string customerId, string typeId)
 {
     this.Invoke(new Action(() =>
     {
         this.cbbInStorage.DataSource    = InvokeWebApiHelper.GetCustomerShippingMethodsByCustomerId(customerId, typeId, false);
         this.cbbInStorage.ValueMember   = "ShippingMethodId";
         this.cbbInStorage.DisplayMember = "FullName";
         this.txtNumber.Focus();
     }));
 }
Esempio n. 4
0
        private void Bind()
        {
            string keyWord = this.txtKeyword.Text.Trim();

            var action = new Action(() =>
            {
                this.ddvCustomerList.DataSource          = InvokeWebApiHelper.GetCustomerListCS(keyWord);
                this.ddvCustomerList.AutoGenerateColumns = true;
                this.ddvCustomerList.ClearSelection();
            });

            if (this.IsHandleCreated && this.InvokeRequired)
            {
                this.Invoke(action);
            }
            else
            {
                action();
            }
        }
Esempio n. 5
0
        private void ChechUpdate()
        {
            var updateResponse = InvokeWebApiHelper.GetLatestVersion(AppName);

            if (updateResponse == null || !updateResponse.Success)
            {
                MessageBox.Show("检测版本失败!");
                Environment.Exit(0);
            }
            else if (updateResponse.Version != Version)
            {
                MessageBox.Show("有新版本发布,请升级!");
                Process p = new Process();
                p.StartInfo.FileName  = "iexplore.exe";
                p.StartInfo.Arguments = updateResponse.Url;
                p.Start();
                p.Dispose();
                Environment.Exit(0);
            }
        }
Esempio n. 6
0
        List <InstorageInfoViewModel> BrandModel(string inStorageID)
        {
            List <InstorageInfoViewModel> model = InvokeWebApiHelper.GetPrintInStorageInvoice(inStorageID);

            return(model);
        }
Esempio n. 7
0
        private void txtNumber_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (string.IsNullOrWhiteSpace(txtNumber.Text.Trim()))
                {
                    lblTip.Text = "请输入单号";
                    txtNumber.Focus();
                    PlayFailSound();
                    return;
                }
                entity = InvokeWebApiHelper.GetInFeeTotalInfo(txtNumber.Text.Trim());

                if (entity != null)
                {
                    if (entity.WayBillStatus ==
                        LMS.Data.Entity.WayBill.StatusToValue(LMS.Data.Entity.WayBill.StatusEnum.WaitOrder) ||
                        entity.WayBillStatus ==
                        LMS.Data.Entity.WayBill.StatusToValue(LMS.Data.Entity.WayBill.StatusEnum.Send))
                    {
                        if (listModel.Exists(p => p.WayBillNumber.Equals(entity.WayBillNumber)))
                        {
                            this.txtNumber.Focus();
                            this.txtNumber.Text = string.Empty;
                            this.txtWeight.Text = string.Empty;
                            lblTip.Text         = entity.WayBillNumber + " 数据已经存在,不能重复添加";
                            PlayFailSound();
                            return;
                        }

                        lblTip.Text       = entity.CustomerName + " 扫描通过";
                        btnSubmit.Enabled = true;

                        PlaySuccessSound();
                    }
                    else
                    {
                        lblTip.Text       = txtNumber.Text + " 该单不是已发货和待转单的运单!";
                        btnSubmit.Enabled = false;
                        this.txtNumber.Focus();
                        this.txtNumber.Text = string.Empty;
                        this.txtWeight.Text = string.Empty;
                        PlayFailSound();
                        return;
                    }
                }
                else
                {
                    lblTip.Text       = txtNumber.Text + " 该单不存在或已删除!";
                    btnSubmit.Enabled = false;
                    this.txtNumber.Focus();
                    this.txtNumber.Text = string.Empty;
                    this.txtWeight.Text = string.Empty;
                    PlayFailSound();
                    return;
                }

                if (cbxWeight.Checked)
                {
                    txtWeight.Focus();
                }
                else
                {
                    VerificationData();
                }

                lblCount.Text = dgvList.Rows.Count.ToString();
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 添加件
        /// </summary>
        private void AddPiece()
        {
            #region 检查数据

            if (waybillList.Exists(p => p.WayBillNumber.Equals(this.txtNumber.Text.Trim()) || p.CustomerOrderNumber.Equals(this.txtNumber.Text.Trim())))
            {
                lblTsg.Text = "数据已经存在,不能重复添加";
                return;
            }

            if (string.IsNullOrWhiteSpace(this.txtPieces.Text))
            {
                return;
            }

            if (int.Parse(this.txtPieces.Text.Trim()) == dgvPackageList.Rows.Count)
            {
                lblTsg.Text = "输入件数与行数相等,请确认提交!";
                btnSubmit.Focus();
                return;
            }

            if (int.Parse(this.txtPieces.Text.Trim()) < dgvPackageList.Rows.Count)
            {
                lblTsg.Text = "行数与列表数不对!";
                return;
            }


            if (string.IsNullOrWhiteSpace(this.txtNumber.Text))
            {
                this.lblTsg.Text = "请输入订单号/运单号!";
                this.txtNumber.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(this.txtPieces.Text))
            {
                this.lblTsg.Text = "请输入件数!";
                this.txtPieces.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(this.txtWeights.Text))
            {
                this.lblTsg.Text = "请输入重量!";
                this.txtWeights.Focus();
                return;
            }

            double weightValue;
            double.TryParse(this.txtWeights.Text, out weightValue);
            if (Convert.ToDouble(weightValue) < 0.005)
            {
                this.lblTsg.Text = "重量不能小于0.005!";
                this.txtWeights.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(this.txtLong.Text))
            {
                this.lblTsg.Text = "请输入长!";
                this.txtLong.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(this.txtWidth.Text))
            {
                this.lblTsg.Text = "请输入宽!";
                this.txtWidth.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(this.txtHeight.Text))
            {
                this.lblTsg.Text = "请输入高!";
                this.txtHeight.Focus();
                return;
            }

            #endregion

            decimal[] wlw       = new decimal[] { decimal.Parse(txtLong.Text.Trim()), decimal.Parse(txtWidth.Text.Trim()), decimal.Parse(txtHeight.Text.Trim()) };
            decimal[] wlwSorted = wlw.OrderByDescending(m => m).ToArray();
            WaybillPackageDetailModel waybillDetailModel = new WaybillPackageDetailModel()
            {
                PackageDetailID = Guid.NewGuid().ToString(),     //唯一包裹序号
            };

            requestModel.CustomerCode         = this.txtCustomers.Text.Trim();
            requestModel.GoodsTypeID          = (int)cbbGoodsType.SelectedValue;
            requestModel.ShippingMethodId     = (int)cbbInStorage.SelectedValue;
            requestModel.IsBusinessExpress    = ((ShippingMethodModel)cbbInStorage.SelectedItem).ShippingMethodTypeId == 2;
            requestModel.OperatorUserName     = LoginHelper.CurrentUserName;
            requestModel.WayBillNumber        = this.txtNumber.Text.Trim();
            requestModel.CustomerType         = int.Parse(CustomerTypeID);
            requestModel.Weight               = decimal.Parse(txtWeights.Text.Trim());
            requestModel.Length               = wlwSorted[0];
            requestModel.Width                = wlwSorted[1];
            requestModel.Height               = wlwSorted[2];
            waybillDetailModel.ShippingMethod = cbbInStorage.SelectedText;
            waybillDetailModel.WayBillNumber  = txtWaybillNumber.Text.Trim();
            waybillDetailModel.Weight         = decimal.Parse(txtWeights.Text.Trim());
            waybillDetailModel.Length         = wlwSorted[0];
            waybillDetailModel.Width          = wlwSorted[1];
            waybillDetailModel.Height         = wlwSorted[2];

            //检查单个包裹
            ResponseModel = InvokeWebApiHelper.CheckOnInStorage(requestModel);
            if (ResponseModel == null)
            {
                return;
            }

            //检查失败
            if (!ResponseModel.IsSuccess)
            {
                this.lblTsg.Text = ResponseModel.Message.Replace("<br/>", "");
                PlayFailSound();
                return;
            }

            if (ResponseModel.SettleWeight == 0)
            {
                MessageBox.Show("错误:结算重量为零");
                return;
            }


            waybilldetailList.Add(waybillDetailModel);
            this.dgvPackageList.Rows.Insert(0, new object[] { 0, waybillDetailModel.PackageDetailID, waybillDetailModel.Weight, waybillDetailModel.Length, waybillDetailModel.Width, waybillDetailModel.Height });

            #region 清空数据,重新定位光标

            if (!cbxWeight.Checked)
            {
                txtWeights.Focus();
            }
            else if (cbxVolume.Checked)
            {
                txtHeight.Focus();
            }
            else
            {
                txtLong.Focus();
            }

            if (!cbxWeight.Checked && txtWeights.Enabled)
            {
                txtWeights.Text = "";
            }
            if (!cbxVolume.Checked && (txtLong.Enabled && txtWidth.Enabled && txtHeight.Enabled))
            {
                txtLong.Text   = "";
                txtWidth.Text  = "";
                txtHeight.Text = "";
            }

            #endregion


            //如果件数与已录入的件数相等,直接提交
            if (int.Parse(this.txtPieces.Text.Trim()) == dgvPackageList.Rows.Count)
            {
                if (btnSubmit.Enabled)
                {
                    btnSubmit_Click(null, null);
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 检查运单号
        /// </summary>
        private bool CheckWayBill()
        {
            this.lblTsg.Text        = "";
            this.lblCountyName.Text = "";

            if (string.IsNullOrWhiteSpace(this.txtCustomers.Text))
            {
                this.lblTsg.Text = "客户不能为空!";
                return(false);
            }

            if (cbbInStorage.SelectedValue == null)
            {
                this.lblTsg.Text = "运输方式不能为空!";
                return(false);
            }

            if (waybillList.Exists(p => p.WayBillNumber.Equals(this.txtNumber.Text.Trim()) || p.CustomerOrderNumber.Equals(this.txtNumber.Text.Trim())))
            {
                lblTsg.Text = "数据已经存在,不能重复添加";
                return(false);
            }

            clearLeft(false);

            InStorageFormModel model = new InStorageFormModel();

            model.CustomerCode     = this.txtCustomers.Text.Trim();
            model.GoodsTypeID      = (int)cbbGoodsType.SelectedValue;
            model.ShippingMethodId = (int)cbbInStorage.SelectedValue;
            model.WayBillNumber    = this.txtNumber.Text.Trim();
            model.CustomerType     = int.Parse(CustomerTypeID);
            model.OperatorUserName = LoginHelper.CurrentUserName;


            inStorageModel = InvokeWebApiHelper.CheckOnWayBill(model);
            if (inStorageModel != null)
            {
                this.btnSubmit.Enabled = inStorageModel.Result;

                if (inStorageModel.Result)
                {
                    this.lblTsg.Text        = "运单: " + model.WayBillNumber + " 扫描通过";
                    this.lblCountyName.Text = inStorageModel.Message;

                    if (this.txtPieces.Enabled && !cbxPieces.Checked)
                    {
                        this.txtPieces.Focus();
                    }
                    else
                    {
                        txtPiecesNext();
                    }

                    return(true);
                }
                else    //如果扫描不通过,清空数据
                {
                    this.lblTsg.Text    = inStorageModel.Message.Replace("<br/>", "");
                    this.txtNumber.Text = "";

                    waybilldetailList.Clear();
                    this.dgvPackageList.Rows.Clear();

                    this.txtNumber.Focus();

                    this.lblCountyName.Text = string.Empty;

                    if (!cbxWeight.Checked && this.txtWeights.Enabled)
                    {
                        this.txtWeights.Text = string.Empty;
                    }

                    //if (!cbxVolume.Checked)
                    //{
                    //    this.txtLong.Text = string.Empty;
                    //    this.txtWidth.Text = string.Empty;
                    //    this.txtHeight.Text = string.Empty;
                    //}
                }
            }
            else
            {
                MessageBox.Show("网络异常");
            }
            return(false);
        }
Esempio n. 10
0
        private void btnInStorage_Click(object sender, EventArgs e)
        {
            if (waybillList.Count <= 0)
            {
                MessageBox.Show("入库数据不能为空!");
                return;
            }

            InStorageSaveModel saveModel = new InStorageSaveModel();

            saveModel.CustomerCode     = this.txtCustomers.Text.Trim();
            saveModel.OperatorUserName = LoginHelper.CurrentUserName;
            saveModel.ReceivingDate    = txtReceivingDate.Text;
            if (waybillList != null && waybillList.Count > 0)
            {
                //遍历每个运单
                foreach (var waybill in waybillList)
                {
                    WayBillInfoSaveModel w = new WayBillInfoSaveModel();
                    w.WayBillNumber     = waybill.WayBillNumber;
                    w.Length            = waybill.Length.Value;
                    w.Width             = waybill.Width.Value;
                    w.Height            = waybill.Height.Value;
                    w.SettleWeight      = waybill.SettleWeight == null ? 0 : waybill.SettleWeight.Value;
                    w.Weight            = waybill.Weight.Value;
                    w.PriceResult       = waybill.PriceResult;
                    w.GoodsTypeID       = waybill.GoodsTypeID.Value;
                    w.ShippingMethodId  = waybill.InShippingMethodID.Value;
                    w.IsBusinessExpress = waybill.ShippingMethodTypeId == 2;
                    w.IsBattery         = waybill.IsBattery;
                    w.SensitiveType     = waybill.SensitiveType;

                    //遍历运单的每个包裹
                    foreach (var dateil in waybill.WaybillPackageDetaillList)
                    {
                        WaybillPackageDetailModel wayDetailModel = new WaybillPackageDetailModel();
                        wayDetailModel.WayBillNumber = dateil.WayBillNumber;
                        wayDetailModel.Weight        = dateil.Weight;
                        wayDetailModel.AddWeight     = dateil.AddWeight;
                        wayDetailModel.SettleWeight  = dateil.SettleWeight;
                        wayDetailModel.Length        = dateil.Length;
                        wayDetailModel.Width         = dateil.Width;
                        wayDetailModel.Height        = dateil.Height;
                        wayDetailModel.LengthFee     = dateil.LengthFee == null ? 0 : dateil.LengthFee.Value;
                        wayDetailModel.WeightFee     = dateil.WeightFee == null ? 0 : dateil.WeightFee.Value;
                        w.waybillPackageDetailList.Add(wayDetailModel);
                    }

                    saveModel.WayBillInfoSaveList.Add(w);
                }
            }


            ResponseResult responseResult = null;

            new BackgroundLoading(this, () =>
            {
                responseResult = InvokeWebApiHelper.CreateInStorageCS(saveModel);
            }, "正在提交到服务器...", "正在提交到服务器...").Show();

            if (responseResult == null)
            {
                MessageBox.Show("保存失败,请重试!");
                return;
            }

            if (responseResult.Result)
            {
                waybillList = new List <WayBillInfoModel>();
                this.dgvWaybillList.Rows.Clear();
                this.lblCount.Text       = "0";
                this.lblCountWeight.Text = "0";
                FrmInStorageInfo inStoragt = new FrmInStorageInfo(responseResult.Message);
                inStoragt.ShowDialog();
                //inStoragt.MdiParent = this;
            }
            else
            {
                MessageBox.Show(responseResult.Message);
            }
        }
Esempio n. 11
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            #region 检查输入数据

            if (string.IsNullOrWhiteSpace(this.txtPieces.Text))
            {
                this.lblTsg.Text = "请输入件数!";
                this.txtPieces.Focus();
                return;
            }

            if (int.Parse(this.txtPieces.Text.Trim()) != dgvPackageList.Rows.Count)
            {
                this.lblTsg.Text = "输入的件数与行数不正确!请检查";
                return;
            }

            #endregion

            WayBillInfoModel waybillModel = new WayBillInfoModel();

            CustomerInfoPackageRequest waybillRequest     = new CustomerInfoPackageRequest();
            List <PackageRequest>      packageRequestList = new List <PackageRequest>();

            //生成运费请求
            foreach (var package in waybilldetailList)
            {
                PackageRequest packageRequest = new PackageRequest();
                packageRequest.Weight = package.Weight.Value;
                packageRequest.Length = package.Length.Value;
                packageRequest.Width  = package.Width.Value;
                packageRequest.Height = package.Height.Value;
                packageRequestList.Add(packageRequest);
            }

            waybillRequest.CustomerId         = Guid.Parse(this.CustomerId);
            waybillRequest.CountryCode        = ResponseModel.CountryCode;
            waybillRequest.ShippingMethodId   = (int)cbbInStorage.SelectedValue;
            waybillRequest.ShippingTypeId     = (int)cbbGoodsType.SelectedValue;
            waybillRequest.Packages           = packageRequestList;
            waybillRequest.EnableTariffPrepay = ResponseModel.EnableTariffPrepay;//是否启用运费预付服务
            waybillRequest.ShippingInfo       = inStorageModel.ShippingInfo;

            //计算运费
            PriceProviderExtResult priceResult = InvokeWebApiHelper.PostCustomerPriceAuto(waybillRequest);

            if (priceResult == null)
            {
                this.lblTsg.Text = "网络错误,请重试";
                return;
            }

            //如果不能邮寄
            if (!priceResult.CanShipping)
            {
                this.lblTsg.Text = priceResult.Message;

                clearLeft();

                txtNumber.Focus();
                return;
            }

            var sumSettleWeight = priceResult.Weight;//结算重量
            var sumWeight       = priceResult.Weight;

            #region 包裹长宽高求和

            decimal sumLeng   = 0;
            decimal sumWidth  = 0;
            decimal sumHeight = 0;
            if (priceResult.PackageDetails.Count() > 0)
            {
                sumLeng = (from s in priceResult.PackageDetails
                           select s.Length).Sum();
                sumWidth = (from s in priceResult.PackageDetails
                            select s.Width).Sum();
                sumHeight = (from s in priceResult.PackageDetails
                             select s.Height).Sum();
            }

            #endregion

            if (!waybillList.Exists(p => p.WayBillNumber.Equals(ResponseModel.WayBillNumber)))
            {
                waybillModel.CountryCode = ResponseModel.CountryCode;
                waybillModel.Pieces      = Convert.ToInt32(txtPieces.Text.Trim());

                waybillModel.SettleWeight         = sumSettleWeight;
                waybillModel.Length               = sumLeng;
                waybillModel.Width                = sumWidth;
                waybillModel.Height               = sumHeight;
                waybillModel.WayBillNumber        = ResponseModel.WayBillNumber;
                waybillModel.TrackingNumber       = ResponseModel.TrackingNumber;
                waybillModel.CustomerOrderNumber  = ResponseModel.CustomerOrderNumber;
                waybillModel.InShippingMethodID   = (int)cbbInStorage.SelectedValue;
                waybillModel.ShippingMethodTypeId = ((ShippingMethodModel)cbbInStorage.SelectedItem).ShippingMethodTypeId;
                waybillModel.InShippingMethodName = cbbInStorage.Text;
                waybillModel.GoodsTypeID          = (int)cbbGoodsType.SelectedValue;
                waybillModel.PriceResult          = priceResult;
                waybillModel.IsBattery            = cbxBattery.Checked;
                waybillModel.SensitiveType        = cbxBattery.Checked?(int?)cbbSensitiveType.SelectedValue:null;

                //以下方便测试
                #region 弹出费用明细

                if (File.Exists(Application.StartupPath + @"\debug.txt"))
                {
                    showPriceProviderResult(priceResult);
                }

                #endregion

                #region 包裹明细赋值

                for (int j = 0; j < waybilldetailList.Count; j++)
                {
                    var r = waybilldetailList[j];
                    WaybillPackageDetailModel model = new WaybillPackageDetailModel();
                    model.WayBillNumber = r.WayBillNumber;
                    model.Pieces        = r.Pieces;
                    model.Weight        = priceResult.PackageDetails[j].Weight;
                    model.AddWeight     = priceResult.PackageDetails[j].AddWeight;
                    model.SettleWeight  = priceResult.PackageDetails[j].SettleWeight;
                    model.Length        = r.Length;
                    model.Width         = r.Width;
                    model.Height        = r.Height;
                    model.LengthFee     = priceResult.PackageDetails[j].OverGirthFee;
                    model.WeightFee     = priceResult.PackageDetails[j].OverWeightOrLengthFee;
                    waybillModel.WaybillPackageDetaillList.Add(model);
                }

                waybillModel.Weight = waybillModel.WaybillPackageDetaillList.Sum(p => (p.Weight + (p.AddWeight ?? 0)));

                #endregion


                waybillList.Add(waybillModel);
            }

            if (cbxPrintLable.Checked)//打印报表
            {
                string frxPath = Application.StartupPath + @"\Resource\PackageLable.frx";

                if (!File.Exists(frxPath))
                {
                    MessageBox.Show("找不到货物标签打印模板:" + frxPath);
                    return;
                }

                Report report = new Report();

                report.Load(frxPath);
                report.RegisterData(waybilldetailList, "waybilldetailList");
                var      datasource = report.GetDataSource("waybilldetailList");
                DataBand data1      = report.FindObject("data1") as DataBand;
                if (data1 != null)
                {
                    data1.DataSource = datasource;
                }
                report.Prepare();
                report.PrintSettings.ShowDialog = true;
                //report.Show();
                report.Print();
                report.Dispose();
            }

            updateScanInfo();

            this.dgvWaybillList.Rows.Add(new object[] { waybillModel.WayBillNumber, waybillModel.TrackingNumber, waybillModel.CustomerOrderNumber, waybillModel.InShippingMethodName, waybillModel.Pieces, waybillModel.SettleWeight, waybillModel.CountryCode, "删除" });
            clearLeft();
            txtNumber.Focus();

            PlaySuccessSound();
        }