Esempio n. 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);
                    }
                }
            }
        }
Esempio n. 3
0
        //T Deneme<T, IdT>(IManagerBase<T, IdT> mng,IdT id)
        //{
        //  return mng.GetById(id,false);
        //}



        void AssStokValues(Stok stok)
        {
            CultureInfo ci = new CultureInfo("tr-TR");

            stok.StokAdi = txtStokIsmi.Text;
            //stok.KdvOrani = txtAlisKdvOrani.Text.ParseNullable<double>(x => double.Parse(x, ci));
            stok.AlisKdvOrani  = txtAlisKdvOrani.Text.ParseStruct <double>(x => double.Parse(x, ci));
            stok.SatisKdvOrani = txtSatisKdvOrani.Text.ParseStruct <double>(x => double.Parse(x, ci));
            stok.AnaBirim      = txtAnaBirim.Text.Trim();
            stok.AltBirim1     = txtAltBirim1.Text.Trim();
            stok.Carpan1       = txtCarpan1.Text.ParseNullable <double>(x => double.Parse(x, ci));
            stok.AltBirim2     = txtAltBirim2.Text.Trim();
            stok.Carpan2       = txtCarpan2.Text.ParseNullable <double>(x => double.Parse(x, ci));
            stok.AltBirim3     = txtAltBirim3.Text.Trim();
            stok.Carpan3       = txtCarpan3.Text.ParseNullable <double>(x => double.Parse(x, ci));

            stok.AsgariMiktar = txtAsgariMiktar.Text.ParseNullable <int>(x => int.Parse(x, ci));
            stok.AzamiMiktar  = txtAzamiMiktar.Text.ParseNullable <int>(x => int.Parse(x, ci));
            stok.AlisFiyat1   = txtAlisFyt1.Text.ParseNullable <double>(delegate(string x) { return(double.Parse(x, ci)); });
            stok.AlisFiyat2   = txtAlisFyt2.Text.ParseNullable <double>(delegate(string x) { return(double.Parse(x, ci)); });
            stok.AlisFiyat3   = txtAlisFyt3.Text.ParseNullable <double>(delegate(string x) { return(double.Parse(x, ci)); });
            //stok.AlisDovTipi = mngKur.GetByKurName(cmbAlisFytKur.Text);
            stok.SatisFiyat1 = txtSatisFyt1.Text.ParseNullable <double>(x => double.Parse(x, ci));
            stok.SatisFiyat2 = txtSatisFyt2.Text.ParseNullable <double>(x => double.Parse(x, ci));
            stok.SatisFiyat3 = txtSatisFyt3.Text.ParseNullable <double>(x => double.Parse(x, ci));
            //stok.SatDovTipi = mngKur.GetByKurName(cmbSatisFyt.Text);
            stok.SubelerdeOrtak = chkSubelerdeOrtak.Checked;
            StokCategory parentCat1 = null;
            StokCategory parentCat2 = null;
            StokCategory parentCat3 = null;
            StokCategory parentCat4 = null;

            if (!string.IsNullOrEmpty(txtStGrup1.Text))
            {
                parentCat1 = mngStokCat.GetById(txtStGrup1.Text, false);
                if (parentCat1 == null)
                {
                    //mngStokCat.BeginTransaction();
                    stok.Grup1 = parentCat1 = mngStokCat.Save(new StokCategory()
                    {
                        Id = txtStGrup1.Text, Sube = UserInfo.Sube
                    });
                    //mngStokCat.CommitTransaction();
                }
                else
                {
                    stok.Grup1 = parentCat1;
                }
            }
            else
            {
                stok.Grup1 = null;
            }
            if (parentCat1 != null && !string.IsNullOrEmpty(txtStGrup1.Text) && !string.IsNullOrEmpty(txtStGrup2.Text))
            {
                parentCat2 = mngStokCat.GetById(txtStGrup2.Text, false);
                if (parentCat2 == null)
                {
                    //mngStokCat.BeginTransaction();
                    parentCat2 = new StokCategory {
                        Id = txtStGrup2.Text, Sube = UserInfo.Sube, ParentCategory = parentCat1
                    };
                    stok.Grup2 = mngStokCat.Save(parentCat2);
                    //mngStokCat.CommitTransaction();
                }
                else
                {
                    stok.Grup2 = parentCat2;
                }
            }
            else
            {
                stok.Grup2 = null;
            }
            if (parentCat2 != null && !string.IsNullOrEmpty(txtStGrup2.Text) && !string.IsNullOrEmpty(txtStGrup3.Text))
            {
                parentCat3 = mngStokCat.GetById(txtStGrup3.Text, false);
                if (parentCat3 == null)
                {
                    //mngStokCat.BeginTransaction();
                    parentCat3 = new StokCategory {
                        Id = txtStGrup3.Text, Sube = UserInfo.Sube, ParentCategory = parentCat2
                    };
                    stok.Grup3 = mngStokCat.Save(parentCat3);
                    //mngStokCat.CommitTransaction();
                }
                else
                {
                    stok.Grup3 = parentCat3;
                }
            }
            else
            {
                stok.Grup3 = null;
            }
            if (parentCat3 != null && !string.IsNullOrEmpty(txtStGrup3.Text) && !string.IsNullOrEmpty(txtStGrup4.Text))
            {
                parentCat4 = mngStokCat.GetById(txtStGrup4.Text, false);
                if (parentCat4 == null)
                {
                    //mngStokCat.BeginTransaction();
                    parentCat4 = new StokCategory {
                        Id = txtStGrup4.Text, Sube = UserInfo.Sube, ParentCategory = parentCat3
                    };
                    stok.Grup4 = mngStokCat.Save(parentCat4);
                    //mngStokCat.CommitTransaction();
                }
                else
                {
                    stok.Grup4 = parentCat4;
                }
            }
            else
            {
                stok.Grup4 = null;
            }
            if (parentCat4 != null && !string.IsNullOrEmpty(txtStGrup4.Text) && !string.IsNullOrEmpty(txtStGrup5.Text))
            {
                StokCategory parentCat5 = mngStokCat.GetById(txtStGrup5.Text, false);
                if (parentCat5 == null)
                {
                    //mngStokCat.BeginTransaction();
                    parentCat5 = new StokCategory {
                        Id = txtStGrup5.Text, Sube = UserInfo.Sube, ParentCategory = parentCat4
                    };
                    stok.Grup5 = mngStokCat.Save(parentCat5);
                    //mngStokCat.CommitTransaction();
                }
                else
                {
                    stok.Grup5 = parentCat5;
                }
            }
            else
            {
                stok.Grup5 = null;
            }

            stok.Barkod1 = txtBarkod1.Text; stok.Barkod2 = txtBarkod2.Text; stok.Barkod3 = txtBarkod3.Text;
        }