Save,update and delete is not working which condition actio

Package.aspx page





var x=$get(’<%=ddlPacakageNames.ClientID %>’).value;



mygrid.loadXML(“http://”+location.host+"/t2india/PackageLoadData.aspx?PCode="+ x + “”,sumColumn);



myDataProcessor = new dataProcessor(“http://”+location.host+"/t2india/Savepackage.aspx?PCode="+ x +"");



myDataProcessor.setVerificator(1)



myDataProcessor.setUpdateMode(“off”);//available values: cell (default), row, off

myDataProcessor.init(mygrid);





function save_data()

{



myDataProcessor.sendData();

window.location=‘http://’+location.host+’/t2india/’;



}





Savepackage.aspx.cs





protected XmlDocument xmlDoc = null;

public string xmlfile;

private String xmlConfigFile = string.Empty;

string a = HttpContext.Current.Request.QueryString[“PageName”].ToString();

protected void Page_Load(object sender, EventArgs e)

{

xmlConfigFile = System.Web.HttpContext.Current.Server.MapPath(“xmlfiles/Itinerary.xml”);

PI.Bll.package.BllPackage objbllpackage = new PI.Bll.package.BllPackage(xmlConfigFile, Request.QueryString[“Pcode”].ToString());

Response.Write(objbllpackage.Save(Request.QueryString));

}





.bll file

namespace PI.Bll.package

{

public class BllPackage

{

protected String strFileName = “”;

protected string strPICode = “”;

protected string strPageName = string.Empty;

public BllPackage(String xmlFile, string pstrICode)

{

this.strFileName = xmlFile;

this.strPageName = “Package”;

strPICode = pstrICode;

}

~BllPackage()

{

}



public String getXML()

{

// PIInfoSoft.DLL.TripPlanner.dalDataLink objDalDataLink = new PIInfoSoft.DLL.TripPlanner.dalDataLink(strFileName, strICode, strPageName);

PI.Dal.Package.dalDataLink objdaldatalink = new PI.Dal.Package.dalDataLink(strFileName, strPICode);

String res = objdaldatalink.getXML();

return res;

}

public String Save(NameValueCollection data)

{



PI.Dal.Package.dalDataLink objdalpackage = new PI.Dal.Package.dalDataLink(strFileName, strPICode);

String res = objdalpackage.Save(data);

return res;

}

}

}





Dal file



using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.UI;

using System.Xml;

using System.Collections.Specialized;

using System.Collections;

using PIInfosoft.Framework.Data;

using Microsoft.Xml.XQuery;

using System.IO;

using System.Data.SqlClient;



///



/// Summary description for dalDataLink

///


///

namespace PI.Dal.Package

{

public class dalDataLink

{

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[“Sql”].ToString());



protected XmlDocument xmlDoc = null;

//protected IDbConnection conn = null;

protected String tag = “”;

protected string strICode = “”;

protected string strPageName = “”;

public dalDataLink( String xmlFile,string pstrICode)

{

this.xmlDoc = new XmlDocument();

this.xmlDoc.Load(xmlFile);

strICode = pstrICode;

strPageName = “Package”;

}

~dalDataLink()

{ }





private String PrintXMLHeader()

{

return this.PrintXMLHeader(“data”, “”);

}

private String PrintXMLHeader(String tag, String add)

{

this.tag = tag;

return “<?xml version=\"1.0\" encoding=\"UTF-8\"?><” + tag + " " + add + “>”;



}

private String PrintXMLFooter()

{

return “</” + this.tag + “>”;

}

///

///

///


///

///

///

///

private String PrintAction(String action, String sid, String tid)

{

return “”;

}







///

///

///


///

///

public String Save(NameValueCollection data)

{



String res = this.PrintXMLHeader();

////

String action = (xmlDoc.GetElementsByTagName(“action”)[0] == null) ? “” : data[xmlDoc.GetElementsByTagName(“action”)[0].InnerText];

if (xmlDoc.DocumentElement.Attributes[“type”] != null &&

xmlDoc.DocumentElement.Attributes[“type”].Value == “tree”)

{



}

else

{

switch (action)

{

case “deleted”:

res += this.Delete(data);

break;

case “inserted”:

res += this.Insert(data);

break;

default:

res += this.Update(data);

//res += this.Insert(data);

break;

}

}

res += this.PrintXMLFooter();

//conn.Close();

return res;

}

///

///

///


///

///

private String Delete(NameValueCollection data)

{

String tableName = xmlDoc.GetElementsByTagName(“table”)[0].Attributes[“name”].Value;

String tableKey = xmlDoc.GetElementsByTagName(“key”)[0].Attributes[“name”].Value;

String tableKeyValue = data[xmlDoc.GetElementsByTagName(“key”)[0].InnerText];

if (tableName != “”)

{

String sql = "DELETE FROM " + tableName + " WHERE " + tableKey + “=’” + tableKeyValue + “’”;

SqlCommand cmd = new SqlCommand(sql, con);

cmd.Connection.Open();

cmd.ExecuteNonQuery();

cmd.Connection.Close();

return this.PrintAction(“delete”, tableKeyValue, “0”);



}

return “”;

}

///

///

///


///

///

private String Insert(NameValueCollection data)

{

String strA = “”;

String strB = “”;

int count = 0;

foreach (XmlElement param in xmlDoc.GetElementsByTagName(“param”))

{

if (count++ > 0)

{

strA += “,”;

strB += “,”;

}

strA += param.Attributes[“name”].Value;

strB += “’” + data[param.InnerText] + “’”;

}

String sql = “INSERT INTO " + xmlDoc.GetElementsByTagName(“table”)[0].Attributes[“name”].Value + " (” + strA + “) VALUES ( " + strB + " ); SELECT scope_identity();”;

SqlCommand cmd = new SqlCommand(sql, con);

cmd.Connection.Open();

object res = cmd.ExecuteScalar();

cmd.Connection.Close();

return this.PrintAction(“insert”, data[xmlDoc.GetElementsByTagName(“key”)[0].InnerText], (res != null) ? res.ToString() : “0”);

}

///

///

///


///

///

private String Update(NameValueCollection data)

{

String sql = “UPDATE " + xmlDoc.GetElementsByTagName(“table”)[0].Attributes[“name”].Value + " SET “;

int count = 0;

foreach (XmlElement param in xmlDoc.GetElementsByTagName(“param”))

{

if (count++ > 0)

sql += “,”;

sql += param.Attributes[“name”].Value + " = '” + data[param.InnerText] + “’”;

}

sql += " WHERE " + xmlDoc.GetElementsByTagName(“key”)[0].Attributes[“name”].Value + " =’” + data[xmlDoc.GetElementsByTagName(“key”)[0].InnerText] + “’”;

SqlCommand cmd = new SqlCommand(sql, con);

cmd.Connection.Open();

cmd.ExecuteNonQuery();

cmd.Connection.Close();

return this.PrintAction(“update”, data[xmlDoc.GetElementsByTagName(“key”)[0].InnerText], “0”);

}









public String getXML()

{

String res = “”;

String type = (xmlDoc.DocumentElement.Attributes[“type”] != null) ? xmlDoc.DocumentElement.Attributes[“type”].Value : “”;

switch (type)

{

case “tree”:

break;

default:

if(strPageName==“Package”)

{

res += this.PrintXMLHeader(“rows”, “”);

res += " " +

" Sr No. " +

" vcItineraryCode " +

" From Date " +

" From Place " +

" To Place " +

" " +

" Mode " +

" Air " +

" Train " +

" Road " +

" Other " +

" " +

" Over Night " +

" To Date " +

" stayNight " +

" FromPlaceCode " +

" ToPlaceCode " +



" " +

" px " +

" " +

" “;

res += this.GetXmlGrid();

}

break;

}

res += this.PrintXMLFooter();

//conn.Close();

return res;

}

///

///

///


///

private String GetXmlGrid()

{

String res = “”;

String where = xmlDoc.GetElementsByTagName(“where”)[0].InnerText;

if (strPageName == “Package”)

{



String sql = “SELECT * FROM " + xmlDoc.GetElementsByTagName(“table”)[0].Attributes[“name”].Value;

if (where != “” && strICode != “”)

sql += " WHERE " + where + “=’” + strICode.Trim() + “’ order by inSrNo”;

SqlCommand cmd = new SqlCommand(sql, con);

cmd.Connection.Open();

IDataReader r = cmd.ExecuteReader();

while (r.Read())

{



res += “<row id=”” + r[xmlDoc.GetElementsByTagName(“key”)[0].Attributes[“name”].Value] + “”>”;



foreach (XmlElement param in xmlDoc.GetElementsByTagName(“param”))

{

if (param.Attributes[“name”].Value == “inSrNo”)

{

res += “” + r[1] + “”;

}

else if (param.Attributes[“name”].Value==“dtFromDate”)

{

res += “” + DateTime.Now.Date + “”;

}

else if (param.Attributes[“name”].Value == “inStayingNights”)

{

res += “” + r[9] + “”;

}

else if (param.Attributes[“name”].Value == “dtToDate”)

{

res += “” + DateTime.Now.Date + “”;

}

else

{







res += “” + r[param.Attributes[“name”].Value] + “”;











}

}



res += “”;

}



cmd.Connection.Close();

return res;

}

else{return res;}



}







}

}



Please try to include dhtmlxdataprocessor_debug.js ( included in your package ) , it will add debug console output.
If there was some errors on server side during update process - extended error info will be shown.