コード例 #1
0
ファイル: Form1.cs プロジェクト: unayir/StokTakipUygulamasi
 private void btnAddCategory_Click(object sender, EventArgs e)
 {
     try
     {
         Categories cat = new Categories
         {
             CategoryName = txtCategoryName.Text,
             Description  = rtxtCategoryDescription.Text,
             Picture      = ImageConvertToByte(imagePath)
         };
         imagePath = "";
         CategoryORM catORM = new CategoryORM();
         bool        result = catORM.Insert(cat);
         if (result)
         {
             MessageBox.Show("Kategori Ekleme İşleminiz Başarıyla Gerçekleştirildi", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             dGvCategories.DataSource           = catORM.List();
             tabControlCategories.SelectedIndex = 0;
             CategoryControlsClear(true);
         }
         else
         {
             MessageBox.Show("İşlem Sırasında Bir Hata Meydana Geldi !", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     catch (SqlException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #2
0
        protected void btnCategoryEkle_Click(object sender, EventArgs e)
        {
            CategoryORM catORM = new CategoryORM();
            bool        result = false;

            if (btnCategoryEkle.Text == "Güncelle")
            {
                result = catORM.Update(new Categories
                {
                    CategoryID   = int.Parse(ViewState["catID"].ToString()),
                    CategoryName = txtCatName.Value
                });
            }
            else
            {
                result = catORM.Insert(new Categories
                {
                    CategoryName = txtCatName.Value
                });
            }

            if (result)
            {
                eklemeBilgi.Visible    = true;
                eklemeBilgi.InnerText  = "İşleminiz Başarıyla Gerçekleştirildi.";
                rptCategory.DataSource = catORM.List();
                rptCategory.DataBind();
            }
            else
            {
                eklemeBilgi.Visible   = true;
                eklemeBilgi.InnerText = "İşleminiz Gerçekleştirilemedi.";
            }
        }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Category ctg = new Category();

            ctg.Name = textBox1.Text;
            bool result = cOrm.Insert(ctg);

            if (result)
            {
                MessageBox.Show("Added successful!");
                dataGridView1.DataSource = cOrm.Select();
            }
            else
            {
                MessageBox.Show("Added not successful!");
            }
        }