示例#1
0
        public void Ac(int id)
        {
            try
            {
                Liste.Rows.Clear();
                _aid = id;
                tblPurchasing pur = _db.tblPurchasings.First(x => x.PurNo == _aid);
                txtAlisNo.Text   = pur.PurNo.ToString().PadLeft(7, '0');
                txtFirma.Text    = pur.tblCompany.Name;
                txtPersonel.Text = pur.tblEmployee.Name;

                int i   = 0;
                var srg = from s in _db.tblPurchasings where s.PurNo == _aid select s;

                foreach (tblPurchasing 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[2].Value = k.LotSerial;
                    Liste.Rows[i].Cells[3].Value = k.PurchasingPrice;
                    Liste.Rows[i].Cells[4].Value = k.Quantity;
                    i++;
                }
            }
            catch (Exception e)
            {
                _m.Hata(e);
            }
        }
示例#2
0
        void YeniKaydet()
        {
            Liste.AllowUserToAddRows = false;
            try
            {
                tblPurchasing[] pur = new tblPurchasing[Liste.RowCount];
                tblStock[]      stk = new tblStock[Liste.RowCount];

                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();
                    pur[i]       = new tblPurchasing();
                    pur[i].PurNo = int.Parse(txtAlisNo.Text);
                    //pur[i].PurNo = int.Parse(Liste.Rows[i].Cells[5].Value.ToString());
                    pur[i].CompanyID       = _db.tblCompanies.First(x => x.Name == txtFirma.Text).ID;
                    pur[i].ProductID       = int.Parse(Liste.Rows[i].Cells[0].Value.ToString());
                    pur[i].LotSerial       = Liste.Rows[i].Cells[2].Value.ToString();
                    pur[i].Date            = DateTime.Parse(dtpTarih.Text);
                    pur[i].PurchasingPrice = decimal.Parse(Liste.Rows[i].Cells[3].Value.ToString());
                    pur[i].Quantity        = int.Parse(Liste.Rows[i].Cells[4].Value.ToString());
                    pur[i].EmployeeID      = _db.tblEmployees.First(x => x.Name == txtPersonel.Text).ID;

                    _db.tblPurchasings.InsertOnSubmit(pur[i]);

                    AccountingDBDataContext _gb = new AccountingDBDataContext();

                    stk[i] = new tblStock();
                    var srg = (from s in _gb.tblStocks where s.ProductID == int.Parse(Liste.Rows[i].Cells[0].Value.ToString()) && s.LotSerial == Liste.Rows[i].Cells[2].Value.ToString() select s).ToList();

                    if (srg.Count == 0)
                    {
                        stk[i].ProductID = int.Parse(Liste.Rows[i].Cells[0].Value.ToString());
                        stk[i].LotSerial = Liste.Rows[i].Cells[2].Value.ToString();
                        stk[i].Quantity  = int.Parse(Liste.Rows[i].Cells[4].Value.ToString());

                        _gb.tblStocks.InsertOnSubmit(stk[i]);
                    }
                    else
                    {
                        tblStock st = _gb.tblStocks.First(x => x.ProductID == pid && x.LotSerial == lot);
                        st.Quantity += int.Parse(Liste.Rows[i].Cells[4].Value.ToString());
                    }
                    _gb.SubmitChanges();
                }
                _db.SubmitChanges();
                _m.YeniKayit("Kayıt başarılı!!");
            }
            catch (Exception e)
            {
                _m.Hata(e);
            }
        }