public ActionResult FormattingNew()
        {
            var model = new Formatting();
            getDisplayData(ref model);

            return View(model);
        }
Esempio n. 2
0
        public string GetUserName(Formatting fr)
        {
            try
            {
                clsParameterCollection clsParaCollection = new clsParameterCollection();
                clsParaCollection.ProcedureName = Constants.sp_GetFRUserName;
                clsParaCollection.Add(new clsParameter("@TrnID", fr.Trn_ID));
                dt.Reset();
                dt = DataAccess.ExecuteSpAndGetDataTable(clsParaCollection);
                return dt.Rows[0][0].ToString();

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        public void InsertFormattingRequest(Formatting FormattingRef)
        {
            try
            {
                clsParameterCollection clsParaCollection = new clsParameterCollection();
                clsParaCollection.ProcedureName = Constants.sp_InsertFormattingRequest;
                clsParaCollection.Add(new clsParameter("@UserID",FormattingRef.UserID));
                clsParaCollection.Add(new clsParameter("@SizeID", FormattingRef.BookSize));
                clsParaCollection.Add(new clsParameter("@RequestFilePath", FormattingRef.RequestFileName));
                clsParaCollection.Add(new clsParameter("@FullPageIMGCount", FormattingRef.FullPageIMGCount));
                clsParaCollection.Add(new clsParameter("@HalfPageIMGCount", FormattingRef.HalfPageIMGCount));
                clsParaCollection.Add(new clsParameter("@QuaterPageIMGCount", FormattingRef.QuarterPageIMGCount));
                clsParaCollection.Add(new clsParameter("@Temp_ID",FormattingRef.TemplateID));
                clsParaCollection.Add(new clsParameter("@StatusID",FormattingRef.Status));
                clsParaCollection.Add(new clsParameter("@RequestDate",FormattingRef.RequestDate));
                clsParaCollection.Add(new clsParameter("@EstimatedAmt",FormattingRef.EstimatedAmt));
                DataAccess.ExecuteNonQuerySp(clsParaCollection);

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        public void UpdateFormattingData(Formatting fr)
        {
            try
            {
                clsParameterCollection clsParaCollection = new clsParameterCollection();

                clsParaCollection.Add(new clsParameter("@TrnID", fr.Trn_ID));
                clsParaCollection.Add(new clsParameter("@Status", fr.Status));
                clsParaCollection.Add(new clsParameter("@ResponseDate", fr.ResponseDate));

                if (fr.ReponseFileName != null)
                {
                    clsParaCollection.Add(new clsParameter("@ResponseFilePath", fr.ReponseFileName));
                    clsParaCollection.ProcedureName = Constants.sp_UpadateFormattingResponse;
                }
                else
                {
                    clsParaCollection.ProcedureName = Constants.sp_UpdateFormattingStatus;
                }

                DataAccess.ExecuteNonQuerySp(clsParaCollection);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult FormattingNew(Formatting pr, FormCollection form, string Command, string PageIndex)
        {
            if (Command == "Submit")
            {
                CtrlFormatting.ListSize = LoadBookSizeDropDown();
                CtrlFormatting.ListStatus = LoadStatusDropDown();

                MembershipUser MemberUser = Membership.GetUser(User.Identity.Name);
                string UserId = MemberUser.ProviderUserKey.ToString();

                var uploadedFile = Request.Files[0];
                string strFileExtension = Path.GetExtension(uploadedFile.FileName);

                if (strFileExtension == ".doc" || strFileExtension == ".docx" || strFileExtension == ".pdf")
                {
                    string FilePathToUpload = "";
                    FilePathToUpload = User.Identity.Name + "_" + Constants.strRequest + "_" + DateTime.Now.Date.ToShortDateString() + "_" + (Path.GetFileName(uploadedFile.FileName));

                    if (!Directory.Exists(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest))
                    {
                        Directory.CreateDirectory(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest);
                    }
                    uploadedFile.SaveAs(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest + "//" + FilePathToUpload);

                    CtrlFormatting.RequestFileName = FilePathToUpload;
                    CtrlFormatting.UserID = UserId;
                    CtrlFormatting.BookSize = form["ddlSize"];
                    CtrlFormatting.EstimatedAmt = "1000";
                    CtrlFormatting.RequestDate = DateTime.Now.ToShortDateString();
                    CtrlFormatting.Status = "1";

                    CtrlFormatting.FullPageIMGCount = Session["fullPImg"].ToString();
                    CtrlFormatting.HalfPageIMGCount = Session["halfPImg"].ToString();
                    CtrlFormatting.QuarterPageIMGCount = Session["quaterPImg"].ToString();
                    CtrlFormatting.TemplateID = Session["tempID"].ToString();

                    BussinessLayerObject.InsertFormattingRequest(CtrlFormatting);
                    ViewBag.StatusMessage = "Request submited successfuly";
                    ViewBag.StatusMessageClass = "text-success bg-success";

                    SendMail("mail", int.Parse(CtrlFormatting.FullPageIMGCount),int.Parse(CtrlFormatting.HalfPageIMGCount),int.Parse(CtrlFormatting.QuarterPageIMGCount), int.Parse(CtrlFormatting.EstimatedAmt));
                }
                else
                {
                    ViewBag.StatusMessage = "Only document and PDF file allowed!";
                    ViewBag.StatusMessageClass = "text-danger bg-danger";
                }
                getDisplayData(ref CtrlFormatting);
                return View(CtrlFormatting);

            }
            else
            {
                ////////////////Edit button Functionality code Admin
                var uploadedFile = Request.Files[1];
                var fileName1 = Path.GetFileName(uploadedFile.FileName);

                CtrlFormatting.Status = form["ddlStatus"];
                CtrlFormatting.Trn_ID = form["lblTrnID"];
                string UserName = BussinessLayerObject.GetUserName(CtrlFormatting);
                MembershipUser MemberUser = Membership.GetUser(User.Identity.Name);
                string UserId = MemberUser.ProviderUserKey.ToString();
                if (fileName1 != String.Empty)
                {
                    fileName1 = UserName + "_" + Constants.strResponse + "_" + DateTime.Now.Date.ToShortDateString() + "_" + 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);
                    CtrlFormatting.ReponseFileName = fileName1;
                }
                CtrlFormatting.ResponseDate = DateTime.Now.ToShortDateString();
                BussinessLayerObject.UpdateFormattingData(CtrlFormatting);
                ViewBag.StatusMessage = "Saved successfuly";
                ViewBag.StatusMessageClass = "text-success bg-success";
            }

            getDisplayData(ref CtrlFormatting);
            return View(CtrlFormatting);
        }
 //[Authorize(Roles = "Admin,Customer")]
 //public ActionResult formatting()
 //{
 //    load_ddlBookSize();
 //    load_ddlStatus();
 //    var model = new Formatting();
 //    DataTable.Reset();
 //    DataTable = retrieve_Data();
 //    foreach (DataRow dr in DataTable.Rows)
 //    {
 //        model.Data_List.Add(new Formatting { pTrn_ID = dr[0].ToString(), UserID = dr[1].ToString(),book_Size = dr[2].ToString(),no_fullP_images=dr[3].ToString(),no_halfP_images=dr[4].ToString(),no_quaterP_images=dr[5].ToString(),template_ID=dr[6].ToString(), estimated_Amt = dr[7].ToString(), request_FileName = dr[8].ToString(), reponse_FileName = dr[9].ToString(), request_Date = dr[10].ToString(), response_Date = dr[11].ToString(), status = dr[12].ToString() });
 //    }
 //    DataTable.Reset();
 //    DataTable = BussinessLayerObject.get_Templates();
 //    //foreach (DataRow dr in dt.Rows)
 //    //{
 //    //    model.temp_urls.Add(dr["temp_Name"].ToString());
 //    //}
 //    foreach (DataRow dr in DataTable.Rows)
 //    {
 //        model.temp_urls.Add(dr);
 //    }
 //    model.templates_Count = model.temp_urls.Count.ToString();
 //    return View(model);
 //}
 //[HttpPost]
 //[AcceptVerbs(HttpVerbs.Post)]
 //public ActionResult Formatting(Formatting fr,FormCollection form,string Command)
 //{
 //    if (Command == "Submit")
 //    {
 //        load_ddlBookSize();
 //        load_ddlStatus();
 //        var model = new Formatting();
 //        var fileSavePath = "";
 //        var uploadedFile = Request.Files[0];
 //        fileName1 = Path.GetFileName(uploadedFile.FileName);
 //        fileName1 = User.Identity.Name + "_" + fr.strRequest + "_" + DateTime.Now.Date.ToShortDateString() + "_" + fileName1;
 //        if (!Directory.Exists(Server.MapPath(fr.FilePath1) + fr.FilePath2))
 //        {
 //            Directory.CreateDirectory(Server.MapPath(fr.FilePath1) + fr.FilePath2);
 //        }
 //        if (!Directory.Exists(Server.MapPath(fr.FilePath3) + "//" + User.Identity.Name))
 //        {
 //            Directory.CreateDirectory(Server.MapPath(fr.FilePath3) + "//" + User.Identity.Name);
 //        }
 //        if (!Directory.Exists(Server.MapPath(fr.FilePath3) + "//" + User.Identity.Name + "//" + fr.strRequest))
 //        {
 //            Directory.CreateDirectory(Server.MapPath(fr.FilePath3) + "//" + User.Identity.Name + "//" + fr.strRequest);
 //        }
 //        fileSavePath = Server.MapPath(fr.FilePath3 + "//" + User.Identity.Name + "//" + fr.strRequest + "//" + fileName1);
 //        uploadedFile.SaveAs(fileSavePath);
 //        fr.request_FileName = fileName1;
 //        fr.UserID = User.Identity.Name;
 //        fr.book_Size = form["ddlBSizes"];
 //        fr.no_fullP_images = Session["fullPImg"].ToString();
 //        fr.no_halfP_images = Session["halfPImg"].ToString();
 //        fr.no_quaterP_images = Session["quaterPImg"].ToString();
 //        fr.template_ID = Session["tempID"].ToString();
 //        ////getWordCount(fileSavePath);
 //        //int nw = 100;
 //        //pr.no_of_words = nw.ToString();
 //        //fr.estimated_amt = bl.cal_Estimate_Amt(nw);
 //        fr.request_Date = DateTime.Now.ToShortDateString();
 //        fr.status = "1";
 //        fr.estimated_Amt = "100";
 //        BussinessLayerObject.insert_FormattingData(fr);
 //        int result = 1;
 //        if (result > 0)
 //        {
 //            ViewData["result"] = result;
 //        }
 //        else
 //        {
 //            ViewData["Error"] = 1;
 //        }
 //        DataTable.Reset();
 //        DataTable = retrieve_Data();
 //        foreach (DataRow dr in DataTable.Rows)
 //        {
 //            model.Data_List.Add(new Formatting { pTrn_ID = dr[0].ToString(), UserID = dr[1].ToString(), book_Size = dr[2].ToString(), no_fullP_images = dr[3].ToString(), no_halfP_images = dr[4].ToString(), no_quaterP_images = dr[5].ToString(), template_ID = dr[6].ToString(), estimated_Amt = dr[7].ToString(), request_FileName = dr[8].ToString(), reponse_FileName = dr[9].ToString(), request_Date = dr[10].ToString(), response_Date = dr[11].ToString(), status = dr[12].ToString() });
 //        }
 //        Session["fullPImg"]=null;
 //            Session["halfPImg"]=null;
 //            Session["quaterPImg"] = null;
 //            Session["tempID"] = null;
 //        return View(model);
 //    }
 //    else
 //    {
 //        var uploadedFile = Request.Files[0];
 //        var fileName1 = Path.GetFileName(uploadedFile.FileName);
 //        fr.status = form["ddlStatus"];
 //        fr.pTrn_ID = form["lblTrnID"];
 //        string uName = BussinessLayerObject.get_UserName(fr);
 //        if (fileName1 != String.Empty)
 //        {
 //            fileName1 = uName + "_" + fr.strResponse + "_" + DateTime.Now.Date.ToShortDateString() + "_" + fileName1;
 //            if (!Directory.Exists(Server.MapPath(fr.FilePath3) + "//" + uName + "//" + fr.strResponse))
 //            {
 //                Directory.CreateDirectory(Server.MapPath(fr.FilePath3) + "//" + uName + "//" + fr.strResponse);
 //            }
 //            var fileSavePath = Server.MapPath(fr.FilePath3 + "//" + uName + "//" + fr.strResponse + "//" + fileName1);
 //            uploadedFile.SaveAs(fileSavePath);
 //            fr.reponse_FileName = fileName1;
 //        }
 //        fr.response_Date = DateTime.Now.ToShortDateString();
 //        BussinessLayerObject.update_FormattingData(fr);
 //        int i = 1;
 //        if (i > 0)
 //        {
 //            ViewData["Saved"] = 1;
 //        }
 //        else
 //            ViewData["Saved"] = null;
 //        load_ddlStatus();
 //        var model = new Formatting();
 //        DataTable = retrieve_Data();
 //        foreach (DataRow dr in DataTable.Rows)
 //        {
 //            model.Data_List.Add(new Formatting { pTrn_ID = dr[0].ToString(), UserID = dr[1].ToString(), book_Size = dr[2].ToString(), no_fullP_images = dr[3].ToString(), no_halfP_images = dr[4].ToString(), no_quaterP_images = dr[5].ToString(), template_ID = dr[6].ToString(), estimated_Amt = dr[7].ToString(), request_FileName = dr[8].ToString(), reponse_FileName = dr[9].ToString(), request_Date = dr[10].ToString(), response_Date = dr[11].ToString(), status = dr[12].ToString() });
 //        }
 //        return View(model);
 //    }
 //}
 private DataTable retrieve_Data()
 {
     var model = new Formatting();
     if (User.IsInRole("Admin"))
     {
     //    DataTable = BussinessLayerObject.get_FormattingData_Admin();
     }
     else
     {
         model.UserID = User.Identity.Name;
        // DataTable = BussinessLayerObject.get_FormattingData_User(model);
     }
     return DataTable;
 }
        /// <summary>
        /// This method is used to load model to display grid data.
        /// </summary>
        /// <param name="model"></param>
        private void getDisplayData(ref Formatting model)
        {
            model.ListSize = LoadBookSizeDropDown();
            model.ListStatus = LoadStatusDropDown();

            MembershipUser MemberUser = Membership.GetUser(User.Identity.Name);
            string UserId = MemberUser.ProviderUserKey.ToString();

            DataTable dtData = new DataTable();
            dtData = BussinessLayerObject.GetFormattingUserData(UserId);

            List<Formatting> listData = new List<Formatting>();
            foreach (DataRow dr in dtData.Rows)
            {
                listData.Add(new Formatting
                {
                    Trn_ID = dr["Trn_ID"].ToString(),
                    UserName = dr["UserName"].ToString(),
                    BookSize = dr["size_Name"].ToString(),
                    FullPageIMGCount = dr["FullPageIMGCount"].ToString(),
                    HalfPageIMGCount = dr["HalfPageIMGCount"].ToString(),
                    QuarterPageIMGCount = dr["QuaterPageIMGCount"].ToString(),
                    TemplateID= dr["temp_Name"].ToString(),
                    RequestFileName = dr["RequestFilePath"].ToString(),
                    ReponseFileName = dr["ResponseFilePath"].ToString(),
                    Status = dr["status_Name"].ToString(),
                    EstimatedAmt = dr["EstimatedAmt"].ToString(),
                    isPaymentRelesed = dr["IsPaymentReleased"].ToString(),
                    RequestDate = dr["RequestDate"].ToString(),
                    ResponseDate = dr["ResponseDate"].ToString()
                });
            }
            model.ModelList = listData;
            DataTable = BussinessLayerObject.GetTemplates();
            foreach (DataRow dr in DataTable.Rows)
            {
                model.Temp_Urls.Add(dr);

            }
            model.TemplatesCount = model.Temp_Urls.Count.ToString();
        }
        /// <summary>
        /// This method is used to load model to display grid data.
        /// </summary>
        /// <param name="model"></param>
        private void getDisplayData(ref Formatting model)
        {
            model.ListSize = LoadBookSizeDropDown();
            model.ListStatus = LoadStatusDropDown();

            string UserId = Convert.ToString(Common.GetUserId(HttpContext.User.Identity.Name));

            //MembershipUser MemberUser = Membership.GetUser(User.Identity.Name);
            //string UserId = MemberUser.ProviderUserKey.ToString();

            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.GetFilteredFormattingDataByBoth(model.UserName, model.StartIndex, model.EndIndex, model.sort, model.sortdir, model.StartDate, model.EndDate);
            }
            else if (!string.IsNullOrEmpty(model.StartDate))
            {
                dtData = BLObj.GetFilteredFormattingDataByDates(UserId, model.StartIndex, model.EndIndex, model.sort, model.sortdir, model.StartDate, model.EndDate);
            }
            else if (!string.IsNullOrEmpty(model.UserName))
            {
                dtData = BLObj.GetFilteredFormattingData(model.UserName, model.StartIndex, model.EndIndex, model.sort, model.sortdir);
            }
            else
            {
                dtData = BLObj.GetFormattingUserData(UserId, model.StartIndex, model.EndIndex, model.sort, model.sortdir);
            }

            List<Formatting> listData = new List<Formatting>();
            foreach (DataRow dr in dtData.Rows)
            {
                listData.Add(new Formatting
                {
                    SrNo = Convert.ToInt32(dr["row"]),
                    Trn_ID = dr["Trn_ID"].ToString(),
                    OrderID = dr["OrderID"].ToString(),
                    UserName = dr["UserName"].ToString(),
                    BookSize = dr["size_Name"].ToString(),
                    FullPageIMGCount = dr["FullPageIMGCount"].ToString(),
                    HalfPageIMGCount = dr["HalfPageIMGCount"].ToString(),
                    QuarterPageIMGCount = dr["QuaterPageIMGCount"].ToString(),
                    TemplateID = dr["temp_Name"].ToString(),
                    RequestFileName = dr["RequestFilePath"].ToString(),
                    ReponseFileName = dr["ResponseFilePath"].ToString(),
                    Status = dr["status_Name"].ToString(),
                    EstimatedAmt = dr["EstimatedAmt"].ToString(),
                    isPaymentRelesed = dr["IsPaymentReleased"].ToString(),
                    RequestDate = dr["RequestDate"].ToString(),
                    ResponseDate = dr["ResponseDate"].ToString()
                });
            }
            model.ModelList = listData;
            DataTable = BLObj.GetTemplates();
            foreach (DataRow dr in DataTable.Rows)
            {
                model.Temp_Urls.Add(dr);

            }
            model.TemplatesCount = model.Temp_Urls.Count.ToString();
        }
        public ActionResult FormattingNew(Formatting pr, FormCollection form, string Command, string PageIndex)
        {
            if (Command == "Submit")
            {
                if (HttpContext.Session["upfID"] != null)
                {
                    CtrlFormatting.upfID = Convert.ToInt32(HttpContext.Session["upfID"]);

                }
                else
                {
                    CtrlFormatting.upfID = 0;

                }
                CtrlFormatting.ListSize = LoadBookSizeDropDown();
                CtrlFormatting.ListStatus = LoadStatusDropDown();

                //MembershipUser MemberUser = Membership.GetUser(User.Identity.Name);
                //string UserId = MemberUser.ProviderUserKey.ToString();
                string UserId = Convert.ToString(Common.GetUserId(HttpContext.User.Identity.Name));

                var uploadedFile = Request.Files[0];
                string strFileExtension = Path.GetExtension(uploadedFile.FileName);

                if (strFileExtension == ".docx" || strFileExtension == ".doc") //|| strFileExtension == ".pdf")
                {
                    if (uploadedFile.ContentLength > 0)
                    {
                        string FilePathToUpload = "";
                        FilePathToUpload = User.Identity.Name + "_" + Constants.strRequest + "_" + DateTime.Today.ToString("dd-MM-yyyy") + "_" + (Path.GetFileName(uploadedFile.FileName));

                        if (!Directory.Exists(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest))
                        {
                            Directory.CreateDirectory(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest);
                        }
                        uploadedFile.SaveAs(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest + "//" + FilePathToUpload);
                        if (strFileExtension == ".docx")
                        {
                            NumberOfPages = CountPagesFromDocx(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest + "//" + FilePathToUpload);
                        }
                        else
                        {
                            NumberOfPages = CountPagesFromPdf(Server.MapPath(Constants.strUploadFileIntialPath) + "//" + User.Identity.Name + "//" + Constants.strRequest + "//" + FilePathToUpload);
                        }
                        CtrlFormatting.RequestFileName = FilePathToUpload;
                        CtrlFormatting.UserID = UserId;
                        CtrlFormatting.BookSize = form["ddlSize"];

                        DataTable GetPriceforFormatting = BLObj.GetPriceForFormatting();
                        DataTable GetServiceTax = BLObj.GetServiceTax();

                        string getprice = Convert.ToString(Convert.ToInt32(NumberOfPages) * Convert.ToInt32(GetPriceforFormatting.Rows[0]["FormattingPricing"]));

                        CtrlFormatting.EstimatedAmt = (Convert.ToDouble(getprice) + (Convert.ToDouble(GetServiceTax.Rows[0][0]) / 100)).ToString();

                        CtrlFormatting.RequestDate = DateTime.Now.ToShortDateString();
                        CtrlFormatting.Status = "1";

                        CtrlFormatting.FullPageIMGCount = Session["fullPImg"].ToString();
                        CtrlFormatting.HalfPageIMGCount = Session["halfPImg"].ToString();
                        CtrlFormatting.QuarterPageIMGCount = Session["quaterPImg"].ToString();
                        CtrlFormatting.TemplateID = Session["tempID"].ToString();
                        CtrlFormatting.OrderID = VishwaPress.BusinessLayer.Utilities.Common.GetUniqueKey(User.Identity.Name, CtrlFormatting.serviceChar);

                        BLObj.InsertFormattingRequest(CtrlFormatting);
                        Session["fullPImg"] = null;
                        Session["halfPImg"] = null;
                        Session["quaterPImg"] = null;
                        Session["tempID"] = null;
                        if (CtrlFormatting.upfID != 0)
                        {
                            BL_Account bl = new BL_Account();
                            bl.UpdateCountAndisDone(CtrlFormatting.upfID);
                            HttpContext.Session["upfID"] = "";
                        }
                        //ViewBag.StatusMessage = "Request submited successfuly";
                        //ViewBag.StatusMessageClass = "text-success bg-success";
                        DataTable = BLObj.GetUserMailID(UserId);
                        htmlFilePath = Server.MapPath(Constants.FREmailHTMLTemplate);
                        SendMail(User.Identity.Name, DataTable.Rows[0][0].ToString(), int.Parse(CtrlFormatting.FullPageIMGCount), int.Parse(CtrlFormatting.HalfPageIMGCount), int.Parse(CtrlFormatting.QuarterPageIMGCount), CtrlFormatting.EstimatedAmt, CtrlFormatting.OrderID, htmlFilePath);
                    }
                    else
                    {
                        TempData["StatusMessage"] = "File is empty, please select another file";
                        TempData["StatusMessageClass"] = "text-danger bg-danger";
                        return RedirectToAction("FormattingNew");
                    }
                }
                else
                {
                    //ViewBag.StatusMessage = "Only document and PDF file allowed!";
                    //ViewBag.StatusMessageClass = "text-danger bg-danger";
                    TempData["StatusMessage"] = "Only document allowed!";
                    TempData["StatusMessageClass"] = "text-danger bg-danger";
                    return RedirectToAction("FormattingNew");
                }
                //getDisplayData(ref CtrlFormatting);
                //return View(CtrlFormatting);

            }
            else if (Command == "Save")
            {
                ////////////////Edit button Functionality code Admin
                var uploadedFile = Request.Files[0];
                var fileName1 = Path.GetFileName(uploadedFile.FileName);

                CtrlFormatting.Status = form["ddlStatus"];
                CtrlFormatting.Trn_ID = form["lblTrnID"];
                string UserName = BLObj.GetUserName(CtrlFormatting);
                string UserId = Convert.ToString(Common.GetUserId(HttpContext.User.Identity.Name));
                //MembershipUser MemberUser = Membership.GetUser(User.Identity.Name);
                //string UserId = MemberUser.ProviderUserKey.ToString();
                if (fileName1 != String.Empty)
                {
                    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);
                    CtrlFormatting.ReponseFileName = fileName1;
                }
                CtrlFormatting.ResponseDate = DateTime.Now.ToShortDateString();
                BLObj.UpdateFormattingData(CtrlFormatting);
                //ViewBag.StatusMessage = "Saved successfuly";
                //ViewBag.StatusMessageClass = "text-success bg-success";
                TempData["StatusMessage"] = "Saved successfuly";
                TempData["StatusMessageClass"] = "text-success bg-success";
                DataTable.Clear();
                DataTable = BLObj.getUserIDFromTrnID(form["lblTrnID"]);
                string uid = DataTable.Rows[0]["UserId"].ToString();
                string OId = DataTable.Rows[0]["OrderID"].ToString();
                DataTable.Clear();
                DataTable = BLObj.GetUserMailID(uid);
                statusHtmlFilePath = Server.MapPath(Constants.StatusChangeHTMLTemplate);
                SendMailOnStatusChange(UserName, DataTable.Rows[0][0].ToString(), form["ddlStatus"], OId, statusHtmlFilePath);
                return RedirectToAction("FormattingNew");
            }
            else if (Command == "SearchUser")
            {
                //TempData["searchUser"] = pr.txtFilterUserName;
                return RedirectToAction("FormattingNew", new { UserName = pr.txtFilterUserName });
            }
            else if (Command == "Search")
            {
                return RedirectToAction("FormattingNew", new { StartDate = pr.StartDate, EndDate = pr.EndDate, UserName = pr.txtFilterUserName });
            }
            //getDisplayData(ref CtrlFormatting);
            //return View(CtrlFormatting);
            return RedirectToAction("RequestSuccess");
        }
Esempio n. 10
0
        //[Authorize(Roles = "Admin,Customer,Formatting")]
        public ActionResult FormattingNew(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 Formatting();

            //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
                {
                    //if (!string.IsNullOrEmpty(Convert.ToString(TempData["sort"])))
                    //{
                    //    model.sort = TempData["sort"].ToString();
                    //    model.sortdir = TempData["sortdir"].ToString();
                    //    TempData["sort"] = model.sort;
                    //    TempData["sortdir"] = model.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("_WebgridFormating", model); }
            }
            if (!string.IsNullOrEmpty(sort) && page != null)
            {
                return PartialView("_WebgridFormating", model);
            }
            return View(model);
        }