Ejemplo n.º 1
0
        public void PopulateDataGridView(ReturnGoodsExt model)
        {
            if (model == null)
            {
                return;
            }
            int index = this.dgvList.Rows.Add();

            this.dgvList.Rows[index].Cells[0].Value  = i;
            this.dgvList.Rows[index].Cells[1].Value  = model.WayBillNumber;
            this.dgvList.Rows[index].Cells[2].Value  = model.CustomerOrderNumber;
            this.dgvList.Rows[index].Cells[3].Value  = model.CustomerName;
            this.dgvList.Rows[index].Cells[4].Value  = model.TotalFee;
            this.dgvList.Rows[index].Cells[5].Value  = model.PackageNumber;
            this.dgvList.Rows[index].Cells[6].Value  = model.WayBillWeight;
            this.dgvList.Rows[index].Cells[7].Value  = model.Weight;
            this.dgvList.Rows[index].Cells[8].Value  = model.ShippingMethodName;
            this.dgvList.Rows[index].Cells[9].Value  = model.CountryName;
            this.dgvList.Rows[index].Cells[10].Value = "取消";
            //运单原重量与退货重量相差100g 用颜色标识该行
            if (cbxWeight.Checked)
            {
                if ((model.WayBillWeight * 1000) - (model.Weight * 1000) >= 100 ||
                    (model.Weight * 1000) - (model.WayBillWeight * 1000) >= 100)
                {
                    this.dgvList.Rows[index].DefaultCellStyle.ForeColor = Color.Red;
                }
            }
            i++;
            //foreach (DataGridViewColumn c in dgvList.Columns)
            //{
            //    c.SortMode = DataGridViewColumnSortMode.Automatic;
            //}

            // DataGridViewColumn sortColumn = dgvList.CurrentCell.OwningColumn;

            //设定排序的方向(升序、降序)
            // ListSortDirection sortDirection = ListSortDirection.Descending;
            //if (dgvList.SortedColumn != null &&
            //     dgvList.SortedColumn.Equals(sortColumn))
            //{
            //    sortDirection =
            //        dgvList.SortOrder == SortOrder.Ascending ? ListSortDirection.Ascending : ListSortDirection.Ascending;
            //       // ListSortDirection.Descending : ListSortDirection.Ascending;
            //}

            //进行排序
            dgvList.Columns[0].Visible = false;
            //this.dgvList.Rows[index].Cells[0].Visible = false;
            dgvList.Sort(dgvList.Columns[0], System.ComponentModel.ListSortDirection.Descending);
            //  dgvList.Sort(sortColumn, sortDirection);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 验证用户输入的数据
        /// </summary>
        public void VerificationData()
        {
            if (entity == null)
            {
                lblTip.Text = "请按下回车键,查询该单是否存在";
                return;
            }



            if (cbxWeight.Checked)
            {
                string s   = @"^\d{1,7}(?:\.\d{0,2}$|$)";
                Regex  reg = new Regex(s);
                if (!reg.IsMatch(this.txtWeight.Text))
                {
                    btnSubmit.Enabled = false;
                    lblTip.Text       = "请输入数字或小数,小数位最多为2位";
                }
                else
                {
                    lblTip.Text       = "";
                    btnSubmit.Enabled = true;
                }
            }

            ReturnGoodsExt model = new ReturnGoodsExt()
            {
                UserName            = LoginHelper.GetUserName(),
                WayBillNumber       = entity.WayBillNumber,
                CustomerName        = entity.CustomerName,
                CustomerID          = entity.CustomerID,
                CustomerCode        = entity.CustomerCode,
                CountryName         = entity.ChineseName,
                CustomerOrderNumber = entity.CustomerOrderNumber,
                //Freight = entity.Freight,
                //FuelCharge = entity.FuelCharge,
                InStorageID   = entity.InStorageID,
                PackageNumber = entity.PackageNumber,
                TotalFee      = entity.TotalFee,
                //Surcharge = entity.Surcharge,
                //Register = entity.Register,
                TariffPrepayFee    = entity.TariffPrepayFee,
                ShippingMethodName = entity.ShippingMethodName,
                WayBillWeight      = entity.SettleWeight
            };

            //
            if (cbxWeight.Checked)
            {
                decimal weight;
                Decimal.TryParse(txtWeight.Text.Trim(), out weight);
                model.Weight = weight;
            }
            else
            {
                model.Weight = entity.Weight;
            }

            model.IsDirectReturnGoods = rbtnDirectReGoods.Checked;

            if (rbtnInternal.Checked || rbtnExternal.Checked)
            {
                model.Type = rbtnInternal.Checked ? 1 : 2;
            }
            else
            {
                lblTip.Text = "请选择退货类型";
                return;
            }
            if (cbbReGoodsReason.Text == "请选择")
            {
                lblTip.Text = "请选择退货原因";
                return;
            }

            model.Reason       = cbbReGoodsReason.Text.Trim();
            model.ReasonRemark = txtRemark.Text.Trim();
            if (rbtnDirectReGoods.Checked)
            {
                if (rbtnReturnTrue.Checked || rbtnReturnFalse.Checked)
                {
                    model.IsReturnShipping = rbtnReturnTrue.Checked;
                }
                else
                {
                    lblTip.Text = "请选择是否退运费";
                    return;
                }
            }

            ////lblTip.Text = "";
            //if (listModel.Exists(p => p.WayBillNumber.Equals(model.WayBillNumber)))
            //{
            //    this.txtNumber.Focus();
            //    this.txtNumber.Text = string.Empty;
            //    this.txtWeight.Text = string.Empty;
            //    lblTip.Text = model.WayBillNumber + " 数据已经存在,不能重复添加";
            //    return;
            //}
            lblTip.Text = entity.CustomerName + " 扫描通过";
            listModel.Add(model);
            PopulateDataGridView(model);
            btnSubmit.Enabled      = false;
            btnSureReGoods.Enabled = true;
            this.txtNumber.Focus();
            this.txtNumber.Text = string.Empty;
            this.txtWeight.Text = string.Empty;
            lblCount.Text       = dgvList.Rows.Count.ToString();
        }