Ejemplo n.º 1
0
 private ProductInfoEntity GetDataEntity()
 {
     /*
      * productInfoEntity = new ProductInfoEntity
      * {
      *  ProductCode = this.ProductCode.Text.Trim(),
      *  ProductName = this.ProductName.Text.Trim(),
      *  ProductCategory = BusinessLogic.ConvertToString(this.ProductCategory.SelectedValue),
      *  ProductModel = this.ProductModel.Text.Trim(),
      *  ProductStandard = this.ProductStandard.Text.Trim(),
      *  ProductUnit = this.ProductUnit.Text.Trim(),
      *  ProductDescription = this.ProductDescription.Text.Trim(),
      *  MiddleRate = BusinessLogic.ConvertToNullableDecimal(this.MiddleRate.Text),
      *  ReferenceCoefficient = BusinessLogic.ConvertToNullableDecimal(this.ReferenceCoefficient.Text),
      *  ProductPrice = BusinessLogic.ConvertToNullableDecimal(this.ProductPrice.Text),
      *  WholesalePrice = BusinessLogic.ConvertToNullableDecimal(this.WholesalePrice.Text),
      *  PromotionPrice = BusinessLogic.ConvertToNullableDecimal(this.PromotionPrice.Text),
      *  InternalPrice = BusinessLogic.ConvertToNullableDecimal(this.InternalPrice.Text),
      *  SpecialPrice = BusinessLogic.ConvertToNullableDecimal(this.SpecialPrice.Text),
      *  Description = this.Description.Text.Trim(),
      *  Enabled = Enabled.Checked ? 1:0
      * };
      */
     //新方法,一句话就搞定了
     productInfoEntity = new ProductInfoEntity();
     FormBinding.BindControlsToObject(productInfoEntity, this);
     return(productInfoEntity);
 }
Ejemplo n.º 2
0
        private void BindEditData()
        {
            currentProductInfoEntity = new ProductInfoManager(dbProvider).GetEntity(this.EntityId);
            if (currentProductInfoEntity == null || string.IsNullOrEmpty(currentProductInfoEntity.ProductName))
            {
                return;
            }
            //新方法,一句话就搞定了
            FormBinding.BindObjectToControls(currentProductInfoEntity, this);

            /*
             * //General Information 常规信息
             * this.ProductCode.Text = currentProductInfoEntity.ProductCode;
             * this.ProductName.Text = currentProductInfoEntity.ProductName;
             * this.ProductCategory.SelectedValue = currentProductInfoEntity.ProductCategory;
             * this.ProductModel.Text = currentProductInfoEntity.ProductModel;
             * this.ProductStandard.Text = currentProductInfoEntity.ProductStandard;
             * this.ProductUnit.Text = currentProductInfoEntity.ProductUnit;
             * this.ProductDescription.Text = currentProductInfoEntity.ProductDescription;
             *
             * //价格信息
             * this.MiddleRate.Text = currentProductInfoEntity.MiddleRate.ToString();
             * this.ReferenceCoefficient.Text = currentProductInfoEntity.ReferenceCoefficient.ToString();
             * this.ProductPrice.Text = currentProductInfoEntity.ProductPrice.ToString();
             * this.WholesalePrice.Text = currentProductInfoEntity.WholesalePrice.ToString();
             * this.PromotionPrice.Text = currentProductInfoEntity.PromotionPrice.ToString();
             * this.InternalPrice.Text = currentProductInfoEntity.InternalPrice.ToString();
             * this.SpecialPrice.Text = currentProductInfoEntity.SpecialPrice.ToString();
             *
             * //功能描述
             * this.Description.Text = currentProductInfoEntity.Description;
             * this.Enabled.Checked = BusinessLogic.ConvertIntToBoolean(currentProductInfoEntity.Enabled);
             */
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 保存修改的数据
        /// </summary>
        /// <returns></returns>
        private bool SaveEditData()
        {
            // 设置鼠标繁忙状态,并保留原先的状态
            Cursor holdCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            bool returnValue = false;

            //新方法,一句话就搞定了
            FormBinding.BindControlsToObject(currentProductInfoEntity, this);

            /*
             * currentProductInfoEntity.ProductCode = this.ProductCode.Text.Trim();
             * currentProductInfoEntity.ProductName = this.ProductName.Text.Trim();
             * currentProductInfoEntity.ProductCategory = BusinessLogic.ConvertToString(this.ProductCategory.SelectedValue);
             * currentProductInfoEntity.ProductModel = this.ProductModel.Text.Trim();
             * currentProductInfoEntity.ProductStandard = this.ProductStandard.Text.Trim();
             * currentProductInfoEntity.ProductUnit = this.ProductUnit.Text.Trim();
             * currentProductInfoEntity.ProductDescription = this.ProductDescription.Text.Trim();
             * currentProductInfoEntity.MiddleRate = BusinessLogic.ConvertToNullableDecimal(this.MiddleRate.Text);
             * currentProductInfoEntity.ReferenceCoefficient = BusinessLogic.ConvertToNullableDecimal(this.ReferenceCoefficient.Text);
             * currentProductInfoEntity.ProductPrice = BusinessLogic.ConvertToNullableDecimal(this.ProductPrice.Text);
             * currentProductInfoEntity.WholesalePrice = BusinessLogic.ConvertToNullableDecimal(this.WholesalePrice.Text);
             * currentProductInfoEntity.PromotionPrice = BusinessLogic.ConvertToNullableDecimal(this.PromotionPrice.Text);
             * currentProductInfoEntity.InternalPrice = BusinessLogic.ConvertToNullableDecimal(this.InternalPrice.Text);
             * currentProductInfoEntity.SpecialPrice = BusinessLogic.ConvertToNullableDecimal(this.SpecialPrice.Text);
             * currentProductInfoEntity.Description = this.Description.Text.Trim();
             * currentProductInfoEntity.Enabled = Enabled.Checked ? 1: 0;
             */
            string statusMessage = string.Empty;

            returnValue = new ProductInfoManager(dbProvider, this.UserInfo).Update(currentProductInfoEntity, out statusMessage) > 0;
            if (returnValue)
            {
                this.Changed = true;
                MessageBoxHelper.ShowSuccessMsg(statusMessage);
            }
            else
            {
                MessageBoxHelper.ShowWarningMsg(statusMessage);
            }


            // 设置鼠标默认状态,原来的光标状态
            this.Cursor = holdCursor;
            return(returnValue);
        }
Ejemplo n.º 4
0
        internal void Construct(ApplicationSchemaDefinition application, DataMap dataMap, bool isNew, CompositeDataMap composite, DetailController detailController, Func <Task <bool> > commandPreCondition, Action <string> titleSetter)
        {
            _applicationMetadata = application;
            _dataMap             = dataMap;
            _composite           = composite;
            _detailController    = detailController;
            _commandPreCondition = commandPreCondition;
            _titleSetter         = titleSetter;

            // Create our buddy binding which will help
            // us to move data between the data map and
            // the UI controls.
            _binding = UiBinder.Bind(_dataMap, _applicationMetadata, isNew);

            // Load the data, but ignore validation for
            // now. We don't want objects that are already
            // invalid triggering a sea of red in the UI.
            _binding.IsValidationSuppressed = true;
        }
Ejemplo n.º 5
0
 public static IEnumerable <FieldBinding> VisibleFields(this FormBinding form)
 {
     return(form
            .Fields
            .Where(f => false == ((ValueProvider)f.ValueProvider).IsHidden));
 }
 private void btnControlToEntity_Click(object sender, EventArgs e)
 {
     FormBinding.BindControlsToObject(TestEntity, this);
     this.richTextBox1.Text = TestEntity.ToString();
 }
 private void btnEntityToControl_Click(object sender, EventArgs e)
 {
     FormBinding.BindObjectToControls(TestEntity, this);
 }
 public override void FormOnLoad()
 {
     base.FormOnLoad();
     BindCategory();
     FormBinding.BindObjectToControls(TestEntity, this);
 }