Beispiel #1
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            inv_ItemHistory inv_ItemHistory = await db.inv_ItemHistory.FindAsync(id);

            db.inv_ItemHistory.Remove(inv_ItemHistory);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public async Task <ActionResult> UpdateQuantity(inv_Items Item, inv_ItemHistory ItemHistory, decimal?NewQuantity)
        {
            int status = 0;

            long ItemId;

            if (Item.ItemID > 0)
            {
                //Edit
                var v = db.inv_Items.Where(a => a.ItemID == Item.ItemID).FirstOrDefault();
                if (v != null)
                {
                    Session["OldQuantityTemp"] = v.ItemQuantity;
                    Session["NewQuantityTemp"] = NewQuantity;

                    v.ItemID = Item.ItemID;
                    ItemId   = Item.ItemID;

                    v.ItemQuantity = int.Parse(Session["OldQuantityTemp"].ToString()) + int.Parse(Session["NewQuantityTemp"].ToString());

                    await db.SaveChangesAsync();

                    status = 1;


                    // Log ItemHistroy

                    string constr = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;
                    using (SqlConnection con = new SqlConnection(constr))
                    {
                        using (SqlCommand cmd = new SqlCommand("Insert_ItemHistory"))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.AddWithValue("@ItemID", Item.ItemID);
                            cmd.Parameters.AddWithValue("@ItemHistoryQuantity", long.Parse(Session["NewQuantityTemp"].ToString()));
                            cmd.Parameters.AddWithValue("@ItemHistoryProccessTypeID", 1);
                            cmd.Parameters.AddWithValue("@ItemHistoryDebitOrCredit", true);
                            cmd.Parameters.AddWithValue("@ItemHistoryDecription", "توريدة جديدة");

                            cmd.Connection = con;
                            con.Open();
                            cmd.ExecuteNonQuery();
                            con.Close();
                        }
                    }

                    //Log ItemHistroy
                }
            }


            return(new JsonResult {
                Data = new { status = status }
            });
        }
Beispiel #3
0
        public async Task <ActionResult> Edit([Bind(Include = "ItemHistoryID,ItemID,ItemHistoryQuantity,QuantityMeasureUnit,ItemHistoryDebitOrCredit,ItemHistoryCuurentQuantity,ItemHistoryProccessTypeID,ItemHistoryProccessType,ItemHistoryDecription,ItemHistoryDate,UpLoaded,ItemHistoyPrice")] inv_ItemHistory inv_ItemHistory)
        {
            if (ModelState.IsValid)
            {
                db.Entry(inv_ItemHistory).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(inv_ItemHistory));
        }
Beispiel #4
0
        // GET: ItemHistory/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            inv_ItemHistory inv_ItemHistory = await db.inv_ItemHistory.FindAsync(id);

            if (inv_ItemHistory == null)
            {
                return(HttpNotFound());
            }
            return(View(inv_ItemHistory));
        }