Esempio n. 1
0
        /// <summary>
        /// Get Sale Order Ref. No. and Date, GRN Ref. No. and Date, Work Desc. Ref. No and Short Name
        /// </summary>
        /// <param name="id">SaleOrderId OR SaleOrderItemId</param>
        /// <param name="type">0 if SaleOrderId, 1 if SaleOrderItemId</param>
        /// <returns>JsonResult</returns>
        public JsonResult GetItemBatchDetails(int id, int type)
        {
            ItemBatch model = new ItemBatchRepository().GetItemBatchDetails(id, type);

            return(Json(new
            {
                WorkDescRefNo = model.WorkDescrRefNo + " - " + model.WorkDescrShortName,
                SaleOrderRefNo = model.SaleOrderRefNo + " - " + model.SaleOrderDate,
                GRNRefNo = model.GRNNo + " - " + model.GRNDate.ToString("dd MMMM yyyy")
            }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
 public ActionResult Reserve(int id = 0, int item = 0)//SOI id and material id is received here
 {
     if (id != 0 && item != 0)
     {
         var items = new ItemBatchRepository().GetItemBatchForReservation(id, item);
         return(View(items));
     }
     else
     {
         TempData["success"] = "";
         TempData["error"]   = "That was an invalid request. Please try again.";
         return(RedirectToAction("PendingReservation"));
     }
 }
Esempio n. 3
0
 public ActionResult Delete(int id = 0, int type = 0)//type=0 means GRNItemId, type=1 means OpeningStockId
 {
     try
     {
         var    model  = new ItemBatchRepository().DeleteItemBatch(id, type, UserID, OrganizationId);
         string ref_no = string.Empty;
         foreach (var item in model)
         {
             ref_no += ", " + item.SerialNo;
         }
         TempData["success"] = "Deleted Successfully (" + ref_no.Substring(2) + ")";
         return(RedirectToAction("Index"));
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occurred while deleting. Please try again.";
         return(RedirectToAction("Edit", new { id = id, type = type }));
     }
 }
Esempio n. 4
0
 public ActionResult Create(int id = 0, int type = 0)
 {
     try
     {
         if (id != 0)
         {
             ItemBatch model = new ItemBatch();
             if (type == 0)
             {
                 model = new ItemBatchRepository().GetGRNItem(grnItemId: id);
             }
             else if (type == 1)
             {
                 model = new ItemBatchRepository().GetOpeningStockItem(OpeningStockItemId: id);
             }
             model.isOpeningStock = type;
             List <ItemBatch> list = new List <ItemBatch>();
             for (int i = 0; i < model.Quantity; i++)
             {
                 list.Add(model);
             }
             return(View(list));
         }
         throw new NullReferenceException();
     }
     catch (NullReferenceException)
     {
         TempData["success"] = "";
         TempData["error"]   = "Some required data was missing. Please try again";
     }
     catch (SqlException sx)
     {
         TempData["success"] = "";
         TempData["error"]   = "Some error occured while connecting to database. Check your network connection and try again|" + sx.Message;
     }
     catch (Exception)
     {
         TempData["success"] = "";
         TempData["error"]   = "Some error occured. Please try again";
     }
     return(RedirectToAction("Pending"));
 }
Esempio n. 5
0
        public ActionResult Create(IList <ItemBatch> model)
        {
            HashSet <string> temp = new HashSet <string>();

            foreach (var item in model)
            {
                temp.Add(item.SerialNo);
            }
            if (temp.Count != model.Count)
            {
                TempData["error"] = "Serial numbers cannot be same. Please enter different serial numbers.";
                return(View(model));
            }
            foreach (ItemBatch item in model)
            {
                item.CreatedBy      = UserID.ToString();
                item.OrganizationId = OrganizationId;
                item.CreatedDate    = DateTime.Now;
            }
            try
            {
                string existingSerialNos = new ItemBatchRepository().IsSerialNoExists(model.Select(m => m.SerialNo).ToList());
                if (existingSerialNos == null)
                {
                    new ItemBatchRepository().InsertItemBatch(model);
                    TempData["success"] = "Saved successfully";
                    TempData["error"]   = "";
                    return(RedirectToAction("Pending", new { type = model[0].isOpeningStock }));
                }
                TempData["error"] = existingSerialNos + " already exists.";
            }
            catch (Exception ex)
            {
                TempData["success"] = "";
                TempData["error"]   = "Some error occured while connecting to database. Check your network connection and try again|" + ex.Message;
            }
            return(View(model));
        }