public ActionResult PrintWOFactur(string random, string woId) { string msg = string.Empty; bool success = false; bool allowPrint = true; try { //get wo by wo id TWO wo = this._woTasks.One(woId); //check if user have print WO, if not, allow print for role CS if (User.IsInRole("CS")) { allowPrint = !_woLogTasks.HaveBeenPrint(wo, User.Identity.Name); } if (allowPrint) { ReportParameterCollection paramCol = null; ReportDataSource[] repCol = new ReportDataSource[1]; //get data source repCol[0] = GetWOById(wo); //save log SaveLog(wo, EnumWOLog.Print); Session["ReportData"] = repCol; Session["ReportParams"] = paramCol; success = true; msg = "Print WO success"; } else { success = false; msg = "Anda sudah pernah mencetak WO"; } } catch (Exception ex) { success = false; msg = ex.GetBaseException().Message; } var e = new { Success = success, Message = msg, UrlReport = string.Format("{0}", EnumReports.RptPrintWOFactur.ToString()) }; return(Json(e, JsonRequestBehavior.AllowGet)); }
public ActionResult PrintWOFactur(string random, string woId) { string msg = string.Empty; bool success = false; bool allowPrint = true; EnumReports rptToPrint = EnumReports.RptPrintWOFactur; try { //get wo by wo id TWO wo = this._woTasks.One(woId); //check if user have print WO, if not, allow print for role CS if (User.IsInRole("CS")) { allowPrint = !_woLogTasks.HaveBeenPrint(wo, User.Identity.Name); } if (allowPrint) { ReportParameterCollection paramCol = null; ReportDataSource[] repCol = new ReportDataSource[1]; //get data source IList <WOViewModel> listWO = GetWOById(wo); ReportDataSource reportDataSource = new ReportDataSource("WOViewModel", listWO); repCol[0] = reportDataSource; //set rpt to print switch (listWO[0].MerkName) { case "CROSS": rptToPrint = EnumReports.RptPrintWOFacturEvercoss; break; case "ADVAN": rptToPrint = EnumReports.RptPrintWOFacturAdvan; break; default: rptToPrint = EnumReports.RptPrintWOFacturGJCell; break; } //save log SaveLog(wo, EnumWOLog.Print); Session["ReportData"] = repCol; Session["ReportParams"] = paramCol; success = true; msg = "Print WO success"; } else { success = false; msg = "Anda sudah pernah mencetak WO"; } } catch (Exception ex) { success = false; msg = ex.GetBaseException().Message; } var e = new { Success = success, Message = msg, UrlReport = string.Format("{0}&rs%3aFormat=HTML4.0", rptToPrint.ToString()) }; return(Json(e, JsonRequestBehavior.AllowGet)); }