/// <summary> /// This method is used to Update Status and Upload Response File . /// </summary> /// <param name="tr"></param> public void UpdateCoverDesignData(CoverDesign tr) { try { clsParameterCollection clsParaCollection = new clsParameterCollection(); clsParaCollection.Add(new clsParameter("@TrnID", tr.Trn_ID)); clsParaCollection.Add(new clsParameter("@Status", tr.Status)); clsParaCollection.Add(new clsParameter("@ResponseDate", tr.ResponseDate)); if (tr.ResponseFilePath != null) { clsParaCollection.Add(new clsParameter("@ResponseFilePath", tr.ResponseFilePath)); clsParaCollection.ProcedureName = Constants.sp_CoverDesign_updateResponse; } else { clsParaCollection.ProcedureName = Constants.sp_CoverDesign_updateStatus; } DataAccess.ExecuteNonQuerySp(clsParaCollection); } catch (Exception ex) { BL_Exception.WriteLog(ex); throw ex; } }
/// <summary> /// This method is used to insert Record of CoverDesign Serive request against respective User(userid). /// </summary> /// <param name="CDRef"></param> public void InsertCoverDesignData(CoverDesign CDRef) { try { clsParameterCollection clsParaCollection = new clsParameterCollection(); clsParaCollection.ProcedureName = Constants.sp_CoverDesign_insertCoverDesign; clsParaCollection.Add(new clsParameter("@UserID", CDRef.UserID)); clsParaCollection.Add(new clsParameter("@LangID", CDRef.Language)); clsParaCollection.Add(new clsParameter("@SizeID", CDRef.BookSize)); clsParaCollection.Add(new clsParameter("@SpineSize", CDRef.SpineSize)); clsParaCollection.Add(new clsParameter("@CoverDesignType", CDRef.CoverDesignType)); clsParaCollection.Add(new clsParameter("@BindingType", CDRef.BindingType)); clsParaCollection.Add(new clsParameter("@RequestFilePath", CDRef.RequestFilePath)); clsParaCollection.Add(new clsParameter("@StatusID", CDRef.Status)); clsParaCollection.Add(new clsParameter("@RequestDate", CDRef.RequestDate)); clsParaCollection.Add(new clsParameter("@EstimatedAmt", CDRef.EstimatedAmt)); clsParaCollection.Add(new clsParameter("@OrderID", CDRef.OrderID)); clsParaCollection.Add(new clsParameter("@CoverDesignSynopsis", CDRef.CoverDesignSynopsis)); clsParaCollection.Add(new clsParameter("@upfID", CDRef.upfID)); DataAccess.ExecuteNonQuerySp(clsParaCollection); } catch (Exception ex) { BL_Exception.WriteLog(ex); throw ex; } }
/// <summary> /// This method is used to fetch UserName based on TrnID. /// </summary> /// <param name="tr"></param> /// <returns></returns> public string GetUserName(CoverDesign tr) { try { clsParameterCollection clsParaCollection = new clsParameterCollection(); clsParaCollection.ProcedureName = Constants.sp_CoverDesign_GetUserNameFromTranID; clsParaCollection.Add(new clsParameter("@TrnId", tr.Trn_ID)); dt.Reset(); dt = DataAccess.ExecuteSpAndGetDataTable(clsParaCollection); return dt.Rows[0][0].ToString(); } catch (Exception ex) { BL_Exception.WriteLog(ex); throw ex; } }
/// <summary> /// This Action loads CoverDesign view. /// </summary> /// <returns></returns> public ActionResult CoverDesign(int? page, string sort, string sortdir, string UserName, string StartDate, string EndDate, int? RecordsPerPage, string upfID) { if (upfID != "") { HttpContext.Session["upfID"] = upfID; } var model = new CoverDesign(); //Check whether package is taken or not, 0 for not taken and 1 for taken DataTable dt = BLObj.GetPackageInfobyuserid(Convert.ToString(Common.GetUserId(HttpContext.User.Identity.Name))); if (dt.Rows.Count > 0) model.IsPackageTaken = 1; else model.IsPackageTaken = 0; model.PagingRange = Constants.PagingRange; if (!string.IsNullOrEmpty(UserName)) { model.txtFilterUserName = UserName; } if (!string.IsNullOrEmpty(StartDate)) { model.StartDate = StartDate; model.EndDate = EndDate; } if (page != null) { model.CurrentPage = Convert.ToInt32(page); if (RecordsPerPage == null) { model.StartIndex = (Convert.ToInt32(page) * 5) - 4; model.EndIndex = Convert.ToInt32(page) * 5; } else { model.RecordsPerPage = Convert.ToInt32(RecordsPerPage); model.StartIndex = (Convert.ToInt32(page) * model.RecordsPerPage) - (model.RecordsPerPage - 1); model.EndIndex = Convert.ToInt32(page) * model.RecordsPerPage; } if (!string.IsNullOrEmpty(sort)) { model.sort = sort; model.sortdir = sortdir; } else { model.sort = "Trn_ID"; model.sortdir = "Desc"; } } else { model.CurrentPage = 1; if (RecordsPerPage == null) { model.StartIndex = 1; model.EndIndex = 5; } else { model.RecordsPerPage = Convert.ToInt32(RecordsPerPage); model.StartIndex = 1; model.EndIndex = model.RecordsPerPage; } if (!string.IsNullOrEmpty(sort)) { model.sort = sort; model.sortdir = sortdir; } else { model.sort = "Trn_ID"; model.sortdir = "Desc"; } } model.UserName = UserName; getDisplayData(ref model); model.LastPageIndex = model.Pages; if (string.IsNullOrEmpty(sort)) { if (Request.IsAjaxRequest()) { return PartialView("_WebgridCoverDesign", model); } } if (!string.IsNullOrEmpty(sort) && page != null) { return PartialView("_WebgridCoverDesign", model); } return View(model); }
/// <summary> /// This method is used to load model to display Webgrid data. /// </summary> /// <param name="model"></param> private void getDisplayData(ref CoverDesign model) { model.ListLang = LoadLanguageDropDown(); model.ListStatus = LoadStatusDropDown(); model.ListBookSize = LoadBookSizeDropDown(); //MembershipUser MemberUser = Membership.GetUser(User.Identity.Name); //string UserId = MemberUser.ProviderUserKey.ToString(); string UserId = Convert.ToString(Common.GetUserId(HttpContext.User.Identity.Name)); DataTable dtData = new DataTable(); dtData = BLObj.getRowsCount(Convert.ToString(model.UserName), UserId, model.StartDate, model.EndDate); model.Pages = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(dtData.Rows[0][0].ToString()) / Convert.ToDouble((model.RecordsPerPage == 0) ? 5.00 : model.RecordsPerPage))); dtData.Clear(); if (!string.IsNullOrEmpty(model.StartDate) && !string.IsNullOrEmpty(model.UserName)) { dtData = BLObj.GetFilteredCoverDesignDataByBoth(model.UserName, model.StartIndex, model.EndIndex, model.sort, model.sortdir, model.StartDate, model.EndDate); } else if (!string.IsNullOrEmpty(model.StartDate)) { dtData = BLObj.GetFilteredCoverDesignDataByDates(UserId, model.StartIndex, model.EndIndex, model.sort, model.sortdir, model.StartDate, model.EndDate); } else if (!string.IsNullOrEmpty(model.UserName)) { dtData = BLObj.GetFilteredCoverDesignData(model.UserName, model.StartIndex, model.EndIndex, model.sort, model.sortdir); } else { dtData = BLObj.GetCoverDesignUserData(UserId, model.StartIndex, model.EndIndex, model.sort, model.sortdir); } List<CoverDesign> listData = new List<CoverDesign>(); foreach (DataRow dr in dtData.Rows) { listData.Add(new CoverDesign { SrNo = Convert.ToInt32(dr["row"]), Trn_ID = dr["Trn_ID"].ToString(), OrderID = dr["OrderID"].ToString(), UserName = dr["UserName"].ToString(), Language = dr["lang_Name"].ToString(), BookSize = dr["size_Name"].ToString(), SpineSize = dr["SpineSize"].ToString(), RequestFilePath = dr["RequestFilePath"].ToString(), CoverDesignType = dr["CoverDesignType"].ToString(), BindingType = dr["BindingType"].ToString(), CoverDesignSynopsis = dr["CoverDesignSynopsis"].ToString(), ResponseFilePath = dr["ResponseFilePath"].ToString(), Status = dr["status_Name"].ToString(), EstimatedAmt = Convert.ToInt32(dr["EstimatedAmt"]), isPaymentRelesed = dr["IsPaymentReleased"].ToString(), RequestDate = dr["RequestDate"].ToString(), ResponseDate = dr["ResponseDate"].ToString() }); } model.ModelList = listData; }
public ActionResult CoverDesign(CoverDesign cr, FormCollection form, string Command, string PageIndex) { if (Command == "Submit") { var uploadedFile = Request.Files[0]; var fileName1 = Path.GetFileName(uploadedFile.FileName); string UserName = HttpContext.User.Identity.Name; if (fileName1 != String.Empty) { string strFileExtension = Path.GetExtension(uploadedFile.FileName); if (strFileExtension == ".jpg" || strFileExtension == ".jpeg" || strFileExtension == ".cdr" || strFileExtension == ".doc" || strFileExtension == ".docx")// || strFileExtension == ".pdf") { fileName1 = UserName + "_" + Constants.strResponse + "_" + DateTime.Today.ToString("dd-MM-yyyy") + "_" + fileName1; if (!Directory.Exists(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + UserName + "//" + Constants.strResponse)) { Directory.CreateDirectory(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + UserName + "//" + Constants.strResponse); } var fileSavePath = Server.MapPath(Constants.strUploadFileIntialPath + "//" + UserName + "//" + Constants.strResponse + "//" + fileName1); uploadedFile.SaveAs(fileSavePath); cr.RequestFilePath = fileName1; } else { TempData["StatusMessage"] = "Only.jpg/.jpeg/.cdr/.doc/.docx file allowed!"; TempData["StatusMessageClass"] = "text-danger bg-danger"; return RedirectToAction("CoverDesign"); } } if (HttpContext.Session["upfID"] != null) { cr.upfID = Convert.ToInt32(HttpContext.Session["upfID"]); } else { cr.upfID = 0; } cr.ListLang = LoadLanguageDropDown(); cr.ListStatus = LoadStatusDropDown(); //MembershipUser MemberUser = Membership.GetUser(User.Identity.Name); //string UserId = MemberUser.ProviderUserKey.ToString(); string UserId = Convert.ToString(Common.GetUserId(HttpContext.User.Identity.Name)); cr.OrderID = Common.GetUniqueKey(User.Identity.Name, cr.serviceChar); //cr.RequestFilePath = ""; cr.UserID = UserId; cr.Language = form["ddlLang"]; cr.BookSize = form["ddlSize"]; cr.SpineSize = form["txtSpineSize"]; cr.CoverDesignType = form["rbnCVDesign"]; DataTable ServiceTax = BLObj.GetServiceTax(); if (form["rbnCVDesign"].Contains("Graphical") || form["rbnCVDesign"].Contains("graphical")) { DataTable coverdesignprice = BLObj.GetPricingForCoverDesing("Graphical"); String priceafterServiceTax = (Convert.ToDouble(coverdesignprice.Rows[0][0]) + (Convert.ToDouble(coverdesignprice.Rows[0][0]) * (Convert.ToDouble(ServiceTax.Rows[0][0]) / 100))).ToString(); cr.EstimatedAmt = Convert.ToInt32(priceafterServiceTax); } else //if (form["rbnCVDesign"].Contains("Illustrive")) { DataTable coverdesignprice = BLObj.GetPricingForCoverDesing("Illustrive"); String priceafterServiceTax = (Convert.ToDouble(coverdesignprice.Rows[0][0]) + (Convert.ToDouble(coverdesignprice.Rows[0][0]) * (Convert.ToDouble(ServiceTax.Rows[0][0]) / 100))).ToString(); cr.EstimatedAmt = Convert.ToInt32(priceafterServiceTax); } //else //{ cr.EstimatedAmt = 0; } cr.BindingType = form["rbnCVDgn"]; cr.SpineSize = form["txtSpineSize"]; cr.CoverDesignSynopsis = form["textArea"]; cr.RequestDate = DateTime.Now.ToShortDateString(); cr.Status = "1"; BLObj.InsertCoverDesignData(cr); if (cr.upfID != 0) { BL_Account bl = new BL_Account(); bl.UpdateCountAndisDone(cr.upfID); HttpContext.Session["upfID"] = ""; } dt = BLObj.GetUserMailID(UserId); htmlFilePath = Server.MapPath(Constants.CREmailHTMLTemplate); SendMail(User.Identity.Name, dt.Rows[0][0].ToString(), cr.EstimatedAmt, cr.OrderID, htmlFilePath); } else if (Command == "Save") { ////////////////Edit button Functionality code Admin var uploadedFile = Request.Files[0]; var fileName1 = Path.GetFileName(uploadedFile.FileName); cr.Status = form["ddlStatus"]; cr.Trn_ID = form["lblTrnID"]; string UserName = BLObj.GetUserName(cr); //MembershipUser MemberUser = Membership.GetUser(User.Identity.Name); //string UserId = MemberUser.ProviderUserKey.ToString(); string UserId = Convert.ToString(Common.GetUserId(HttpContext.User.Identity.Name)); if (fileName1 != String.Empty) { string strFileExtension = Path.GetExtension(uploadedFile.FileName); if (strFileExtension == ".jpg" || strFileExtension == ".jpeg" || strFileExtension == ".cdr" || strFileExtension == ".doc" || strFileExtension == ".docx" || strFileExtension == ".pdf") { fileName1 = UserName + "_" + Constants.strResponse + "_" + DateTime.Today.ToString("dd-MM-yyyy") + "_" + fileName1; if (!Directory.Exists(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + UserName + "//" + Constants.strResponse)) { Directory.CreateDirectory(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + UserName + "//" + Constants.strResponse); } var fileSavePath = Server.MapPath(Constants.strUploadFileIntialPath + "//" + UserName + "//" + Constants.strResponse + "//" + fileName1); uploadedFile.SaveAs(fileSavePath); cr.ResponseFilePath = fileName1; } else { TempData["StatusMessage"] = "Only.jpg/.jpeg/.cdr/.doc/.docx/.pdf file allowed!"; TempData["StatusMessageClass"] = "text-danger bg-danger"; return RedirectToAction("CoverDesign"); } } cr.ResponseDate = DateTime.Now.ToShortDateString(); BLObj.UpdateCoverDesignData(cr); TempData["StatusMessage"] = "Saved successfuly"; TempData["StatusMessageClass"] = "text-success bg-success"; dt.Clear(); dt = BLObj.getUserIDFromTrnID(form["lblTrnID"]); uid = Convert.ToString(dt.Rows[0]["UserId"]); OId = Convert.ToString(dt.Rows[0]["OrderID"]); dt.Clear(); dt = BLObj.GetUserMailID(uid); statusHtmlFilePath = Server.MapPath(Constants.StatusChangeHTMLTemplate); SendMailOnStatusChange(UserName, dt.Rows[0][0].ToString(), form["ddlStatus"], OId, statusHtmlFilePath); return RedirectToAction("CoverDesign"); } else if (Command == "SearchUser") { //TempData["searchUser"] = pr.txtFilterUserName; return RedirectToAction("CoverDesign", new { UserName = cr.txtFilterUserName }); } else if (Command == "Search") { return RedirectToAction("CoverDesign", new { StartDate = cr.StartDate, EndDate = cr.EndDate, UserName = cr.txtFilterUserName }); } return RedirectToAction("RequestSuccess"); }