Beispiel #1
0
        public string CreateGTNDetailString(stock stk, gtnheader gtnh)
        {
            string updateSQL = "";

            try
            {
                updateSQL = "insert into GTNDetail " +
                            "(DocumentID,TemporaryNo,TemporaryDate,StockItemID,ModelNo,Quantity,MRNNo,MRNDate," +
                            "BatchNo,ExpiryDate,PurchaseQuantity,PurchasePrice,PurchaseTax) values (" +
                            "'" + gtnh.DocumentID + "'," +
                            gtnh.TemporaryNo + "," +
                            "'" + gtnh.TemporaryDate.ToString("yyyy-MM-dd") + "'," +
                            "'" + stk.StockItemID + "'," +
                            "'" + stk.ModelNo + "'," +
                            stk.PresentStock + "," +
                            stk.MRNNo + "," +
                            "'" + stk.MRNDate.ToString("yyyy-MM-dd") + "'," +
                            "'" + stk.BatchNo + "'," +
                            "'" + stk.ExpiryDate.ToString("yyyy-MM-dd") + "'," +
                            stk.PurchaseQuantity + "," +
                            stk.PurchasePrice + "," +
                            stk.PurchaseTax + ")";
            }
            catch (Exception ex)
            {
                updateSQL = "";
            }
            return(updateSQL);
        }
        public void UpdateStock(commande cmd)
        {
            GestionStock gs             = new GestionStock();
            stock        st             = gs.FindById(cmd.Stock.GetValueOrDefault());
            var          httpWebRequest = (HttpWebRequest)WebRequest.Create("http://localhost:18080/refugeesCamp-web/api/stock");

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = "	{\"stockType\": \"" + st.stockType + "\",\"qteTotal\": " + cmd.qteOfProduct + ",\"qteInStock\": " + cmd.qteOfProduct + ",\"stockValue\": " + cmd.totalPrice + "}";

                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
            }
        }
Beispiel #3
0
        public int stockInsert(stock stockData)
        {
            stockData.insert_date = DateTime.Now;

            mspbu.stocks.Add(stockData);
            return(mspbu.SaveChanges());
        }
        // GET: stocks/Details/5
        public ActionResult Details(int?id, DateTime?fecha, float?precio)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            stock stock = new stock();

            var ostock = (from d in db.stock
                          where d.producto == id && d.precio == precio
                          select d).FirstOrDefault();

            if (ostock != null)
            {
                stock.producto      = ostock.producto;
                stock.fecha_ingreso = ostock.fecha_ingreso;
                stock.precio        = ostock.precio;
                stock.cantidad      = ostock.cantidad;
            }

            if (stock == null)
            {
                return(HttpNotFound());
            }
            return(View(stock));
        }
        public ActionResult Create(stock s)
        {
            ss.Add(s);
            ss.Commit();

            return(RedirectToAction("Index"));
        }
        protected IList <IndexData> GetLastIndexData(stock stock, IndexDefinitionInfo define)
        {
            using (StockManDBEntities entity = new StockManDBEntities())
            {
                string sql = @"select * from " + define.table_name + " where f_code='" + stock.code + "' order by code desc limit 50";

                entity.Database.Connection.Open();
                using (entity.Database.Connection)
                {
                    System.Data.IDbCommand commond = entity.Database.Connection.CreateCommand();
                    commond.CommandText = sql;
                    IDataReader reader = commond.ExecuteReader();

                    IList <IndexData> list = new List <IndexData>();
                    while (reader.Read())
                    {
                        IndexData id = new IndexData();
                        id.date = DateTime.Parse(reader["date"] + "");
                        foreach (var filed in define.fields)
                        {
                            id.Add(double.Parse(reader[filed.name] + ""));
                        }

                        list.Add(id);
                    }
                    entity.Database.Connection.Close();
                    return(list);
                }
            }
        }
Beispiel #7
0
        static void stockbuysell(int[] a)
        {
            if (a.Length <= 1)
                return;

            int i = 0;
            stock[] s = new stock[a.Length / 2];
            int count = 0;

            while (i < a.Length-1)
            {
                while (i < (a.Length - 1) && (a[i] >= a[i + 1]))
                    i++;

                s[count] = new stock();
                s[count].buy = a[i++];

                while (i < a.Length && (a[i] >= a[i - 1]))
                    i++;

                s[count].sell = a[i - 1];
                count++;
            }

            for (int j = 0; j < count; j++)
                Console.WriteLine("buy = {0} and sell = {1}", s[j].buy, s[j].sell);
        }
        public IHttpActionResult Poststock(stock stock)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.stocks.Add(stock);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (stockExists(stock.store_id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = stock.store_id }, stock));
        }
Beispiel #9
0
        public int insertStock(stock tempStock)
        {
            int result = 1;

            try
            {
                using (SqlConnection con = new SqlConnection(conString))
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("InsertStock", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@prod_ID", tempStock.Product_ID);
                    cmd.Parameters.AddWithValue("@prod_Name", tempStock.Product_Name);
                    cmd.Parameters.AddWithValue("@details", tempStock._details);
                    cmd.Parameters.AddWithValue("@init_Date", tempStock.StockInitiation_Date.ToString("yyyy-MM-dd HH:mm:ss"));
                    cmd.Parameters.AddWithValue("@quantity", tempStock.Quantity);
                    cmd.Parameters.AddWithValue("@cost", tempStock._Cost);
                    result = (Int32)cmd.ExecuteScalar();
                    con.Close();
                }
            }
            catch (Exception e)
            {
                result = 0;
                logger.Error("DAL Error in insertStock: " + e.Message);
                //Console.WriteLine("DAL Error in insertStock: " + e.Message);
            }
            return(result);
        }
        private void deleteBtn_Click(object sender, EventArgs e)
        {
            if (stocksDataGrid.RowCount != 0)
            {
                int selectedIndex = stocksDataGrid.CurrentCell.RowIndex;
                if (selectedIndex > -1)
                {
                    string stockId       = stocksDataGrid.Rows[selectedIndex].Cells[0].Value.ToString();
                    string productId     = stocksDataGrid.Rows[selectedIndex].Cells[1].Value.ToString();
                    string productName   = stocksDataGrid.Rows[selectedIndex].Cells[2].Value.ToString();
                    string details       = stocksDataGrid.Rows[selectedIndex].Cells[3].Value.ToString();
                    string stockDate     = stocksDataGrid.Rows[selectedIndex].Cells[4].Value.ToString();
                    string quantity      = stocksDataGrid.Rows[selectedIndex].Cells[5].Value.ToString();
                    string cost          = stocksDataGrid.Rows[selectedIndex].Cells[5].Value.ToString();
                    stock  selectedStock = new stock(int.Parse(stockId), int.Parse(productId),
                                                     productName, details, Convert.ToDateTime(stockDate), int.Parse(quantity), decimal.Parse(cost));

                    stockDataManipulations stockDataManipulations = new stockDataManipulations();
                    Boolean stockDeletion = stockDataManipulations.deleteStock(selectedStock);

                    if (stockDeletion)
                    {
                        MessageBox.Show("Deletion Successfull. Data deleted successfully", "Important Note",
                                        MessageBoxButtons.OK);
                    }
                    else
                    {
                        MessageBox.Show("Deletion Failed. Error occured while deleting data", "Important Note",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }
                }
            }
        }
        public IHttpActionResult Putstock(long id, stock stock)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != stock.id_stock)
            {
                return(BadRequest());
            }

            db.Entry(stock).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!stockExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutLists(decimal id, stock stock)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != stock.idCoche)
            {
                return(BadRequest());
            }

            db.Entry(stock).State = EntityState.Modified;

            try
            {
                string sql = String.Format("update stock set unidades = '{0}' where idCoche like {1}",
                                           stock.unidades, id);
                db.Database.ExecuteSqlCommand(sql);
                //db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ListsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.OK));
        }
Beispiel #13
0
 public ActionResult add(stock s)
 {
     ViewBag.i = new SelectList(new admin().showall(), "ad_id", "ad_name");
     ViewBag.j = new SelectList(new product().showall(), "prd_id", "prd_name");
     s.add();
     return(RedirectToAction("show"));
 }
Beispiel #14
0
        private void etatStockToolStripMenuItem_Click(object sender, EventArgs e)
        {
            stock form = new stock();

            form.MdiParent = this;
            form.Show();
        }
Beispiel #15
0
 public ActionResult update(stock s)
 {
     ViewBag.i = new SelectList(new admin().showall(), "ad_id", "ad_name");
     ViewBag.j = new SelectList(new product().showall(), "prd_id", "prd_name");
     s.st_id   = (int)TempData["stock_id"];
     s.update();
     return(RedirectToAction("show"));
 }
Beispiel #16
0
        public ActionResult delete(string id)
        {
            stock s = new stock();

            s.st_id = int.Parse(id);
            s.delete();
            return(RedirectToAction("show"));
        }
        public ActionResult DeleteConfirmed(string id)
        {
            stock table_1 = db.stocks.Find(id);

            db.stocks.Remove(table_1);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            stock stock = db.stocks.Find(id);

            db.stocks.Remove(stock);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #19
0
 public void Post(stock stk)
 {
     if (ModelState.IsValid)
     {
         myEntity.stocks.Add(stk);
         myEntity.SaveChanges();
     }
 }
        private void QuoteSearchButton_Click(object sender, EventArgs e)
        {
            string stockCode = QuoteSearchTextBox.Text.ToUpper().Trim();

            stock = this.stockRepo.GetStockByCode(stockCode);
            StockQuoteLabel.Text = stock.code;
            StockNameLabel.Text  = stock.name;
            this.DailyQuoteDataGridView.DataSource = this.quoteRepo.GetStockQuoteByCode(stockCode);
        }
 public ActionResult Edit([Bind(Include = "Symbol")] stock table_1)
 {
     if (ModelState.IsValid)
     {
         db.Entry(table_1).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(table_1));
 }
        private void btnAddProduct_Click(object sender, EventArgs e)
        {
            try
            {
                String pSrchKey = ((txtProductCode.Text).Replace(" ", string.Empty)).Clone().ToString();
                String details  = ((txtDetails.Text).Replace(" ", string.Empty)).Clone().ToString();
                String quantity = ((txtQty.Text).Replace(" ", string.Empty)).Clone().ToString();
                String cost     = ((txtCost.Text).Replace(" ", string.Empty)).Clone().ToString();


                if (pSrchKey == "")
                {
                    pcodeVerify.Show();
                    hideLabelsTimer();
                }
                else if (cost == "")
                {
                    costVerify.Show();
                    hideLabelsTimer();
                }
                else
                {
                    String          pDetails   = (txtDetails.Text).Clone().ToString();
                    String          sQty       = (txtQty.Text).Clone().ToString();
                    String          sCost      = (txtCost.Text).Clone().ToString();
                    String          srchKyWord = (txtProductCode.Text).Clone().ToString();
                    DateTime        addDte     = dateTimePicker1.Value;
                    List <products> prdLst     = new stockDataManipulations().getProdByCode(srchKyWord);
                    if (!(prdLst.Count.Equals(0) || prdLst.ElementAt(0).ProductID.Equals(0)))
                    {
                        stock sdb1   = new stock(0, prdLst.ElementAt(0).ProductID, prdLst.ElementAt(0).ProductName, pDetails, addDte, Convert.ToInt32(sQty), Convert.ToDecimal(sCost));
                        int   result = new stockDataManipulations().addNewStocks(sdb1);
                        if (result.Equals(0))
                        {
                            MessageBox.Show("Insertion Failed.Check the insert data again", "Important Note",
                                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        }
                        else
                        {
                            MessageBox.Show("Insertion Successfull. Data saved successfully", "Important Note",
                                            MessageBoxButtons.OK);
                            clearForm();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Entered product code or name is invalid", "Product not found",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }
                }
            }
            catch (Exception err) {
                logger.Error("\n UIL Error in btnAddProduct_Click: " + err.ToString());
            }
        }
        public IHttpActionResult Getstock(long id)
        {
            stock stock = db.stock.Find(id);

            if (stock == null)
            {
                return(NotFound());
            }

            return(Ok(stock));
        }
Beispiel #24
0
        public int GetStockId(string code)
        {
            int   stockid = 0;
            stock stock   = entities.stocks.Where(q => q.code == code).FirstOrDefault();

            if (stock != null)
            {
                stockid = stock.id;
            }
            return(stockid);
        }
Beispiel #25
0
 public ActionResult Edit([Bind(Include = "Stock_Id,Book_Name,Qty,Available")] stock stock)
 {
     if (ModelState.IsValid)
     {
         db.Entry(stock).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Book_Name = new SelectList(db.Books, "Book_Id", "Book_Name", stock.Book_Name);
     return(View(stock));
 }
 public ActionResult Edit([Bind(Include = "producto,fecha_ingreso,precio,cantidad")] stock stock)
 {
     if (ModelState.IsValid)
     {
         db.Entry(stock).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.producto = new SelectList(db.producto, "id", "nombre", stock.producto);
     return(View(stock));
 }
Beispiel #27
0
        public ActionResult Edit(int id, stock don)
        {
            stock d1 = ss.Get(e => e.Id == id);

            d1.description = don.description;
            d1.type        = don.type;

            ss.Update(d1);
            ss.Commit();
            return(RedirectToAction("Index"));
        }
Beispiel #28
0
        public ActionResult update(string id)
        {
            ViewBag.i = new SelectList(new admin().showall(), "ad_id", "ad_name");
            ViewBag.j = new SelectList(new product().showall(), "prd_id", "prd_name");
            stock s = new stock();

            s.st_id = int.Parse(id);
            TempData["stock_id"] = s.st_id;
            stock ss = s.search();

            return(View(ss));
        }
 public ActionResult Edit([Bind(Include = "store_id,product_id,quantity")] stock stock)
 {
     if (ModelState.IsValid)
     {
         db.Entry(stock).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.product_id = new SelectList(db.products, "product_id", "product_name", stock.product_id);
     ViewBag.store_id   = new SelectList(db.stores, "store_id", "store_name", stock.store_id);
     return(View(stock));
 }
        public IHttpActionResult Poststock(stock stock)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.stock.Add(stock);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = stock.id_stock }, stock));
        }
Beispiel #31
0
        public ActionResult Create([Bind(Include = "Stock_Id,Book_Name,Qty,Available")] stock stock)
        {
            if (ModelState.IsValid)
            {
                db.stocks.Add(stock);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Book_Name = new SelectList(db.Books, "Book_Id", "Book_Name", stock.Book_Name);
            return(View(stock));
        }
Beispiel #32
0
 public IEnumerable<Stock.Dal.stock> GetAllStocks()
 {
     List<stock> stocks = new List<stock>();
     stock s1 = new stock();
     s1.id = 1;
     s1.stockcode = "goog";
     stocks.Add(s1);
     stock s2 = new stock();
     s2.id = 2;
     s2.stockcode = "appl";
     stocks.Add(s2);
     stock s3 = new stock();
     s3.id = 3; ;
     s3.stockcode = "msft";
     stocks.Add(s3);
     return stocks;
 }