public ActionResult DisChargeReport(long id) { try { var user = (ViewUser)Session["user"]; var actionModel = _iCommonManager.GetActionListModelByAreaControllerActionName("Services", "WarrantyBattery", "DisChargeReport"); var product = _iServiceManager.GetReceivedServiceProductById(id); var proudctHistory = _iInventoryManager.GetProductHistoryByBarcode(product.Barcode) ?? new ViewProductHistory(); product.ProductHistory = proudctHistory; product.ForwardToModels = _iCommonManager.GetAllForwardToModelsByUserAndActionId(user.UserId, actionModel.Id).ToList(); int month = GetMonthDifference(Convert.ToDateTime(proudctHistory.SaleDate), product.ReceiveDatetime); ViewTestPolicy policy = _iPolicyManager.DischargeTestPolicyByProductIdCategoryIdAndMonth(proudctHistory.ProductId, 3, month); product.RecBackupTime = policy.AcceptableValue; return(View(product)); } catch (Exception exception) { Log.WriteErrorLog(exception); return(PartialView("_ErrorPartial", exception)); } }
public ViewTestPolicy DischargeTestPolicyByProductIdCategoryIdAndMonth(int productId, int categoryId, int month) { try { CommandObj.CommandText = "UDSP_GetDischargeTestPolicyByProductIdCategoryIdAndMonth"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@Month", month); CommandObj.Parameters.AddWithValue("@ProductId", productId); CommandObj.Parameters.AddWithValue("@CategoryId", categoryId); ConnectionObj.Open(); SqlDataReader reader = CommandObj.ExecuteReader(); ViewTestPolicy policy = new ViewTestPolicy(); if (reader.Read()) { policy.AcceptableValue = Convert.ToDecimal(reader["AcceptableValue"]); policy.ProductId = productId; } reader.Close(); return(policy); } catch (Exception exception) { Log.WriteErrorLog(exception); throw new Exception("Coluld not Collect product test policy by productid,categoryid,month"); } finally { CommandObj.Dispose(); ConnectionObj.Close(); CommandObj.Parameters.Clear(); } }