Пример #1
0
 void setData()
 {
     try {
         if (_stokCari == StokCariCategory.Stok)
         {
             StokCategory sc = _mngStkCat.GetById(_categoryId, false);
             if (sc != null && sc.ParentCategory != null)
             {
                 txtSelectedCategory.Text = string.Format("{0}", sc.ParentCategory.Id);
                 txtCatCode.Text          = sc.Id;
                 txtCatName.Text          = sc.CategoryName;
                 txtCatCode.Enabled       = false;
             }
             else if (sc != null)
             {
                 txtCatCode.Text        = sc.Id;
                 txtCatName.Text        = sc.CategoryName;
                 chkAnaKategori.Checked = true;
                 txtCatCode.Enabled     = false;
             }
         }
         else
         {
             CariCategory cc = _mngCariCat.GetById(_categoryId, false);
             if (cc != null && cc.ParentCategory != null)
             {
                 txtSelectedCategory.Text = string.Format("{0}", cc.ParentCategory.Id);
                 txtCatCode.Text          = cc.Id;
                 txtCatName.Text          = cc.CategoryName;
                 txtCatCode.Enabled       = false;
             }
             else if (cc != null)
             {
                 txtCatCode.Text        = cc.Id;
                 txtCatName.Text        = cc.CategoryName;
                 txtCatCode.Enabled     = false;
                 chkAnaKategori.Checked = true;
             }
         }
     } catch (Exception exc) {
         LogWrite.Write(exc);
         MessageBox.Show(exc.Message);
     }
 }
        private void btnSil_Click(object sender, EventArgs e)
        {
            DialogResult re         = MessageBox.Show("Kayıt Silinsin mi?", "Dikkat", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
            bool         beginTrans = false;

            if (re == DialogResult.Yes)
            {
                try {
                    DataGridViewRow dr = dataGridView1.SelectedRows[0];
                    if (dr != null)
                    {
                        if (StokCariCategory.Stok == _stokCari)
                        {
                            StokCategory sc = _mngCatStok.GetById(dr.Cells[clId.Name].Value.ToString(), false);
                            beginTrans = true;
                            BeginTransaction();

                            sc.ParentCategory = null;
                            _mngCatStok.Delete(sc);
                        }
                        if (StokCariCategory.Cari == _stokCari)
                        {
                            CariCategory cc = _mngCatCari.GetById(dr.Cells[clId.Name].Value.ToString(), false);
                            beginTrans = true;
                            BeginTransaction();

                            cc.ParentCategory = null;
                            _mngCatCari.Delete(cc);
                        }
                    }
                } catch (Exception) { } finally {
                    try {
                        if (beginTrans)
                        {
                            CommitTransaction();
                        }
                        if (_useParent)
                        {
                            LoadData(_parentCategory);
                        }
                        else
                        {
                            LoadData();
                        }
                    } catch (Exception exc) {
                        MessageBox.Show(exc.Message); LogWrite.Write(exc);
                    }
                }
            }
        }
Пример #3
0
        void Kaydet()
        {
            if (string.IsNullOrEmpty(txtCariKodu.Text))
            {
                MessageBox.Show("lütfen Cari kodunu giriniz.");
                txtCariKodu.Focus();
                return;
            }
            try {
                Cari cari = mngCari.GetById(txtCariKodu.Text, false);
                if (cari == null)
                {
                    cari            = new Cari();
                    cari.Id         = txtCariKodu.Text;
                    cari.KayitTarih = DateTime.Now;
                }
                cari.CariIsim = txtCariIsim.Text;
                if (Char.IsDigit(txtTel.Text[1]))
                {
                    cari.CariTel = txtTel.Text;
                }
                if (Char.IsDigit(txtCepTel.Text[1]))
                {
                    cari.CepTel = txtCepTel.Text;
                }
                cari.CariAdres = txtCariAdres.Text.Trim();
                cari.CariEmail = txtCariEmil.Text;

                if (rbAliciSatici.Checked)
                {
                    cari.CariTip = "AS";
                }
                else if (rbAlici.Checked)
                {
                    cari.CariTip = "A";
                }
                else
                {
                    cari.CariTip = "S";
                }
                cari.VergiDairesi  = txtVergiDairesi.Text;
                cari.VergiNumarasi = txtVergiNumarasi.Text;
                cari.WebAdresi     = txtWebAdres.Text;
                if (Char.IsDigit(txtFax.Text[1]))
                {
                    cari.Fax = txtFax.Text;
                }
                cari.Sube           = UserInfo.Sube;
                cari.Il             = txtIl.Text;
                cari.Ilce           = txtIlce.Text;
                cari.YetkiliKisi    = txtYetkiliKisi.Text;
                cari.SatisFiyatKod  = cmbSatisFiyatKod.Text;
                cari.AlisFiyatKod   = cmbAlisFiyatKod.Text;
                cari.SubelerdeOrtak = chkSubelerdeOrtak.Checked;
                CariCategory parentCat1 = null;
                CariCategory parentCat2 = null;
                CariCategory parentCat3 = null;
                CariCategory parentCat4 = null;
                BeginTransaction();
                if (!string.IsNullOrEmpty(txtCariGrup1.Text))
                {
                    parentCat1 = mngCariCat.GetById(txtCariGrup1.Text, false);
                    if (parentCat1 == null)
                    {
                        //mngCariCat.BeginTransaction();
                        cari.Grup1 = parentCat1 = mngCariCat.Save(new CariCategory()
                        {
                            Id = txtCariGrup1.Text, Sube = UserInfo.Sube
                        });
                        //mngCariCat.CommitTransaction();
                    }
                    else
                    {
                        cari.Grup1 = parentCat1;
                    }
                }
                else
                {
                    cari.Grup1 = null;
                }
                if (parentCat1 != null && !string.IsNullOrEmpty(txtCariGrup1.Text) && !string.IsNullOrEmpty(txtCariGrup2.Text))
                {
                    parentCat2 = mngCariCat.GetById(txtCariGrup2.Text, false);
                    if (parentCat2 == null)
                    {
                        //mngCariCat.BeginTransaction();
                        parentCat2 = new CariCategory {
                            Id = txtCariGrup2.Text, Sube = UserInfo.Sube, ParentCategory = parentCat1
                        };
                        cari.Grup2 = mngCariCat.SaveOrUpdate(parentCat2);
                        //mngCariCat.CommitTransaction();
                    }
                    else
                    {
                        cari.Grup2 = parentCat2;
                    }
                }
                else
                {
                    cari.Grup2 = null;
                }
                if (parentCat2 != null && !string.IsNullOrEmpty(txtCariGrup2.Text) && !string.IsNullOrEmpty(txtCariGrup3.Text))
                {
                    parentCat3 = mngCariCat.GetById(txtCariGrup3.Text, false);
                    if (parentCat3 == null)
                    {
                        //mngCariCat.BeginTransaction();
                        parentCat3 = new CariCategory {
                            Id = txtCariGrup3.Text, Sube = UserInfo.Sube, ParentCategory = parentCat2
                        };
                        cari.Grup3 = mngCariCat.SaveOrUpdate(parentCat3);
                        //mngCariCat.CommitTransaction();
                    }
                    else
                    {
                        cari.Grup3 = parentCat3;
                    }
                }
                else
                {
                    cari.Grup3 = null;
                }
                if (parentCat3 != null && !string.IsNullOrEmpty(txtCariGrup3.Text) && !string.IsNullOrEmpty(txtCariGrup4.Text))
                {
                    parentCat4 = mngCariCat.GetById(txtCariGrup4.Text, false);
                    if (parentCat4 == null)
                    {
                        //mngCariCat.BeginTransaction();
                        parentCat4 = new CariCategory {
                            Id = txtCariGrup4.Text, Sube = UserInfo.Sube, ParentCategory = parentCat3
                        };
                        cari.Grup4 = mngCariCat.SaveOrUpdate(parentCat4);
                        //mngCariCat.CommitTransaction();
                    }
                    else
                    {
                        cari.Grup4 = parentCat4;
                    }
                }
                else
                {
                    cari.Grup4 = null;
                }
                //mngCari.BeginTransaction();

                mngCari.SaveOrUpdate(cari);


                Form frm = this.Owner;
                if (frm != null)
                {
                    if (frm is frmCariRehber)
                    {
                        this.Close();
                    }
                    else if (frm is frmFatura)
                    {
                        frmFatura f = (frmFatura)frm;
                        f.txtCari.Text = txtCariKodu.Text;
                        f.txtCari.Focus();
                        this.Close();
                    }
                    else if (frm is frmSiparis)
                    {
                        frmSiparis f = (frmSiparis)frm;
                        f.txtCari.Text = txtCariKodu.Text;
                        f.txtCari.Focus();
                        this.Close();
                    }
                }
                else
                {
                    //LoadAllCari();
                    btnYeni_Click(this, EventArgs.Empty);
                    txtCariKodu.Focus();
                }
            } catch (Exception exc) {
                LogWrite.Write(exc);
                MessageBox.Show(exc.Message);
            } finally {
                try {
                    CommitTransaction();
                } catch (Exception exc) {
                    MessageBox.Show(exc.Message);
                    LogWrite.Write(exc);
                }
            }
        }
Пример #4
0
        void InitializeData()
        {
            mngFct     = new ManagerFactory(Engine.GetConString(), Engine.GetSqlServerType());
            mngCari    = mngFct.GetCariManager();
            mngCariCat = mngFct.GetCariCategoryManager();
            // LoadAllCari();
            IList <Cari> listef = mngCari.GetBySUBE_KODU(UserInfo.Sube.Id);

            filterDataGridView1.grd.DataSource = listef;
            ManagerIl mngIl = new ManagerIl();

            //txtIl.DataSource = () =>
            //  {
            //    try
            //    {
            //      System.Globalization.CultureInfo dil;
            //      dil = new System.Globalization.CultureInfo("tr-TR");

            //      //txtIl.SelectionStart = txtIl.Text.Length;
            //      string str = txtIl.Text.ToUpper(dil);
            //      return mngIl.IlListe(str) ;
            //    }
            //    catch (Exception exc)
            //    {
            //      MessageBox.Show(exc.Message);
            //      LogWrite.Write(exc);
            //    }
            //    return null;
            //  };
            //txtIlce.DataSource = () =>
            //{
            //  try
            //  {
            //    if (string.IsNullOrEmpty(txtIl.Text))
            //      return null;
            //    System.Globalization.CultureInfo dil;
            //    dil = new System.Globalization.CultureInfo("tr-TR");

            //    //txtIl.SelectionStart = txtIl.Text.Length;
            //    string str = txtIl.Text.ToUpper(dil);
            //    int il = mngIl.SehirId(str);
            //    string ilce = txtIlce.Text.ToUpper(dil);
            //    return mngIl.IlceListe(ilce,il);
            //  }
            //  catch (Exception exc)
            //  {
            //    MessageBox.Show(exc.Message);
            //    LogWrite.Write(exc);
            //  }
            //  return null;
            //};
            txtCariKodu.DataSource = () =>
            {
                try {
                    return(mngCari.GetCariKodsBySubeKodu(UserInfo.Sube.Id, txtCariKodu.Text).ToStringList(15, txtCariKodu.Ayirac));
                } catch (Exception exc) {
                    MessageBox.Show(exc.Message);
                    LogWrite.Write(exc);
                }
                return(null);
            };
            txtCariGrup1.DataSource = () =>
            {
                try {
                    List <string> liste = mngCariCat.GetListRootCategoriesKodAndName(txtCariGrup1.Text).ToStringList(30, "");
                    return(liste);
                } catch (Exception exc) {
                    LogWrite.Write(exc);
                    MessageBox.Show(exc.Message);
                }
                return(null);
            };
            txtCariGrup2.DataSource = () =>
            {
                try {
                    CariCategory parent = mngCariCat.GetById(txtCariGrup1.Text, false);
                    if (parent == null)
                    {
                        return(null);
                    }
                    else
                    {
                        List <string> liste = mngCariCat.GetListParentSubCategoryKodAndName(parent.Id, txtCariGrup2.Text).ToStringList(30, "");
                        return(liste);
                    }
                } catch (Exception exc) {
                    LogWrite.Write(exc);
                    MessageBox.Show(exc.Message);
                }
                return(null);
            };
            txtCariGrup3.DataSource = () =>
            {
                try {
                    CariCategory parent = mngCariCat.GetById(txtCariGrup2.Text, false);
                    if (parent == null)
                    {
                        return(null);
                    }
                    else
                    {
                        List <string> liste = mngCariCat.GetListParentSubCategoryKodAndName(parent.Id, txtCariGrup3.Text).ToStringList(30, "");
                        return(liste);
                    }
                } catch (Exception exc) {
                    LogWrite.Write(exc);
                    MessageBox.Show(exc.Message);
                }
                return(null);
            };
            txtCariGrup4.DataSource = () =>
            {
                try {
                    CariCategory parent = mngCariCat.GetById(txtCariGrup3.Text, false);
                    if (parent == null)
                    {
                        return(null);
                    }
                    else
                    {
                        List <string> liste = mngCariCat.GetListParentSubCategoryKodAndName(parent.Id, txtCariGrup4.Text).ToStringList(30, "");
                        return(liste);
                    }
                } catch (Exception exc) {
                    LogWrite.Write(exc);
                    MessageBox.Show(exc.Message);
                }
                return(null);
            };
        }