Notes
Notes - notes.io |
//convert this code into mvc C# motive of this code is after insert my personal detail, education detail ,work exp and all on submit otp button now after otpsubmit i redirect to docupload where is i want to upload dynamic uploads according to my procedure
@using (Html.BeginForm("DocUpload", "Details", FormMethod.Post, new { id = "submitForm", enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
<body>
@*<form id="X" name="X" action="ViewAppFormDtls.aspx" method="post" style="display: inline;">
<input type="hidden" name="app_no" id="app_no" />
<input type="hidden" name="dob" id="dob" />
<input type="hidden" name="exam_code" id="exam_code" />
</form>*@
<form id="form1" class="Ignore" style="margin-top: 0px;" method="POST" autocomplete="off">
<table class="table table-bordered table-hover table-striped">
<tr align="center">
<td>
<div id="PrintContent" style="font-family: 'Arapey', serif;">
<table class="table table-bordered table-hover table-striped">
<tr>
<th colspan="4">
<div style="align-content:center; display:flex; justify-content:center; font-size:20px; font-family: 'Arapey', serif;">
<label style="color:red; font-weight:bold; font-size: 19px; align-content:center; display:flex; justify-content:center; font-family: 'Arapey', serif;" id="LblExamName" cssclass="form-heading">
<u style=" text-decoration: underline solid black 2px;"> @ViewBag.LblExamName </u>
</label>
</div>
</th>
</tr>
<tr>
<td colspan="2">
<div style="align-content:center; display:flex; font-family: 'Arapey', serif; width:50%;">
<label style="font-size:large; font-weight:bold; font-family: 'Arapey', serif;" cssclass="form-heading">
Application Number :
</label>
<label style="color:red; font-size:large; font-weight:bold;"> <strong> @Session["application1"] </strong> </label>
</div>
</td>
<td colspan="2">
<div style="align-content:center; display:flex; font-family: 'Arapey', serif;">
<label style="font-size:large; font-weight:bold; font-family: 'Arapey', serif;" cssclass="form-heading">
Applicant's Name :
</label>
<label style="color:red; font-size:large; font-weight:bold;"> <strong> @Session["Name"] </strong> </label>
</div>
</td>
</tr>
<tr align="center">
<td colspan="4" style="height: 21px">
<hiddenfield id="HiddenField1" />
<hiddenfield id="HiddenField2" />
<hiddenfield id="HiddenField3" />
<hiddenfield id="hdid" />
</td>
</tr>
<tr>
<td colspan="4">
<uc1:dynamicfileupload id="DynamicFileUpload" />
</td>
</tr>
<tr>
<td colspan="4">
<div class="" style="display:flex; justify-content:center; align-items:center;" id="otpdiv">
<div class=" form-horizontal">
<label id="lblnote" style="color:red; font-size:small; font-weight:bold;"> <strong> @ViewBag.lblnote </strong> </label>
<div style="display:flex; justify-content:flex-start;" class="form-inline">
<label style="font-weight:normal; font-size:small">
@Html.CheckBoxFor(x => x.Declaration, new { id = "chkDeclaration", @checked = "checked", @disabled = "disabled" })
I, hereby declare that the above details are true, correct and complete in all respects to the best of my knowledge and belief and nothing has been concealed and in the event of any information being found false/fabricated or any deficiency in the eligibility of the post being detected at a later stage, my candidature is liable to be summarily cancelled/rejected.
</label>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td colspan="4">
<div style="display:flex; justify-content:center; align-items:center;">
<div style="align-items:center;" class=" form-horizontal">
<label id="lblMsg" forecolor="Red" font-bold="True"></label>
@*<button id="btnNext" text="Submit" class="btn btn-info" />*@
<input type="submit" id="btnNext" name="Submit" value="Submit" class="btn btn-info" />
</div>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</form>
@*<label id="lblScript" />
<script type="text/javascript" language="javascript" src="/Portal/headers/creditsfootermp.js"></script>*@
</body>
}
public ActionResult DocUpload(string HiddenField1, string HiddenField3, string HiddenField2, string hdid, Personal_Detail model)
{
ViewBag.lblExamName = CommonFunction.SelectTable("6", examcode, "").Rows[0]["Exam_name"].ToString();
Session["Name"] = model.Applicant_Name;
Session["application1"] = model.App_no;
model.App_no = @ViewBag.lblappno;
ViewBag.lblnote = "Read form carefully before submission.";
try
{
string[] DeptName = null;
string ExamCode = string.Empty;
string FolderHead = string.Empty;
//lblMsg.Visible = false;
//// For preventing user to paste direct link of receipt
if (Request.ServerVariables["HTTP_REFERER"] == null && Request.ServerVariables["HTTP_CACHE_CONTROL"] == null)
{
Response.Redirect("~/index.aspx");
}
ViewBag.lblnote = "Read form carefully before submission.";
if (Request.QueryString["app_no"] != null && Request.QueryString["exam_code"] != null)
{
// HiddenField1 = Server.UrlDecode(PortalEncryption.DecryptPassword(Request.QueryString["app_no"].ToString()));
HiddenField1 = System.Web.HttpUtility.UrlDecode("app_no");
//HiddenField3 = Server.UrlDecode(PortalEncryption.DecryptPassword(Request.QueryString["exam_code"].ToString()));
//HiddenField2 = Server.UrlDecode(PortalEncryption.DecryptPassword(Request.QueryString["dob"].ToString()));
if (HiddenField3.Contains("_"))
{
DeptName = HiddenField3.Split('_');
ExamCode = HiddenField3.Split('_')[1];
FolderHead = DeptName[0] + "/" + ExamCode;
}
else
{
ExamCode = HiddenField3;
FolderHead = ExamCode;
}
ViewBag.lblappno = HiddenField1;
SqlParameter[] sqlprom = new SqlParameter[3];
sqlprom[0] = new SqlParameter("@Case", "FileUploadCheck");
sqlprom[1] = new SqlParameter("@Option1", CommonFunction.SQLInjection(ExamCode));
sqlprom[2] = new SqlParameter("@Option2", CommonFunction.SQLInjection(HiddenField1));
string cs = ConfigurationManager.ConnectionStrings["dbcs"].ConnectionString;
using (DataTable dt = CommonFunction.ExecuteSelectProc(sqlprom, "SelOptions", cs))
{
if (dt.Rows.Count > 0)
{
if (Convert.ToString(dt.Rows[0]["Active"]) == "Y")
{
//lblName.Text = Convert.ToString(dt.Rows[0]["Name"]);
//hdid = Convert.ToString(dt.Rows[0]["GUID"]);
////DynamicFileUpload.RenderFileControls(HiddenField3.Value, "FileUpload", DeptName[0]+"/"+HiddenField3.Value, HiddenField1.Value + "_" + hdid.Value, "FileUpload");
//DynamicFileUpload.RenderFileControls(ExamCode, "FileUpload", FolderHead, HiddenField1 + "_" + hdid, "FileUpload");
//ViewBag.lblExamName = CommonFunction.SelectTable("6", ExamCode, "").Rows[0]["Exam_name"].ToString();
/////code if document already uploaded and status changed
//if (Convert.ToString(dt.Rows[0]["IsDocUpload"]) == "Y")
//{
// app_no = Server.HtmlEncode(PortalEncryption.EncryptPassword(HiddenField1));
// dob = Server.HtmlEncode(PortalEncryption.EncryptPassword(HiddenField2));
// exam_code = Server.HtmlEncode(PortalEncryption.EncryptPassword(ExamCode));
// ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "Redirect();", true);
// throw new Exception("Data inserted Successfully & your Application No is '" + CommonFumction.SQLInjection(Server.UrlDecode(PortalEncryption.DecryptPassword(app_no))) + "'");
//}
}
else
{
Response.Redirect("frmHome.aspx");
}
}
else
{
throw new Exception("Document selection not found please fill another application");
}
HiddenField1 = Request.QueryString["app_no"].ToString();
//HiddenField3.Value = ExamCodeRequest.QueryString["exam_code"].ToString();
HiddenField3 = Request.QueryString["exam_code"].ToString();
HiddenField2 = Request.QueryString["dob"].ToString();
}
}
else
{
throw new Exception("invalid parameters");
}
}
catch (Exception ex)
{
ViewBag.Error = ex.Message;
return View(model);
//btnNext.Visible = false;
//MessageBox.Show(ex.Message.ToString());
// Response.Redirect("frmHome.aspx");
}
return View();
}
<script type="text/javascript">
function Validate() {
var _validFileExtensions = ["jpg", "jpeg", "pdf"];
var Form = document.form1;
var arrInputs = Form.getElementsByTagName("input");
for (var i = 0; i < arrInputs.length; i++) {
var oInput = arrInputs[i];
if (oInput.type == "file") {
var sFileName = oInput.value;
if (sFileName != "") {
if ($.inArray(sFileName.split('.').pop().toLowerCase(), _validFileExtensions) == -1) {
alert("Invalid Document Format Please Upload only .jpg or .pdf Document");
this.value = ''; // Clean field
return false;
}
}
}
}
return true;
}
</script>
<div class="box-body box-body-open">
<div id="divPhotoUpload" style="width:100%">
<div class="list-group">
<asp:HiddenField runat="server" ID="hdExamCode" />
<asp:HiddenField runat="server" ID="hdName" />
<asp:HiddenField runat="server" ID="hdFolderHeadName" />
<asp:HiddenField runat="server" ID="hdApplicationNo" />
<asp:HiddenField runat="server" ID="hdAppfor" />
<asp:GridView runat="server" ID="grdUploadSection" OnRowCommand="grdUploadSection_RowCommand" AutoGenerateColumns="false" CssClass="w3-table-all">
<Columns>
<asp:TemplateField HeaderText="Mandatory">
<ItemTemplate>
<asp:CheckBox ID="chkUpload" runat="server" Checked='<%# Convert.ToBoolean(Eval("IsMendatory")) %>' Enabled="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="File Name">
<ItemTemplate>
<asp:Label ID="lblUpload" runat="server" Text='<%# Eval("Option_Name") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="File">
<ItemTemplate>
<asp:FileUpload ID="FuUpload" runat="server" />
<asp:HiddenField ID="hdUpload" runat="server" Value='<%# Eval("Option_Code") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<asp:LinkButton ID="lnkUpload" runat="server" CommandArgument='<%# Eval("Option_Code") %>' Text="Upload" CommandName="Upload" CssClass="w3-button" OnClientClick="return Validate()"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Download">
<ItemTemplate>
<asp:Literal ID="lnkDownload" runat="server" Text='<%# Eval("Download") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
<div class="clearfix">
</div>
</div>
public void RenderFileControls(string ExamCode, string Name, string FolderHead, string ApplicationNo, string Appfor)
{
try
{
SqlParameter[] sqlprom = new SqlParameter[4];
sqlprom[0] = new SqlParameter("@Case", Functions.SQLInjection(Appfor));
sqlprom[1] = new SqlParameter("@Option1", Functions.SQLInjection(ExamCode));
sqlprom[2] = new SqlParameter("@Option2", Functions.SQLInjection(Name));
//for storing application no seperatly
string[] app = ApplicationNo.Split('_');
sqlprom[3] = new SqlParameter("@Option3", Functions.SQLInjection(app[0].ToString()));
using (DataTable dt = SelectTable(sqlprom, "SelOptions"))
{
hdExamCode.Value = ExamCode;
hdName.Value = Name;
hdFolderHeadName.Value = FolderHead;
hdApplicationNo.Value = ApplicationNo;
hdAppfor.Value = Appfor;
if (dt.Rows.Count > 0)
{
foreach (DataRow row in dt.Rows)
{
string[] ext = Convert.ToString(row["ExtType"].ToString().Trim().ToLower()).Split(',');
for (int i = 0; i < ext.Length; i++)
{
if (File.Exists(ActionCommonUtility.MapQuickLinksFolder("/Quick Links/CollectorateRecruitment/" + FolderHead + "/" + row["Option_Code"] + "/" + ApplicationNo + Convert.ToString(ext[i].ToString().Trim().ToLower()))))
{
string Accesspath = Server.UrlEncode(PortalEncryption.EncryptPassword("/Quick Links/CollectorateRecruitment/" + FolderHead + "/" + row["Option_Code"] + "/" + ApplicationNo + Convert.ToString(ext[i].ToString().Trim().ToLower())));
string Accesstime = Server.UrlEncode(PortalEncryption.EncryptPassword(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff")));
row["Download"] = "<a href='/Portal/Services/CollectorateRecruitment/Control/ShowContent.aspx?P1=" + Accesspath + "&P2=" + Accesstime + "&P3=" + Server.UrlEncode(PortalEncryption.EncryptPassword(Convert.ToString(ext[i].ToString().Trim().ToUpper()))) + "' target='_blank' class='btn-default' >Download <i class='material-icons'>attachment</i></a>";
// row["Download"] = "<a href='/Quick Links/collRecruitment/" + FolderHead + "/" + row["Option_Code"] + "/" + ApplicationNo + Convert.ToString(ext[i].ToString().Trim().ToLower()) + "' target='_blank' class='btn-default' >Download <i class='material-icons'>attachment</i></a>";
}
}
}
grdUploadSection.DataSource = dt;
grdUploadSection.EmptyDataText = "No Upload Available";
grdUploadSection.DataBind();
}
else
{
grdUploadSection.DataSource = dt;
grdUploadSection.EmptyDataText = "No Upload Available";
grdUploadSection.DataBind();
}
}
}
catch (Exception ex)
{
throw ex;
}
}
USE [CollectorateRecruitment]
GO
/****** Object: StoredProcedure [dbo].[SelOptions] Script Date: 30-05-2024 11:40:06 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Shivam Tiwari>--Common logic for document upload
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
-- exec [dbo].[SelOptions] 'FileUpload','MC002','MH00119000000','0','asd','','','','','','','',''
ALTER PROCEDURE [dbo].[SelOptions]
@Case varchar(200), -- Case According to Condition
@Option1 nvarchar(500),
@Option2 nvarchar(500)=null,
@Option3 nvarchar(500)=null,
@Option4 nvarchar(500)=null,
@Option5 nvarchar(500)=null,
@Option6 nvarchar(500)=null,
@Option7 nvarchar(500)=null,
@Option8 nvarchar(500)=null,
@Option9 nvarchar(500)=null,
@Option10 nvarchar(500)=null,
@Option11 nvarchar(500)=null,
@Option12 nvarchar(500)=null
AS
BEGIN
declare @tableName varchar(100)
declare @varExec varchar(max)
declare @domicile varchar(10)
declare @iscast varchar(10)
declare @post varchar(10)
declare @Compcert varchar(10)
declare @Handi varchar(10)
declare @IsDegree varchar(10)
declare @IsPreExp varchar(10)
declare @IsGovtCorpExp varchar(10)
declare @mastdeg varchar(20)
declare @DIP varchar(20)
declare @IsEXP char(1)
declare @Degree12th varchar(10)
declare @Degree varchar(10)
declare @10th varchar(10)
declare @8th varchar(10)
if(@Case='FileUpload')
begin
--Add flag by child service i means ExamCode and document selection with same aliasing according to conditional documents
--Do not change mandatory conversion from "bit" to any other it is required
IF(@OPTION1='KH004')
BEGIN
DECLARE @IsExServiceMan varchar(10)
Select @DIP=isnull(Qual_degree,'N') from KH004_Edu_dtls where APP_NO=@OPTION3 and Sno='5'
SELECT @IsExServiceMan=ISNULL(exserviceman,'N'), @DOMICILE=ISNULL(DOMICILE,'N'),@ISCAST=ISNULL(CATEGORY,'N'),@POST=POSITION,@HANDI=ISHANDICAP,@ISPREEXP=ISPREEXP,@ISGOVTCORPEXP=ISGOVTCORPEXP FROM KH004_mstdtls WHERE APP_NO=@OPTION3
SELECT * FROM (
SELECT ROWID, EXAM_CODE, NAME, OPTION_NAME, OPTION_CODE, SEQUENCE,CONVERT(BIT, 1) ISMENDATORY, TYPE AS EXTTYPE, MAXSIZEINKB,'' DOWNLOAD FROM FILEUPLOAD_MASTER WHERE ISMENDATORY=1 AND EXAM_CODE=@OPTION1 AND NAME=@OPTION2
UNION
SELECT ROWID, EXAM_CODE, NAME, OPTION_NAME, OPTION_CODE, SEQUENCE,
CONVERT(BIT,
CASE WHEN ROWID=1 THEN CASE WHEN @ISCAST<>'1' AND @ISCAST<>'5' THEN 1 ELSE 0 END ELSE
CASE WHEN ROWID=4 THEN CASE WHEN @HANDI='Y' THEN 1 ELSE 0 END ELSE
CASE WHEN ROWID=10 THEN CASE WHEN @ISGOVTCORPEXP='Y' THEN 1 ELSE 0 END ELSE
CASE WHEN ROWID=2 THEN CASE WHEN @ISPREEXP='Y' THEN 1 ELSE 0 END ELSE
CASE WHEN ROWID=5 THEN CASE WHEN @DIP<>'Y'THEN 1 ELSE 0 END ELSE
case when rowid=3 then case when @ISCAST='2' then 1 else 0 end else
case when rowid=12 then case when @IsExServiceMan='Y' then 1 else 0 end else
case when rowid=11 then case when @ISCAST='5' then 1 else 0 end else
1 END END END END END END END END ) ISMENDATORY
, TYPE AS EXTTYPE, MAXSIZEINKB,'' DOWNLOAD FROM FILEUPLOAD_MASTER WHERE ISMENDATORY=0 AND EXAM_CODE=@OPTION1 AND NAME=@OPTION2
) AS A WHERE ISMENDATORY=1 ORDER BY SEQUENCE
END
end
if(@Case='FileUploadSave')
begin
set @tableName =(select table_name from yrterm_mst where Exam_code=@Option1)
set @varExec='update '+@tableName+' set IsDocUpload=''Y'' where app_no='''+@Option2+''''
exec(@varExec)
if(@@rowcount>0)
begin
select 1
end
end
if(@Case='FileUploadCheck')
begin
set @tableName =(select table_Name from yrterm_mst where Exam_code=@Option1 and activeflag='Y' and fromdt<=getdate() and todate>=getdate())
print @tableName
if(isnull(@tableName,'')!='')
begin
set @varExec='select Name, isnull(IsDocUpload,''N'') IsDocUpload,''Y'' Active,GUID from '+@tableName+' where app_no='''+@Option2+''''
print @varExec
exec(@varExec)
end
else
begin
set @tableName =(select table_Name from yrterm_mst where Exam_code=@Option1)
set @varExec='select Name,isnull(IsDocUpload,''N'') IsDocUpload,''N'' Active,GUID from '+@tableName+' where app_no='''+@Option2+''''
print @varExec
exec(@varExec)
end
end
if(@Case='SaveFileUploadOnTBL')
begin
set @tableName =@Option1+'_Documents'
set @varExec='select 1 from '+@tableName+' where app_no='''+@Option2+''' and docid='''+@Option3+''''
exec(@varExec)
if(@@rowcount>0)
begin
set @varExec='update '+@tableName+' set DocPath='''+@Option4+''',insert_Date=getdate() where app_no='''+@Option2+''' and docid='''+@Option3+''''
exec(@varExec)
end
else
begin
set @varExec='insert into '+@tableName+'(app_no, DocId, DocPath) values('''+@Option2+''','''+@Option3+''','''+@Option4+''')'
print @varExec
exec(@varExec)
end
end
if(@Case='ReceiptSelectDocument')
begin
if(@Option1='KH004')
BEGIN
SELECT row_number() over(order by f.sequence) SNo,f.Option_name as 'Document Name','<a href='''+b.DocPath +''' target=''_blank'' ><img src="images/click%20here-icon.png" alt="Click Here"/></a>' link,DocPath from FileUpload_Master f join KH004_Documents b on f.RowId=b.docid where f.Exam_Code=@Option1 and f.Name=@Option2 and app_no=@Option3 order by sequence
END
end
if(@Case='DocCount')
begin
set @tableName =@Option1+'_Documents'
set @varExec='select isnull(count(*),0) from '+@tableName+' where app_no='''+@Option2+''''
exec(@varExec)
end
End
[HttpPost]
public ActionResult DocUpload(string HiddenField1, string HiddenField3, string HiddenField2, string hdid, Personal_Detail model)
{
ViewBag.lblExamName = CommonFunction.SelectTable("6", examcode, "").Rows[0]["Exam_name"].ToString();
Session["Name"] = model.Applicant_Name;
Session["application1"] = model.App_no;
model.App_no = @ViewBag.lblappno;
ViewBag.lblnote = "Read form carefully before submission.";
try
{
bool result = DynamicFileUpload.CheckUploadedDocuments();
if (result)
{
if (DynamicFileUpload.GetUploadCountValidate())
{
SqlParameter[] sqlprom = new SqlParameter[3];
string ExamCode = PortalEncryption.DecryptPassword(HiddenField3.Value).Split('_')[1];
sqlprom[0] = new SqlParameter("@Case", "FileUploadSave");
sqlprom[1] = new SqlParameter("@Option1", Functions.SQLInjection(Server.UrlDecode(ExamCode)));
sqlprom[2] = new SqlParameter("@Option2", Functions.SQLInjection(Server.UrlDecode(PortalEncryption.DecryptPassword(HiddenField1.Value))));
using (DataTable dt = Functions.ExecuteSelectProc(sqlprom, "SelOptions", Databases.collRecruitment))
{
if (dt.Rows.Count > 0)
{
app_no.Value = HiddenField1.Value;
dob.Value = HiddenField2.Value;
exam_code.Value = HiddenField3.Value;
ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "Redirect();", true);
throw new Exception("Data inserted Successfully & your Application No is '" + Functions.SQLInjection(Server.UrlDecode(PortalEncryption.DecryptPassword(app_no.Value))) + "'");
}
else
{
throw new Exception("Record is not updated please try again!!!");
}
}
}
else
{
throw new Exception("Upload Document count and Uploaded document count doesnot match,please upload all documents again or try later!!!");
}
}
else
{
throw new Exception("Please upload mendatory Documents carefully!!!");
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
lblMsg.Visible = true;
}
return View();
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team