Пример #1
0
        /// 初始化界面绑定
        private void InitFormValues()
        {
            dateCreateTrade.DateTime = DateTime.Now;                                     //订单时间
            dateEndTrade.DateTime    = DateTime.Now.AddDays(Constants.DEFAULT_END_DAYS); //默认为15天过后

            #region 客户名称
            cmbConsumerName.Properties.DataSource = ConsumerService.GetAllConsumer();
            cmbConsumerName.Properties.NullText   = "请选择客户";
            #endregion

            #region 收款方式
            cmbPayWay.Properties.DataSource = CodeService.GetCode(p => p.CodeCategory == Constants.CODE_TRADE_TYPE);
            cmbPayWay.EditValue             = Constants.DEFAULT_TRADE_TYPE;
            #endregion

            #region 销售人员
            cmbSeller.Properties.DataSource = UserService.GetAllUser();//待添加条件选择
            cmbSeller.Properties.NullText   = "请选择销售人员";
            #endregion

            #region 承担方式
            cmbStandWay.Properties.DataSource = CodeService.GetCode(p => p.CodeCategory == Constants.CODE_POSTFEE_OWNER);
            cmbStandWay.EditValue             = Constants.DEFAULT_POSTFEE_OWNER;
            #endregion

            #region 物流信息系列绑定
            try
            {
                cmbShippingType.Properties.DataSource = CodeService.GetCode(p => p.CodeCategory == Constants.CODE_SHIPPING_TYPE);
                cmbShippingType.EditValue             = Constants.DEFAULT_SHIPPING_TYPE;

                // 物流公司
                List <LogisticCompany> companySource = LogisticCompanyService.GetLogisticCompany(p => p.shippingType == cmbShippingType.EditValue.ToString());
                cmbShipCompany.Properties.DataSource = companySource;
                cmbShipCompany.EditValue             = companySource.FirstOrDefault(p => p.isdefault == true).code;

                //物流模板
                List <LogisticCompanyTemplate> templateSource = LogisticCompanyTemplateService.GetLogisticCompanyTemplate(p => p.LogisticCompanyCode == cmbShipCompany.EditValue.ToString());
                cmbShippingTemplate.Properties.DataSource = templateSource;
                cmbShippingTemplate.EditValue             = templateSource.FirstOrDefault().TemplateCode;
            }
            catch (Exception ex)
            {
            }

            #endregion

            #region  所属店铺
            cmbOwnerShop.Properties.DataSource = ShopService.GetAllShop();
            cmbOwnerShop.Properties.NullText   = "请选择店铺";
            cmbOwnerShop.Properties.PopupWidth = 400;
            #endregion

            radioHasTicket.EditValue = false; //默认不开票
            txtPostFee.Text          = "10";  //默认邮费为10元
            txtDiscountRate.Text     = "1.0"; //默认不打折
            txtDicountOutFee.Text    = "0.0";
            txtDiscountFee.Text      = "0.0";
        }
Пример #2
0
 //当物流方式改变时重新绑定物流公司和物流模板
 private void cmbShippingType_EditValueChanged(object sender, EventArgs e)
 {
     try
     {
         // 物流公司
         List <LogisticCompany> companySource = LogisticCompanyService.GetLogisticCompany(p => p.shippingType == cmbShippingType.EditValue.ToString());
         cmbShipCompany.Properties.DataSource = companySource;
         cmbShipCompany.EditValue             = companySource.FirstOrDefault(p => p.isdefault == true).code;
     }
     catch (Exception ex)
     {
     }
 }
Пример #3
0
        /// 保存交易信息
        private void btnStoreReceiverMsg_Click(object sender, EventArgs e)
        {
            if (_currentTradeRow == null)
            {
                XtraMessageBox.Show("请选中一条交易!");
                return;
            }
            Alading.Entity.Trade focusedTrade = TradeService.GetTrade(_currentTradeRow["CustomTid"].ToString());
            //算法辅助量 默认Yes。如果时间戳不相等,弹出YesNoDialog,由此可决定是否更新
            DialogResult result = DialogResult.Yes;

            #region 利用时间戳来防止并发
            //调用辅助函数来比较时间戳是否相等
            if (!Alading.Utils.SystemHelper.CompareTimeStamp(_currentTradeRow["TradeTimeStamp"] as byte[], focusedTrade.TradeTimeStamp))
            {
                //如果时间戳不相等,则执行此代码段
                result = XtraMessageBox.Show("该交易的已被修改,是否继续修改(YES)/查看流程信息(NO)", "确认修改", MessageBoxButtons.YesNo);
            }
            #endregion

            #region 根据result的值更新数据库

            if (result == DialogResult.Yes)
            {
                #region 构造一条交易数据修改信息
                StringBuilder builder = new StringBuilder();
                try
                {
                    if (focusedTrade.receiver_name != txtBuyerName.Text)
                    {
                        builder.Append("  收获人姓名:" + focusedTrade.receiver_name + "->" + txtBuyerName.Text);
                    }
                    if (focusedTrade.receiver_mobile != txtMobile.Text)
                    {
                        builder.Append("  收货人电话:" + focusedTrade.receiver_mobile + "->" + txtMobile.Text);
                    }
                    if (focusedTrade.receiver_zip != txtZip.Text)
                    {
                        builder.Append("  收货人邮编:" + txtZip.Text + "->" + focusedTrade.receiver_zip);
                    }
                    if (focusedTrade.receiver_phone != txtPhone.Text)
                    {
                        builder.Append("  收货人座机:" + focusedTrade.receiver_phone + "->" + txtPhone.Text);
                    }
                    if (focusedTrade.LogisticCompanyCode != cmbShippingCompany.EditValue.ToString())
                    {
                        builder.Append("  收货人物流公司:" +
                                       LogisticCompanyService.GetLogisticCompany(p => p.code == focusedTrade.LogisticCompanyCode).FirstOrDefault().name +
                                       "->" + cmbShippingCompany.Text);
                    }
                    if (focusedTrade.receiver_address != txtReceiverAddress.Text)
                    {
                        builder.Append("  收货人地址:" + focusedTrade.receiver_address + "->" + txtReceiverAddress.Text);
                    }
                    if (focusedTrade.receiver_state != cmbReceiverState.SelectedItem.ToString())
                    {
                        builder.Append("  收货人省:" + focusedTrade.receiver_state + "->" + cmbReceiverState.SelectedItem.ToString());
                    }
                    if (focusedTrade.receiver_city != cmbReceiverCity.SelectedItem.ToString())
                    {
                        builder.Append("  收货人市:" + focusedTrade.receiver_city + "->" + cmbReceiverCity.SelectedItem.ToString());
                    }
                    if (focusedTrade.receiver_district != cmbReceiverDistrict.SelectedItem.ToString())
                    {
                        builder.Append("  收货人地区:" + focusedTrade.receiver_district + "->" + cmbReceiverDistrict.SelectedItem.ToString());
                    }
                    if ((focusedTrade.buyer_memo == null ? string.Empty : focusedTrade.buyer_memo) != memoBuyerMemo.Text)
                    {
                        builder.Append("  收货人备注:" + focusedTrade.buyer_memo + "->" + memoBuyerMemo.Text);
                    }
                    if ((focusedTrade.buyer_message == null ? string.Empty : focusedTrade.buyer_message) != memoBuyerMessage.Text)
                    {
                        builder.Append("  收货人信息:" + focusedTrade.buyer_message + "->" + memoBuyerMessage.Text);
                    }
                }
                catch (System.Exception ex)
                {
                }

                #endregion

                #region 从界面读取修改信息
                focusedTrade.receiver_name       = txtBuyerName.Text;
                focusedTrade.receiver_mobile     = txtMobile.Text;
                focusedTrade.receiver_zip        = txtZip.Text;
                focusedTrade.receiver_phone      = txtPhone.Text;
                focusedTrade.LogisticCompanyCode = cmbShippingCompany.EditValue.ToString();
                focusedTrade.TemplateCode        = cmbShippingTemplate.EditValue.ToString();
                focusedTrade.receiver_address    = txtReceiverAddress.Text;
                focusedTrade.receiver_state      = cmbReceiverState.SelectedItem.ToString();
                focusedTrade.receiver_city       = cmbReceiverCity.SelectedItem.ToString();
                focusedTrade.receiver_district   = cmbReceiverDistrict.SelectedItem.ToString();
                focusedTrade.buyer_memo          = memoBuyerMemo.Text;
                focusedTrade.buyer_message       = memoBuyerMessage.Text;
                focusedTrade.HasInvoice          = false;
                #endregion

                WaitDialogForm wdf = new WaitDialogForm(Constants.OPERATE_TBDB_DATA);
                try
                {
                    //将修改数据更新到淘宝
                    UpdateTaobaoTradeAddressMessage(focusedTrade);
                    //更新修改数据到数据库
                    TradeService.UpdateTrade(focusedTrade);
                    //创建一条流水信息到数据库
                    Alading.Utils.SystemHelper.CreateFlowMessage(focusedTrade.CustomTid, "收货信息修改", builder.ToString(), "订单管理");
                    wdf.Close();
                    XtraMessageBox.Show("修改收货信息成功!");
                }
                catch (Exception ex)
                {
                    wdf.Close();
                    XtraMessageBox.Show("修改收货保存到淘宝失败,修改无效!原因:" + ex.Message);
                }

                //将更新信息同步到界面
                _currentTradeRow["receiver_name"] = txtBuyerName.Text;
                //时间由系统自动生成,需将本地时间戳与数据库最新同步
                _currentTradeRow["TradeTimeStamp"] = TradeService.GetTrade(focusedTrade.CustomTid).TradeTimeStamp;
            }
            else
            {
                tabsTradeDetail.SelectedTabPage = detailTabFlowMsg;
            }
            #endregion
        }