public ServiceEntryResponse ServiceEntryWithoutPrint([FromBody] ServiceEntry serviceEntryList) { try { string Details = JsonConvert.SerializeObject(serviceEntryList.serviceDetails); string vehicleno = serviceEntryList.vehicleNumber; int vehicletype = serviceEntryList.VehicleType; int partytype = serviceEntryList.partyType; int baytype = serviceEntryList.baytype; string url = serviceEntryList.base64img; string remarks = serviceEntryList.remarks; string customer = serviceEntryList.customername; decimal total = serviceEntryList.Total; decimal discount = serviceEntryList.discount; decimal netamt = serviceEntryList.netamount; var path = ""; if (!Directory.Exists(System.Web.Hosting.HostingEnvironment.MapPath("~/Images/" + DateTime.Now.ToString("dd_MM_yyyy")))) { Directory.CreateDirectory(System.Web.Hosting.HostingEnvironment.MapPath("~/Images/" + DateTime.Now.ToString("dd_MM_yyyy"))); } path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~/Images/" + DateTime.Now.ToString("dd_MM_yyyy") + "/"), "V_" + DateTime.Now.ToString("dd_MM_yyyy_hhmmss") + ".jpg"); string base64Img = ""; int index = serviceEntryList.base64img.IndexOf(','); base64Img = serviceEntryList.base64img.Substring(index + 1); File.WriteAllBytes(path, Convert.FromBase64String(base64Img)); int pathindex = path.IndexOf("Images/"); path = path.Substring(index + 1); int EntryStarNo = int.Parse(WebConfigurationManager.AppSettings["ServiceEntryStartNo"].ToString()); ObjectResult <Nullable <int> > queryResult = db.VSR_Trn_ServiceEntry_Save(EntryStarNo, baytype, partytype, vehicleno, vehicletype, path, remarks, customer, total, discount, netamt, Details); int ID = 0; foreach (Nullable <int> result in queryResult) { ID = result.Value; } ServiceEntryResponse SR = new ServiceEntryResponse(); List <VSR_Trn_ServiceEntryDetails_GetByServeEntryID_Result> ServicePricing = new List <VSR_Trn_ServiceEntryDetails_GetByServeEntryID_Result>(); ServicePricing = db.VSR_Trn_ServiceEntryDetails_GetByServeEntryID(ID).ToList(); SR.status = 1; SR.message = "Saved Successfully !!"; SR.ServiceDetails = ServicePricing; return(SR); } catch (Exception ex) { ServiceEntryResponse SR = new ServiceEntryResponse(); SR.status = 0; SR.message = "Error Occured While Saving Details"; return(SR); } }
public ServiceEntryResponse SaveServiceEntry([FromBody] ServiceEntry serviceEntryList) { try { string Details = JsonConvert.SerializeObject(serviceEntryList.serviceDetails); string vehicleno = serviceEntryList.vehicleNumber; int vehicletype = serviceEntryList.VehicleType; int partytype = serviceEntryList.partyType; int baytype = serviceEntryList.baytype; string url = serviceEntryList.base64img; string remarks = serviceEntryList.remarks; string customer = serviceEntryList.customername; decimal total = serviceEntryList.Total; decimal discount = serviceEntryList.discount; decimal netamt = serviceEntryList.netamount; var path = ""; if (!Directory.Exists(System.Web.Hosting.HostingEnvironment.MapPath("~/Images/" + DateTime.Now.ToString("dd_MM_yyyy")))) { Directory.CreateDirectory(System.Web.Hosting.HostingEnvironment.MapPath("~/Images/" + DateTime.Now.ToString("dd_MM_yyyy"))); } path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~/Images/" + DateTime.Now.ToString("dd_MM_yyyy") + "/"), "V_" + DateTime.Now.ToString("dd_MM_yyyy_hhmmss") + ".jpg"); string base64Img = ""; int index = serviceEntryList.base64img.IndexOf(','); base64Img = serviceEntryList.base64img.Substring(index + 1); File.WriteAllBytes(path, Convert.FromBase64String(base64Img)); int pathindex = path.IndexOf("Images/"); path = path.Substring(index + 1); int EntryStarNo = int.Parse(WebConfigurationManager.AppSettings["ServiceEntryStartNo"].ToString()); ObjectResult <Nullable <int> > queryResult = db.VSR_Trn_ServiceEntry_Save(EntryStarNo, baytype, partytype, vehicleno, vehicletype, path, remarks, customer, total, discount, netamt, Details); int ID = 0; foreach (Nullable <int> result in queryResult) { ID = result.Value; } ServiceEntryResponse SR = new ServiceEntryResponse(); List <VSR_Trn_ServiceEntryDetails_GetByServeEntryID_Result> ServicePricing = new List <VSR_Trn_ServiceEntryDetails_GetByServeEntryID_Result>(); ServicePricing = db.VSR_Trn_ServiceEntryDetails_GetByServeEntryID(ID).ToList(); DataTable dt = ToDataTable(ServicePricing); // System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "openModal", "window.open('../Report/RDLCVwr.aspx?rt=gplqtn&ft=pdf&no=" + e.CommandArgument.ToString() + "' ,'_blank');", true); LocalReport report = new LocalReport(); report.ReportPath = "Reports\\ServiceCenter\\serviceentryPrint.rdlc"; //report.ReportEmbeddedResource = ("serviceentryPrint.rdlc"); report.DataSources.Add(new ReportDataSource("DataSet1", dt)); Export(report); //m_currentPageIndex = 0; //Print(); SR.status = 1; SR.message = "Saved Successfully !!"; SR.ServiceDetails = ServicePricing; return(SR); } catch (Exception ex) { ServiceEntryResponse SR = new ServiceEntryResponse(); SR.status = 0; SR.message = "Error Occured While Saving Details"; return(SR); } }