Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Guid productId = Guid.Parse(txtProductId.Text);

            if (productId == Guid.Empty)
            {
                return;
            }
            using (IUnitOfWork uow = new UnitOfWork())
            {
                foreach (Control c in this.Controls)
                {
                    if (c is TextBox)
                    {
                        TextBox textbox = c as TextBox;
                        if (textbox.Tag != null && !string.IsNullOrWhiteSpace(textbox.Text))
                        {
                            string[] strValue = textbox.Text.Split(';');
                            try
                            {
                                foreach (string val in strValue)
                                {
                                    if (!string.IsNullOrWhiteSpace(val))
                                    {
                                        CustomModel.ProductProperty prop = new CustomModel.ProductProperty();
                                        prop.TableName = textbox.Tag.ToString();
                                        prop.Value     = val;
                                        prop.ProductId = productId;
                                        uow.ProductRepository.InsertProductProperty(prop);
                                    }
                                }
                            }
                            catch
                            {
                                lblNotify1.SetText(UI.failed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
                            }
                        }
                    }
                }
                uow.Commit();
                lblNotify1.SetText(UI.success, ToolBoxCS.LabelNotify.EnumStatus.Success);
                //FormUtility.ResetForm(this);
            }
        }
Exemplo n.º 2
0
        public void InsertProductProperty(CustomModel.ProductProperty value)
        {
            string insert = "insert into " + value.TableName + " values (@value,@productId)";

            Connection.Execute(insert, new { @value = value.Value, @productId = value.ProductId }, transaction: Transaction);
        }