コード例 #1
0
        public void KasaHareketSil(int cekSenetId, KasaHarTip kasaTip)
        {
            bool isBegin = false;

            try {
                KasaHareket har = _mngKasaHar.GetByTipAndCekOrSenetId(UserInfo.Sube.Id
                                                                      , kasaTip, cekSenetId);
                if (har != null)
                {
                    isBegin = true;
                    _mngKasaHar.BeginTransaction();
                    _mngKasaHar.Delete(har);
                }
            } catch (Exception) {
            } finally {
                try {
                    if (isBegin)
                    {
                        _mngKasaHar.CommitTransaction();
                    }
                } catch (Exception exc) {
                    MessageBox.Show(exc.Message);
                    LogWrite.Write(exc);
                }
            }
        }
コード例 #2
0
        private void btnSil_Click(object sender, EventArgs e)
        {
            DialogResult re = MessageBox.Show("Kayıt Silinsin mi?", "Dikkat", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (re == DialogResult.Yes)
            {
                try {
                    DataGridViewRow dr = dataGridViewSenet.SelectedRows[0];
                    if (dr != null)
                    {
                        string      subeKodu = UserInfo.Sube.Id;
                        Senet       senet    = _mngSenet.SingleOrDefault <Senet>(x => x.Id == int.Parse(dr.Cells[clId.Name].Value.ToString()));
                        CariHarTuru tur      = senet.SenetTip == SenetTip.Alinan ? CariHarTuru.AlinanSenet :
                                               CariHarTuru.VerilenCek;
                        CariHareket  cahar   = _mngCariHar.GetByCekOrSenetIdAndHareketTuruAndCariKod(UserInfo.Sube.Id, senet.Id, tur, senet.CariKodu);
                        HesapHareket hesap   = _mngHesapHar.GetByCekOrSenetIdAndHareketTuru(subeKodu, senet.Id, HesapHareketTuru.SenetTahsil);
                        KasaHareket  kasahar = _mngKasaHar.GetByTipAndCekOrSenetId(subeKodu
                                                                                   , KasaHarTip.Senet, senet.Id);
                        BeginTransaction();
                        if (hesap != null)
                        {
                            _mngHesapHar.Delete(hesap);
                        }
                        if (kasahar != null)
                        {
                            _mngKasaHar.Delete(kasahar);
                        }
                        _mngSenet.Delete(senet);
                        _mngCariHar.Delete(cahar);
                    }
                } catch (Exception exc) {
                    LogWrite.Write(exc);
                    MessageBox.Show(exc.Message);
                } finally {
                    try {
                        CommitTransaction();
                        LoadGrid();
                    } catch (Exception exc) {
                        MessageBox.Show(exc.Message);
                        LogWrite.Write(exc);
                    }
                }
            }
        }