Ejemplo n.º 1
0
 private void addItemStock_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (itemCode > 0)
     {
         addItem myform = new addItem(_user);
         myform.Show();
     }
 }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            addItem myForm = new addItem();

            //myForm.TopLevel = false;
            //myForm.WindowState = FormWindowState.Maximized;
            //panel1.Controls.Add(myForm);
            myForm.Show();
        }
Ejemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (radioAddNew.Checked)
                {
                    string   code         = txtItemCode.Text;
                    string   Quantity     = txtQty.Text;
                    string   UnitPrice    = txtUnitPrice.Text;
                    string   SellingPrice = txtSellingPrice.Text;
                    DateTime addedDate    = txtAddingDate.Value.Date;
                    DateTime expDate      = txtEDate.Value.Date;
                    DateTime mfDate       = txtMDate.Value.Date;

                    int icode = Convert.ToInt32(code);
                    if (code != "" && Quantity != "" && UnitPrice != "" && SellingPrice != "")
                    {
                        _PhamaPOSEntities = _dbConnector.getConn();
                        int   itemId = _PhamaPOSEntities.items.Where(a => a.itemCode == icode).FirstOrDefault().itemId;
                        stock _stock = new stock();
                        _stock.itemId               = itemId;
                        _stock.isAvailable          = true;
                        _stock.entryDate            = DateTime.Now;
                        _stock.entryBy              = _user.userName;
                        _stock.itemUnitPriceBuying  = Convert.ToDecimal(UnitPrice);
                        _stock.itemUnitPriceSelling = Convert.ToDecimal(SellingPrice);
                        _stock.runningQuantity      = Convert.ToInt32(Quantity);
                        _stock.stockExpDate         = expDate;
                        _stock.stockMfdDate         = mfDate;
                        _stock.StockQuantity        = Convert.ToInt32(Quantity);
                        _stock.stockReceivedDate    = addedDate;

                        _PhamaPOSEntities.stocks.Add(_stock);
                        _PhamaPOSEntities.SaveChanges();
                        ClearFields();
                        MessageBox.Show("Stock Successfully added..");
                        if (itemCode != null)
                        {
                            this.Dispose();
                            addItem i = new addItem(_user);
                            i.Show();
                        }
                        else
                        {
                            this.Dispose();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please Fill All the mandetary fields..");
                    }
                }
                else
                {
                    string   code         = txtItemCode.Text;
                    string   Quantity     = txtQty.Text;
                    string   UnitPrice    = txtUnitPrice.Text;
                    string   SellingPrice = txtSellingPrice.Text;
                    DateTime addedDate    = txtAddingDate.Value.Date;
                    DateTime expDate      = txtEDate.Value.Date;
                    DateTime mfDate       = txtMDate.Value.Date;
                    int      batchId      = Convert.ToInt32(drpBatch.SelectedValue);
                    int      icode        = Convert.ToInt32(code);
                    if (code != "" && Quantity != "" && UnitPrice != "" && SellingPrice != "")
                    {
                        _PhamaPOSEntities = _dbConnector.getConn();
                        var _stock = _PhamaPOSEntities.stocks.Where(a => a.stockId == batchId).FirstOrDefault();

                        _stock.stockExpDate         = expDate;
                        _stock.runningQuantity      = Convert.ToInt32(Quantity);
                        _stock.itemUnitPriceBuying  = Convert.ToDecimal(UnitPrice);
                        _stock.itemUnitPriceSelling = Convert.ToDecimal(SellingPrice);
                        _stock.stockMfdDate         = mfDate;
                        _stock.StockQuantity        = Convert.ToInt32(Quantity);

                        _PhamaPOSEntities.stocks.Attach(_stock);
                        var entry = _PhamaPOSEntities.Entry(_stock);

                        entry.Property(a => a.runningQuantity).IsModified      = true;
                        entry.Property(a => a.itemUnitPriceBuying).IsModified  = true;
                        entry.Property(a => a.itemUnitPriceSelling).IsModified = true;
                        entry.Property(a => a.stockExpDate).IsModified         = true;
                        entry.Property(a => a.stockMfdDate).IsModified         = true;
                        entry.Property(a => a.StockQuantity).IsModified        = true;
                        _PhamaPOSEntities.SaveChanges();
                        MessageBox.Show("Stock Successfully updated..");
                        ClearFields();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Please Fill All the mandetary fields..");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Occured.. Please Retry.. " + ex.Message);
            }
        }
Ejemplo n.º 4
0
        private void addItemsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            addItem myForm = new addItem(_user);

            myForm.Show();
        }