コード例 #1
0
        private void btnkaydet_Click(object sender, EventArgs e)
        {
            MusteriBL mbl = new MusteriBL();

            foreach (DataRow item in dt.Rows)
            {
                MODEL.Musteri m = new MODEL.Musteri();
                if (item.RowState != DataRowState.Deleted)
                {
                    m.Musteriad    = item["Musteriad"].ToString();
                    m.Musterisoyad = item["Musterisoyad"].ToString();
                    m.Mustericep   = item["Mustericep"].ToString();
                    m.Musterimail  = item["Musterimail"].ToString();
                    m.Musteriadres = item["Musteriadres"].ToString();
                }
                switch (item.RowState)
                {
                case DataRowState.Added:
                    mbl.MusteriEkle(m);
                    break;

                case DataRowState.Deleted:
                    mbl.MusteriSil((int)item["MusteriId", DataRowVersion.Original]);
                    break;

                case DataRowState.Modified:
                    m.Musteriid = (int)item["MusteriId"];
                    mbl.MusteriGuncelle(m);
                    break;

                default:
                    break;
                }
            }
        }
コード例 #2
0
        private void btnMusEkle_Click(object sender, EventArgs e)
        {
            MusteriBL mbl = new MusteriBL();

            try
            {
                mus.MusteriKayitID = MusteriID;
                mus.TcKNo          = txtETcKNo.Text.Trim();
                mus.Ad             = txtEAdi.Text.Trim();
                mus.Soyad          = txtESoyadi.Text.Trim();
                mus.GirTar         = dtpEGirTar.Value;
                mus.CikTar         = dtpECikTar.Value;
                mus.OdaNo          = (int)cmEBosOda.SelectedValue;
                switch (MusteriID)
                {
                case (0):
                    if (mbl.MusteriEkle(mus))
                    {
                        Temizle();
                        MessageBox.Show("Ekleme Başarılı");
                    }
                    else
                    {
                        MessageBox.Show("Ekleme Başarısız!");
                    }
                    break;

                default:
                    if (mbl.MusteriGuncelle(mus))
                    {
                        Temizle();
                        MessageBox.Show("Güncelleme Başarılı");
                    }
                    else
                    {
                        MessageBox.Show("Güncelleme Başarısız!");
                    }
                    break;
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Sql Hatası! Hata Kodu: " + ex.Number + " !! " + ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Bilinmeyen Hata! " + ex.Message);
            }
            finally
            {
                mbl.Dispose();
                this.Close();
            }
        }
コード例 #3
0
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            MusteriBL mbl = new MusteriBL();

            foreach (DataRow item in dt.Rows)
            {
                Musteri m = new Musteri();
                if (item.RowState != DataRowState.Deleted)
                {
                    m.TcKNo  = item[1].ToString();
                    m.Ad     = item[2].ToString();
                    m.Soyad  = item[3].ToString();
                    m.GirTar = Convert.ToDateTime(item[4]);
                    m.CikTar = Convert.ToDateTime(item[5]);
                    m.OdaNo  = Convert.ToInt32(item[6]);
                }
                switch (item.RowState)
                {
                case DataRowState.Added:
                    mbl.MusteriEkle(m);
                    break;

                case DataRowState.Deleted:
                    mbl.MusteriSil(Convert.ToInt32(item[0, DataRowVersion.Original]));
                    break;

                case DataRowState.Modified:
                    m.MusteriKayitID = Convert.ToInt32(item[0]);
                    mbl.MusteriGuncelle(m);
                    break;

                default:
                    break;
                }
            }
        }