*************Employee Model*******************
public classEmployeeModel
{
public EmployeeModel()
{
EmployeeList = new List<EmployeeModel>();
StudentList = new List<EmployeeModel>();
ServiceList = new List<SelectListItem>();
ParentList = new List<SelectListItem>();
GenderList= new List<SelectListItem>
{
new SelectListItem() {Text = "--Select--", Value ="0" },
new SelectListItem() {Text = "Male", Value ="1" },
new SelectListItem() {Text = "Female", Value ="2"},
};
}
public int ID { get; set; }
public string Name{ get; set; }
public string Address{ get; set; }
public int Age{ get; set; }
public string Mobile{ get; set; }
public List<EmployeeModel> EmployeeList { get; set; }
public List<EmployeeModel> StudentList { get; set; }
public IEnumerable<Employee> SerList { get; set; }
public decimal? ServiceUsage { get; set; }
public decimal? ServiceCost_Per_Annum { get; set; }
public decimal? ServiceCost_for_Service { get; set; }
public List<SelectListItem> GenderList{ get; set; }
publicActionResultLogOut(){HttpCookie cookie =Request.Cookies["TSWA-Last-User"];if(User.Identity.IsAuthenticated==false|| cookie ==null||StringComparer.OrdinalIgnoreCase.Equals(User.Identity.Name, cookie.Value)){string name =string.Empty;if(Request.IsAuthenticated){
name =User.Identity.Name;}
cookie =newHttpCookie("TSWA-Last-User", name);Response.Cookies.Set(cookie);Response.AppendHeader("Connection","close");Response.StatusCode=401;// Unauthorized;Response.Clear();//should probably do a redirect here to the unauthorized/failed login page//if you know how to do this, please tap it on the comments belowResponse.Write("Unauthorized. Reload the page to try again...");Response.End();returnRedirectToAction("Index");}
cookie =newHttpCookie("TSWA-Last-User",string.Empty){Expires=DateTime.Now.AddYears(-5)};Response.Cookies.Set(cookie);returnRedirectToAction("Index");}
<script type="text/javascript">
function insertWebForm() {
debugger;
if (document.getElementById('<%=txtPage.ClientID%>').value == '') {
document.getElementById('<%=txtPage.ClientID%>').focus();
return false;
}
var pageName = document.getElementById('<%=txtPage.ClientID%>').value;
var isCheck = document.getElementById('<%=chkstatus.ClientID%>').checked;
document.getElementById('<%=hdlField.ClientID%>').value = "";
var label = document.getElementById('<%=hdlField.ClientID%>').value;
var fname = document.getElementById("FName");
var title = document.getElementById("Title");
var lname = document.getElementById("LName");
var company = document.getElementById("Company");
var phone = document.getElementById("Phone");
function OnSuccess(response) {
debugger;
if (response.d == "true") {
document.getElementById('<%=hdlField.ClientID%>').value = "";
var abc = document.getElementById('<%=hdlField.ClientID%>').value;
window.location = '/DynamicLabelList.aspx';
}
else {
document.getElementById('<%=hdlField.ClientID%>').value = "";
var abc = document.getElementById('<%=hdlField.ClientID%>').value;
alert("Page Name already inserted");
}
}
function RemoveLabelControl(div) {
document.getElementById("labelContainer").removeChild(div.parentNode);
}
</script>
<script type="text/javascript">
function drag(ev) {
document.getElementById('<%=hdnLabel.ClientID%>').value = ev.target.innerHTML;
}
function allowDrop(ev) {
debugger;
var counter = 0;
var label = document.getElementById('<%=hdnLabel.ClientID%>').value;
if (label) {
var div = document.createElement('DIV');
public static string insertPageNamewithLabel(string pageName, string isCheck, string label)
{
string result = "true";
DataTable dt = new DataTable();
SqlDataAdapter da;
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source="";Initial Catalog="";Persist Security Info=True;User ID="";Password=""";
SqlCommand cmd = new SqlCommand("select * from page where Name='" + pageName + "'", con);
da = new SqlDataAdapter(cmd);
da.Fill(dt);
con.Open();
cmd.ExecuteNonQuery();
if (dt.Rows.Count > 0)
{
result = "false";
//lblMsg.Text = "Page Name already inserted";
//lblMsg.ForeColor = System.Drawing.Color.Green;
}
else
{
SqlConnection coninsert = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["con"].ConnectionString);
coninsert.Open();
string strquery = "INSERT INTO [dbo].[Page]([Name],[Status]) VALUES (@name,@status);SELECT CAST(scope_identity() AS int)";
SqlCommand cmdinsert = new SqlCommand(strquery, coninsert);
cmdinsert.Parameters.AddWithValue("@name", pageName);
if (isCheck == "false")
{
cmdinsert.Parameters.AddWithValue("@status", false);
}
else
{
cmdinsert.Parameters.AddWithValue("@status", true);
}
int pageId = (int)cmdinsert.ExecuteScalar();
if (pageId > 0)
{
if (label.Length > 0)
{
string[] splitId = label.Split(new string[] { "/" }, StringSplitOptions.None);
if (splitId.Count() > 0)
{
for (int i = 0; i < splitId.Count(); i++)
{
if (splitId[i] != "")
{
SqlConnection mycon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["con"].ConnectionString);
mycon.Open();
string strquery1 = "insert into PageField (PageID, ControlToDisplay, FieldLabel, RequiredValidation, OrderBy, OptionalValue)values(@pageid,@Control,@fieldlabel,@required,@orderby,@optionalvalue);SELECT CAST(scope_identity() AS int)";
SqlCommand cmdPageLabel = new SqlCommand(strquery1, mycon);