anylove
یک شنبه 09 اسفند 1394, 04:29 صبح
سلام من از یک کتابخونه ججاوا اسکریپت استفاده میکنم
دیتایی که میگیره باید بدون کوتیشن باشه مانند :
[
{ id: 1, parentId: null, name: "Amber McKenzie", title: "CEO", phone: "678-772-470", mail: "lemmons@jourrapide.com", adress: "Atlanta, GA 30303" , image: "images/f-11.jpg" },
{ id: 2, parentId: 1, name: "Ava Field", title: "Paper goods machine setter", phone: "937-912-4971", mail: "anderson@jourrapide.com", image: "images/f-22.jpg" },
{ id: 3, parentId: 1, name: "Evie Johnson", title: "Employer relations representative", phone: "314-722-6164", mail: "thornton@armyspy.com", image: "images/f-24.jpg" },
{ id: 4, parentId: 1, name: "Paul Shetler", title: "Teaching assistant", phone: "330-263-6439", mail: "shetler@rhyta.com", image: "images/f-25.jpg" },
{ id: 5, parentId: 1, name: "Rebecca Francis", title: "Welding machine setter", phone: "408-460-0589", image: "images/f-26.jpg" },
{ id: 6, parentId: 1, name: "Rebecca Randall", title: "Optometrist", phone: "801-920-9842", mail: "JasonWGoodman@armyspy.com", image: "images/f-27.jpg" }
]
ولی دیتایی برگردانده میشه داببل کوتیشن داره ممنون میشم کمکم کنید
[{"parentId":0,"image":"/Panel/RetrieveStamp/63211","id":63211,"name":"عليرضا فغاني","title":"مدير عامل","mobile":"no number","mail":"no mail"},{"parentId":63211,"image":"/Panel/RetrieveStamp/63212","id":63212,"name":"جواد خياباني","title":" مدير اداري و مالي","mobile":"no number","mail":"no mail"},{"parentId":63211,"image":"/Panel/RetrieveStamp/63213","id":63213,"name":"عادل فردوسي پور","title":" مدير پشتيباني","mobile":"no number","mail":"no mail"},{"parentId":63212,"image":"/Panel/RetrieveStamp/63214","id":63214,"name":"تقي مزيناني","title":" مدير مالي","mobile":"no number","mail":"no mail"},{"parentId":63212,"image":"/Panel/RetrieveStamp/63215","id":63215,"name":"حسين منافي","title":" مدير اداري","mobile":"no number","mail":"no mail"},{"parentId":63213,"image":"/Panel/RetrieveStamp/63216","id":63216,"name":"پيمان يوسفي","title":" مدير برنامه ريزي و انبارها","mobile":"no number","mail":"no mail"},{"parentId":63213,"image":"/Panel/RetrieveStamp/63217","id":63217,"name":"احسان تقي خاني","title":" مدير خدمات","mobile":"no number","mail":"no mail"},{"parentId":63216,"image":"/Panel/RetrieveStamp/63218","id":63218,"name":"مهران مديري","title":" رييس انبارها","mobile":"no number","mail":"no mail"},{"parentId":63216,"image":"/Panel/RetrieveStamp/63219","id":63219,"name":"سعيد آقاخاني","title":" رييس برنامه ريزي توليد","mobile":"no number","mail":"no mail"},{"parentId":63218,"image":"/Panel/RetrieveStamp/63220","id":63220,"name":"علي نصيريان","title":" انباردار 1","mobile":"no number","mail":"no mail"},{"parentId":63214,"image":"/Panel/RetrieveStamp/63222","id":63222,"name":"حجت عزيزي","title":"رييس حسابداري","mobile":"no number","mail":"no mail"},{"parentId":63214,"image":"/Panel/RetrieveStamp/63223","id":63223,"name":"خداداد عزيزي","title":"رييس حسابداري صنعتي","mobile":"no number","mail":"no mail"},{"parentId":63214,"image":"/Panel/RetrieveStamp/63224","id":63224,"name":"علي مطهري","title":"رييس خزانه داري","mobile":"no number","mail":"no mail"},{"parentId":63222,"image":"/Panel/RetrieveStamp/63225","id":63225,"name":"جعفر سبحاني","title":"حسابداري 1","mobile":"no number","mail":"no mail"},{"parentId":63222,"image":"/Panel/RetrieveStamp/63226","id":63226,"name":"علي مطهري","title":"حسابداري 2","mobile":"no number","mail":"no mail"}]
میخوام دابل کوتیشن دور همه فیلد های id و name و ... نباشده
تو چند سایت هم خوندم باید @Html.Raw(Json.Encode(Model))
باز نشد
ممنون میشم کمککم کنید
متدی که رکوردها رو از دیتا بیس میخونه :
public List<ItemOrgChartModel> getElementOrganizer()
{
String connectionString = "Data Source=DESKTOP-5J59MI8\\MR_SAADI;Initial Catalog=Shiz; User ID=sa; Password=100";
String sql = "SELECT Org_Chart_Id,Org_Chart_Parent_Id,Org_Chart_Title,H um_Employee.Employee_Id,Hum_Employee.Employee_Fnam e,Hum_Employee.Employee_Lname,Employee_Pname,Emplo yee_Birth_Certificate,Employee_Birth_Date,Employee _User_Id,Employee_Country_Id,Employee_Birth_State, Employee_Birth_City,Employee_Canceled,Employee_Gen der,Employee_Marital_Id,Employee_Address,Employee_ Postal_Code,Employee_Tel,Employee_Mobile,Employee_ Email,Employee_Start_History,Employee_Religion_Id FROM vi_OrgChartEmployee,Hum_Employee where Hum_Employee.Employee_Id=vi_OrgChartEmployee.Emplo yee_Id";
SqlCommand cmd = new SqlCommand();
List<ItemOrgChartModel> model = new List<ItemOrgChartModel>();
using (SqlConnection conn = new SqlConnection(connectionString))
{
cmd.Connection = conn;
cmd.CommandText =sql;
conn.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
ItemOrgChartModel item = new ItemOrgChartModel();
item.id = Convert.ToInt32(rdr["Org_Chart_Id"]);
item.name = ""+rdr["Employee_Fname"]+" "+rdr["Employee_Lname"];
if (item.id == 63211)
item.parentId=0;
else item.parentId = Convert.ToInt32(rdr["Org_Chart_Parent_Id"]);
item.title = (string)rdr["Org_Chart_Title"];
if (Equals(rdr["Employee_Mobile"]))
item.mobile = Convert.ToString(rdr["Employee_Mobile"]);
else item.mobile = "no number";
if (Equals(rdr["Employee_Email"]))
item.mail = (string) rdr["Employee_Email"];
else item.mail = "no mail";
item.image = "/Panel/RetrieveStamp/"+item.id;
model.Add(item);
}
return model;
}
}
اکشن :
public ActionResult OrgCHart()
{
return View(con.getElementOrganizer());
}
دیتایی که میگیره باید بدون کوتیشن باشه مانند :
[
{ id: 1, parentId: null, name: "Amber McKenzie", title: "CEO", phone: "678-772-470", mail: "lemmons@jourrapide.com", adress: "Atlanta, GA 30303" , image: "images/f-11.jpg" },
{ id: 2, parentId: 1, name: "Ava Field", title: "Paper goods machine setter", phone: "937-912-4971", mail: "anderson@jourrapide.com", image: "images/f-22.jpg" },
{ id: 3, parentId: 1, name: "Evie Johnson", title: "Employer relations representative", phone: "314-722-6164", mail: "thornton@armyspy.com", image: "images/f-24.jpg" },
{ id: 4, parentId: 1, name: "Paul Shetler", title: "Teaching assistant", phone: "330-263-6439", mail: "shetler@rhyta.com", image: "images/f-25.jpg" },
{ id: 5, parentId: 1, name: "Rebecca Francis", title: "Welding machine setter", phone: "408-460-0589", image: "images/f-26.jpg" },
{ id: 6, parentId: 1, name: "Rebecca Randall", title: "Optometrist", phone: "801-920-9842", mail: "JasonWGoodman@armyspy.com", image: "images/f-27.jpg" }
]
ولی دیتایی برگردانده میشه داببل کوتیشن داره ممنون میشم کمکم کنید
[{"parentId":0,"image":"/Panel/RetrieveStamp/63211","id":63211,"name":"عليرضا فغاني","title":"مدير عامل","mobile":"no number","mail":"no mail"},{"parentId":63211,"image":"/Panel/RetrieveStamp/63212","id":63212,"name":"جواد خياباني","title":" مدير اداري و مالي","mobile":"no number","mail":"no mail"},{"parentId":63211,"image":"/Panel/RetrieveStamp/63213","id":63213,"name":"عادل فردوسي پور","title":" مدير پشتيباني","mobile":"no number","mail":"no mail"},{"parentId":63212,"image":"/Panel/RetrieveStamp/63214","id":63214,"name":"تقي مزيناني","title":" مدير مالي","mobile":"no number","mail":"no mail"},{"parentId":63212,"image":"/Panel/RetrieveStamp/63215","id":63215,"name":"حسين منافي","title":" مدير اداري","mobile":"no number","mail":"no mail"},{"parentId":63213,"image":"/Panel/RetrieveStamp/63216","id":63216,"name":"پيمان يوسفي","title":" مدير برنامه ريزي و انبارها","mobile":"no number","mail":"no mail"},{"parentId":63213,"image":"/Panel/RetrieveStamp/63217","id":63217,"name":"احسان تقي خاني","title":" مدير خدمات","mobile":"no number","mail":"no mail"},{"parentId":63216,"image":"/Panel/RetrieveStamp/63218","id":63218,"name":"مهران مديري","title":" رييس انبارها","mobile":"no number","mail":"no mail"},{"parentId":63216,"image":"/Panel/RetrieveStamp/63219","id":63219,"name":"سعيد آقاخاني","title":" رييس برنامه ريزي توليد","mobile":"no number","mail":"no mail"},{"parentId":63218,"image":"/Panel/RetrieveStamp/63220","id":63220,"name":"علي نصيريان","title":" انباردار 1","mobile":"no number","mail":"no mail"},{"parentId":63214,"image":"/Panel/RetrieveStamp/63222","id":63222,"name":"حجت عزيزي","title":"رييس حسابداري","mobile":"no number","mail":"no mail"},{"parentId":63214,"image":"/Panel/RetrieveStamp/63223","id":63223,"name":"خداداد عزيزي","title":"رييس حسابداري صنعتي","mobile":"no number","mail":"no mail"},{"parentId":63214,"image":"/Panel/RetrieveStamp/63224","id":63224,"name":"علي مطهري","title":"رييس خزانه داري","mobile":"no number","mail":"no mail"},{"parentId":63222,"image":"/Panel/RetrieveStamp/63225","id":63225,"name":"جعفر سبحاني","title":"حسابداري 1","mobile":"no number","mail":"no mail"},{"parentId":63222,"image":"/Panel/RetrieveStamp/63226","id":63226,"name":"علي مطهري","title":"حسابداري 2","mobile":"no number","mail":"no mail"}]
میخوام دابل کوتیشن دور همه فیلد های id و name و ... نباشده
تو چند سایت هم خوندم باید @Html.Raw(Json.Encode(Model))
باز نشد
ممنون میشم کمککم کنید
متدی که رکوردها رو از دیتا بیس میخونه :
public List<ItemOrgChartModel> getElementOrganizer()
{
String connectionString = "Data Source=DESKTOP-5J59MI8\\MR_SAADI;Initial Catalog=Shiz; User ID=sa; Password=100";
String sql = "SELECT Org_Chart_Id,Org_Chart_Parent_Id,Org_Chart_Title,H um_Employee.Employee_Id,Hum_Employee.Employee_Fnam e,Hum_Employee.Employee_Lname,Employee_Pname,Emplo yee_Birth_Certificate,Employee_Birth_Date,Employee _User_Id,Employee_Country_Id,Employee_Birth_State, Employee_Birth_City,Employee_Canceled,Employee_Gen der,Employee_Marital_Id,Employee_Address,Employee_ Postal_Code,Employee_Tel,Employee_Mobile,Employee_ Email,Employee_Start_History,Employee_Religion_Id FROM vi_OrgChartEmployee,Hum_Employee where Hum_Employee.Employee_Id=vi_OrgChartEmployee.Emplo yee_Id";
SqlCommand cmd = new SqlCommand();
List<ItemOrgChartModel> model = new List<ItemOrgChartModel>();
using (SqlConnection conn = new SqlConnection(connectionString))
{
cmd.Connection = conn;
cmd.CommandText =sql;
conn.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
ItemOrgChartModel item = new ItemOrgChartModel();
item.id = Convert.ToInt32(rdr["Org_Chart_Id"]);
item.name = ""+rdr["Employee_Fname"]+" "+rdr["Employee_Lname"];
if (item.id == 63211)
item.parentId=0;
else item.parentId = Convert.ToInt32(rdr["Org_Chart_Parent_Id"]);
item.title = (string)rdr["Org_Chart_Title"];
if (Equals(rdr["Employee_Mobile"]))
item.mobile = Convert.ToString(rdr["Employee_Mobile"]);
else item.mobile = "no number";
if (Equals(rdr["Employee_Email"]))
item.mail = (string) rdr["Employee_Email"];
else item.mail = "no mail";
item.image = "/Panel/RetrieveStamp/"+item.id;
model.Add(item);
}
return model;
}
}
اکشن :
public ActionResult OrgCHart()
{
return View(con.getElementOrganizer());
}