예제 #1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     using (FrmProductEditor editor = new FrmProductEditor(new DomainModel.Entities.ApplicationProduct()))
     {
         if (editor.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
         }
     }
 }
예제 #2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            DomainModel.Entities.ApplicationProduct product = null;

            Int64?productId = null;

            // Select language
            int languageId = Convert.ToInt32(cbxLanguageList.SelectedValue);

            // Find product
            if (!string.IsNullOrWhiteSpace(this.tbxUrlName.Text))
            {
                productId = Repository.Sql.Product.IdFromUrlName(this.tbxUrlName.Text);
            }
            else if (!string.IsNullOrWhiteSpace(this.tbxProductId.Text))
            {
                productId = Convert.ToInt64(this.tbxProductId.Text);
            }

            if (productId == null || languageId < 0)
            {
                MessageBox.Show("Produc not found");
                return;
            }

            product = Repository.Sql.Product.GetById(productId.Value, languageId);

            // Edit product
            if (product == null)
            {
                MessageBox.Show("Produc not found");
            }
            else
            {
                Repository.Sql.ProductOptions.Reload(product);
                Repository.Sql.ProductContacts.Reload(product);

                using (FrmProductEditor editor = new FrmProductEditor(product))
                {
                    if (editor.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                    }
                }
            }
        }