Beispiel #1
0
        void Listele()
        {
            Liste2.Rows.Clear();
            int i   = 0;
            var lst = (from s in _db.tblSalesUps select s);

            foreach (var k in lst)
            {
                tblSalesUp slu = _db.tblSalesUps.First(x => x.SalesID == k.SalesID);

                if (_db.tblSalesUps.First(x => x.SalesID == k.SalesID).tblCompany.Name.Contains(txtFirmaBul.Text))
                {
                    Liste2.Rows.Add();
                    Liste2.Rows[i].Cells[0].Value = k.SalesID;
                    Liste2.Rows[i].Cells[1].Value = _db.tblSalesUps.First(x => x.SalesID == k.SalesID).tblCompany.Name;
                    Liste2.Rows[i].Cells[2].Value = _db.tblSalesUps.First(x => x.SalesID == k.SalesID).Date;
                    Liste2.Rows[i].Cells[3].Value = _db.tblSalesUps.First(x => x.SalesID == k.SalesID).tblEmployee.Name;
                    Liste2.Rows[i].Cells[4].Value = _db.tblSalesUps.First(x => x.SalesID == k.SalesID).tblShipper.Name;

                    i++;
                }
            }
            Liste2.AllowUserToAddRows = false;
            Liste2.ReadOnly           = true;
        }
Beispiel #2
0
        public void Ac(int id)
        {
            Liste.Rows.Clear();
            _sid = id;
            tblSalesUp pur = _db.tblSalesUps.First(x => x.SalesID == _sid);

            txtSatisNo.Text = pur.SalesID.ToString().PadLeft(7, '0');
            txtFirma.Text   = pur.tblCompany.Name;
            dtpTarih.Text   = pur.Date.Value.ToString();
            cbSehir.Text    = pur.tblCity.City;
            txtPer.Text     = pur.tblEmployee.Name;
            txtKargo.Text   = pur.tblShipper.Name;
            int i   = 0;
            var srg = from s in _db.tblSalesDowns
                      where s.SalesID == _sid
                      select s;

            foreach (tblSalesDown k in srg)
            {
                Liste.Rows.Add();
                Liste.Rows[i].Cells[0].Value = k.ProductID;
                Liste.Rows[i].Cells[1].Value = k.tblProduct.Name;

                Liste.Rows[i].Cells[4].Value = k.SalesPrice;
                Liste.Rows[i].Cells[5].Value = k.Quantity;
                i++;
            }
        }
        void Listele()
        {
            Liste2.Rows.Clear();
            int i   = 0;
            var lst = (from s in _db.tblSalesDowns select s);

            foreach (var k in lst)
            {
                tblSalesUp slu = _db.tblSalesUps.First(x => x.SalesID == k.SalesID);

                if (slu.tblCompany.Name.ToUpper().Contains(txtFirmaBul.Text.ToUpper()))
                {
                    Liste2.Rows.Add();
                    Liste2.Rows[i].Cells[0].Value = k.SalesID;
                    Liste2.Rows[i].Cells[1].Value = _db.tblSalesUps.First(x => x.SalesID == k.SalesID).tblCompany.Name;
                    Liste2.Rows[i].Cells[2].Value = _db.tblSalesUps.First(x => x.SalesID == k.SalesID).Date;
                    Liste2.Rows[i].Cells[3].Value = _db.tblSalesUps.First(x => x.SalesID == k.SalesID).tblEmployee.Name;
                    Liste2.Rows[i].Cells[4].Value = _db.tblSalesUps.First(x => x.SalesID == k.SalesID).tblShipper.Name;
                    Liste2.Rows[i].Cells[5].Value = k.tblProduct.Name;
                    Liste2.Rows[i].Cells[6].Value = k.LotSerial;
                    Liste2.Rows[i].Cells[7].Value = k.SalesPrice;
                    Liste2.Rows[i].Cells[8].Value = k.Quantity;
                    i++;
                }
            }
            Liste2.AllowUserToAddRows = false;
            Liste2.ReadOnly           = true;
        }
Beispiel #4
0
        void YeniKaydet()
        {
            Liste.AllowUserToAddRows = false;
            try
            {
                tblSalesDown[] sud = new tblSalesDown[Liste.RowCount];
                tblSalesUp     sup = new tblSalesUp();


                for (int i = 0; i < Liste.RowCount; i++)
                {
                    int    pid = int.Parse(Liste.Rows[i].Cells[0].Value.ToString());
                    string lot = Liste.Rows[i].Cells[2].Value.ToString();

                    sud[i]            = new tblSalesDown();
                    sud[i].SalesID    = int.Parse(txtSatisNo.Text);
                    sud[i].ProductID  = pid;
                    sud[i].LotSerial  = lot;
                    sud[i].SalesPrice = decimal.Parse(Liste.Rows[i].Cells[4].Value.ToString());
                    sud[i].Quantity   = int.Parse(Liste.Rows[i].Cells[5].Value.ToString());


                    sup.SalesID    = int.Parse(txtSatisNo.Text);
                    sup.CompanyID  = _db.tblCompanies.First(x => x.Name == txtFirma.Text).ID;
                    sup.Date       = DateTime.Parse(dtpTarih.Text);
                    sup.CityID     = _db.tblCities.First(x => x.City == cbSehir.Text).Id;
                    sup.EmployeeID = _db.tblEmployees.First(x => x.Name == txtPer.Text).ID;
                    sup.ShipperID  = _db.tblShippers.First(x => x.Name == txtKargo.Text).ID;

                    AccountingDBDataContext _gb = new AccountingDBDataContext();
                    tblStock st = _gb.tblStocks.First(x => x.ProductID == pid && x.LotSerial == lot);
                    if (st.Quantity.Value - int.Parse(Liste.Rows[i].Cells[5].Value.ToString()) > 0)
                    {
                        st.Quantity -= int.Parse(Liste.Rows[i].Cells[5].Value.ToString());
                        _gb.SubmitChanges();
                        _db.tblSalesDowns.InsertOnSubmit(sud[i]);
                        _db.tblSalesUps.InsertOnSubmit(sup);
                    }

                    else

                    {
                        MessageBox.Show("Elimizde Yeterli Ürün Yok!");
                    }
                }
                _db.SubmitChanges();
                _m.YeniKayit("Kayıt başarılı.");
            }
            catch (Exception e)
            {
                _m.Hata(e);
            }
        }
        public void Ac(int id)
        {
            try
            {
                Liste.Rows.Clear();
                _aid = id;
                tblSalesUp sup = _db.tblSalesUps.First(x => x.SalesID == _aid);
                txtSatisNo.Text  = sup.SalesID.ToString().PadLeft(7, '0');
                txtFirma.Text    = sup.tblCompany.Name;
                txtPersonel.Text = sup.tblEmployee.Name;
                cbSehir.Text     = sup.tblCity.City;
                cbKargo.Text     = sup.tblShipper.Name;
                dtpTarih.Text    = sup.Date.ToString();

                int i = 0;

                var srg = from s in _db.tblSalesDowns
                          where s.SalesID == _aid
                          select s;

                foreach (var k in srg)
                {
                    Liste.Rows.Add();
                    DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)Liste.Rows[i].Cells[2];
                    //(DataGridViewComboBoxCell)


                    Liste.Rows[i].Cells[0].Value = k.ProductID;
                    Liste.Rows[i].Cells[1].Value = k.tblProduct.Name;
                    LotSeri.Items.Add(k.LotSerial);
                    comboCell.Value = k.LotSerial;
                    Liste.Rows[i].Cells[3].Value = k.Quantity;
                    Liste.Rows[i].Cells[4].Value = k.SalesPrice;
                    i++;
                }
            }
            catch (Exception e)
            {
                _m.Hata(e);
            }
        }
Beispiel #6
0
        private void btnBul_Click(object sender, EventArgs e)
        {
            Liste.Rows.Clear();
            int i   = 0;
            var lst = (from s in _db.tblSalesUps select s);

            foreach (var k in lst)
            {
                tblSalesUp slu = _db.tblSalesUps.First(x => x.SalesID == k.SalesID);

                if ((slu.tblCompany.Name.ToUpper()).Contains(txtFirmaBul.Text.ToUpper()))
                {
                    Liste2.Rows.Add();
                    Liste2.Rows[i].Cells[0].Value = k.SalesID;
                    Liste2.Rows[i].Cells[1].Value = _db.tblSalesUps.First(x => x.SalesID == k.SalesID).tblCompany.Name;
                    Liste2.Rows[i].Cells[2].Value = _db.tblSalesUps.First(x => x.SalesID == k.SalesID).Date;
                    Liste2.Rows[i].Cells[3].Value = _db.tblSalesUps.First(x => x.SalesID == k.SalesID).tblEmployee.Name;
                    Liste2.Rows[i].Cells[4].Value = _db.tblSalesUps.First(x => x.SalesID == k.SalesID).tblShipper.Name;
                    i++;
                }
            }
            Liste2.AllowUserToAddRows = false;
            Liste2.ReadOnly           = true;
        }
Beispiel #7
0
        private void YeniKaydet()
        {
            Liste.AllowUserToAddRows = false;
            bool kon = true;

            try
            {
                tblSalesDown[]          saled = new tblSalesDown[Liste.RowCount];
                tblSalesUp              saleu = new tblSalesUp();
                tblStock[]              stk   = new tblStock[Liste.RowCount];
                AccountingDBDataContext _gb   = new AccountingDBDataContext();
                AccountingDBDataContext _eb   = new AccountingDBDataContext();
                for (int i = 0; i < Liste.RowCount - 1; i++)
                {
                    for (int a = 0; a < Liste.ColumnCount - 1; a++)
                    {
                        var d = Liste.Rows[i].Cells[a].Value;
                        if (d == null)
                        {
                            MessageBox.Show("Alan boş bırakılamaz" + (i + 1) + ".satır " + a + ". sütunu kontrol edin");
                            kon = false;
                            break;
                        }
                    }
                }  //HÜCRE BOŞ BIRAKILAMAZ

                if (kon && txtFirma.Text != "" && txtPersonel.Text != "" && cbKargo.Text != "") //BOŞ ALAN BIRAKILMIŞSA KAYIT YAPILMASINI ÖNLEMEK İÇİN KULLANILAN İF
                {
                    #region SALESUP TABLOSUNA YAPILACAK KAYIT
                    saleu.SalesID    = int.Parse(txtSatisNo.Text);
                    saleu.EmployeeID = _eb.tblEmployees.First(x => x.Name == txtPersonel.Text).ID;
                    saleu.CompanyID  = _eb.tblCompanies.First(x => x.Name == txtFirma.Text).ID;
                    saleu.Date       = DateTime.Parse(dtpTarih.Text);
                    saleu.CityID     = cbSehir.SelectedIndex + 1;
                    saleu.ShipperID  = _eb.tblShippers.First(x => x.Name == cbKargo.Text).ID;


                    _eb.tblSalesUps.InsertOnSubmit(saleu);
                    #endregion

                    for (int i = 0; i < Liste.RowCount; i++)//SALES DOWNA YAPILACAK OLAN KAYIT VE STOCK TABLOSUNDAKİ DEĞİŞTİRİLECEK QUANTİTY
                    {
                        if (Liste.Rows[i].Cells[1].Value != null)
                        {
                            int pid = int.Parse(Liste.Rows[i].Cells[0].Value.ToString());

                            string[] lotseri = Liste.Rows[i].Cells[2].Value.ToString().Split('-');

                            Array.Resize(ref lotseri, lotseri.Length - 1);
                            string lot = string.Join("-", lotseri);

                            saled[i]            = new tblSalesDown();
                            saled[i].SalesID    = int.Parse(txtSatisNo.Text);
                            saled[i].ProductID  = pid;
                            saled[i].LotSerial  = lot;
                            saled[i].SalesPrice = decimal.Parse(Liste.Rows[i].Cells[4].Value.ToString());
                            saled[i].Quantity   = int.Parse(Liste.Rows[i].Cells[3].Value.ToString());


                            #region SATIŞ YAPILAN ÜRÜNÜN STOCK TABLSOUNDAKİ ADET SAYISININ AZALTILMASI
                            stk[i] = new tblStock();
                            var srg = (from s in _gb.tblStocks
                                       where s.ProductID == pid && s.LotSerial == lot
                                       select s
                                       ).ToList();
                            if (srg.Count > 0 && _db.tblStocks.First(x => x.ProductID == pid && x.LotSerial == lot).Quantity >= int.Parse(Liste.Rows[i].Cells[3].Value.ToString()))
                            {
                                tblStock st = _gb.tblStocks.First(x => x.ProductID == pid && x.LotSerial == lot);
                                st.Quantity -= int.Parse(Liste.Rows[i].Cells[3].Value.ToString());


                                _db.tblSalesDowns.InsertOnSubmit(saled[i]);
                                //_gb.tblStocks.InsertOnSubmit(stk[i]); //bu çalışırsa tblstock içine yeni bi null dolu kayıt ekliyor.

                                kont = true;
                            }
                            else
                            {
                                MessageBox.Show(Liste.Rows[i].Cells[5].Value.ToString() + "ürün stokta yeteri kadar yoktur.", "Stok Hatası", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            #endregion
                        }
                    }


                    if (kont) //SATIŞ YAPIALCAK ÜRÜNÜN SAYISI ELİMİZDEKİ ÜRÜNDEN FAZLAYSA DEĞİŞİKLERİ GERÇEKLEŞTİR
                    {
                        _gb.SubmitChanges();
                        _eb.SubmitChanges();
                        _db.SubmitChanges();
                        _m.YeniKayit("Satış başarılı.");
                        Temizle();
                        _f.Satis();
                        Close();
                    }
                }
                else
                {
                    MessageBox.Show("Eksik bilgi girdiniz. Lütfen tüm bilgileri giriniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception e)
            {
                _m.Hata(e);
            }
        }