本文整理匯總了C#中System.Data.DataTable.Select方法的典型用法代碼示例。如果您正苦於以下問題:C# DataTable.Select方法的具體用法?C# DataTable.Select怎麽用?C# DataTable.Select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Data.DataTable
的用法示例。
在下文中一共展示了DataTable.Select方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DataTableToJson
private static void DataTableToJson(StringBuilder result, StringBuilder temp, DataTable table, string idColumn, string textColumn, string relativeColumn, object parentId)
{
result.Append(temp.ToString());
temp.Clear();
if (table.Rows.Count > 0)
{
temp.Append("[");
string filer = string.Format("{0}='{1}'", relativeColumn, parentId);
DataRow[] rows = table.Select(filer);
if (rows.Length > 0)
{
foreach (DataRow row in rows)
{
temp.Append("{\"id\":\"" + row[idColumn] + "\",\"text\":\"" + row[textColumn] + "\",\"state\":\"open\"");
if (table.Select(string.Format("{0}='{1}'", relativeColumn, row[idColumn])).Length > 0)
{
temp.Append(",\"children\":");
DataTableToJson(result, temp, table, idColumn, textColumn, relativeColumn, row[idColumn]);
result.Append(temp.ToString());
temp.Clear();
}
result.Append(temp.ToString());
temp.Clear();
temp.Append("},");
}
temp = temp.Remove(temp.Length - 1, 1);
}
temp.Append("]");
result.Append(temp.ToString());
temp.Clear();
}
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
#region Check Login
CheckRegionAdminSession();
#endregion Check Login
#region Initialize Values and Form Execution
strPortfolioID = CCLib.Common.Strings.GetQueryString("PortfolioID");
dtPortInfo = CCLib.Common.DataAccess.GetDataTable("select p.Username,GradeNumber,FirstName,LastName,p.UserName,u.institutionName from Portfolio p join Userinfo u on p.Schoolid = u.schoolid where portfolioid=" + strPortfolioID);
strSQL = " select p.Username,p.Fullname,p.Address,p.City,p.State,p.Zip,p.Phone,p.Email,p.Password,p.IsImport ";
strSQL += " from Port_Parent_View as p join Portfolio on p.Username = Portfolio.Username ";
strSQL += " where PortfolioID=" + strPortfolioID + " and p.PortTypeID=" + PortTypeID;
dtParents = CCLib.Common.DataAccess.GetDataTable(strSQL);
drsParentByImport = dtParents.Select("IsImport=1");
drsParentByInput = dtParents.Select("IsImport=0");
strUsername = (dtPortInfo.Rows.Count > 0) ? dtPortInfo.Rows[0]["Username"].ToString() : "";
#endregion Initialize Values and Form Execution
#region Properties For The Region Base Class
TitleBar = "Parent/Guardian Access Accounts";
SubTitleBar = "Parent/Guardian Access Accounts";
#endregion Properties For The Region Base Class
}
示例3: GetLeftTree
/// 修改:李東峰 日期:2014-2-28
/// 修改內容:增加根據visible屬性判斷是否顯示該菜單
public void GetLeftTree(string id)
{
string userId = Request.Cookies["T_USERID"].Value.ToString();
string roleId = bl.GetRoleId(userId);
dt = new DataTable();
GetTreeList();
DataRow[] _dr = dt.Select("PID='" + id + "'");
IList<Hashtable> list = new List<Hashtable>();
for (int i = 0; i < _dr.Length; i++)
{
string[] nodeRoleId = _dr[i][5].ToString().TrimStart(',').TrimEnd(',').Split(',');
if (nodeRoleId.Contains(roleId) && _dr[i][4].ToString() == "1")
{
Hashtable ht = new Hashtable();
ht.Add("ID", _dr[i][0].ToString());
ht.Add("NAME", _dr[i][1].ToString());
DataRow[] _dr_judge = dt.Select("PID='" + _dr[i][0].ToString() + "'");
if (_dr_judge.Length > 0)
ht.Add("JUDGE", "1");
else
ht.Add("JUDGE", "0");
list.Add(ht);
}
}
object obj = new
{
list = list
};
string result = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
Response.Write(result);
Response.End();
}
示例4: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
LoginID = Request.QueryString["LoginID"];
LoginInfo = CCLib.Login.GetLoginInfo(LoginID);
Redirect();
PageTitle = "Ability Profiler";
Section = "mm";
CSS = "global_css";
HeadTag = "<style type='TEXT/CSS'><!--.btnDescription { font: 11px Verdana, Arial, Helvetica, sans-serif; margin: 0px 15px}--></style>";
BodyTag = " alink='#990000' style='background-image:url(/media/shared/bg_else.gif); background-repeat:no-repeat; background-color:#FFFFFF;' leftmargin=0 link='#003366' text='#000000' topmargin=0 vlink='#003366' marginwidth='0' marginheight='0'";
LeftBar = "<table border='0' cellpadding='0' cellspacing='0' style='width:100%;'><tr style='background-color:#336699; vertical-align:top;'><td style='background-image:url(/media/mm/i_top_bar_bg.gif);'><img src='/media/mm/i_c_mm_icon.gif' alt=''><img src='/media/mm/h_c_mm.gif' alt='" + TextCode(273) + "'>";
HasTopCenterButtons = false;
ClientScript.RegisterClientScriptBlock(Page.GetType(), "Reconnect", CCLib.Login.AddKeepAlive());
strSection = (CCLib.Common.Strings.GetQueryString("SID") == "") ? "0" : CCLib.Common.Strings.GetSecureQueryString("SID");
strTestID = (CCLib.Common.Strings.GetQueryString("TID") == "") ? "0" : CCLib.Common.Strings.GetSecureQueryString("TID");
strRegID = (CCLib.Common.Strings.GetQueryString("RID") == "") ? "0" : CCLib.Common.Strings.GetSecureQueryString("RID");
strResult = CCLib.Common.Strings.GetQueryString("Result");
intCurrPart = Convert.ToInt16(strSection) - 1;
strSQL = "SELECT SectionID, SectionName_EN, SectionNameCapital_EN, SectionDescription_EN, ExampleDescription_EN, PracticeDescription_EN, Timer, ";
strSQL += " NumberOfSlotsInOnePage, NumberOfQuestionInSlot, LayoutType,TotalQuestions FROM AP_Section";
dtbSection = CCLib.Cache.GetCachedDataTable("AP_Section" + CCLib.Common.Strings.SuffixCode(), strSQL);
drsCurrSection = dtbSection.Select("SectionID=" + intCurrPart.ToString());
strSectionName = drsCurrSection[0]["SectionNameCapital" + SuffixCode()].ToString();
if (intCurrPart < 6)
{
drsNextSection = dtbSection.Select("SectionID=" + strSection);
strNextSectionTimer = drsNextSection[0]["Timer"].ToString();
}
strSection = Server.UrlEncode(CCLib.Common.Strings.SetSecureQueryString("SID", strSection));
strTestID = Server.UrlEncode(CCLib.Common.Strings.SetSecureQueryString("TID", strTestID));
strRegID = Server.UrlEncode(CCLib.Common.Strings.SetSecureQueryString("RID", strRegID));
}
示例5: FillMenus
private static void FillMenus(THOK.AF.Config config, DataTable moduleTable, DataTable functionTable)
{
DataRow[] moduleRows = moduleTable.Select("PARENTID='000000'", "SHOWORDER");
foreach (DataRow moduleRow in moduleRows)
{
DataRow[] menuRows = moduleTable.Select(string.Format("PARENTID='{0}'", moduleRow["MODULEID"]), "SHOWORDER");
List<THOK.AF.Menu> menus = new List<THOK.AF.Menu>();
foreach (DataRow menuRow in menuRows)
{
string menuID = menuRow["MODULEID"].ToString();
THOK.AF.Menu menu = new THOK.AF.Menu(menuRow["MODULENAME"].ToString(),
menuRow["MODULEURL"].ToString(),
menuID);
menus.Add(menu);
if (functionTable != null)
{
DataRow[] functionRows = functionTable.Select(string.Format("MODULEID='{0}'", menuID));
foreach (DataRow row in functionRows)
config.AddFunction(menuID, row["CONTROLNAME"].ToString());
}
}
if (menus.Count != 0)
{
THOK.AF.MenuList menuList = new THOK.AF.MenuList(moduleRow["MODULENAME"].ToString(), menus);
config.MenuList.Add(menuList);
}
}
}
示例6: tbnGenerateReport_Click
protected void tbnGenerateReport_Click(object sender, EventArgs e)
{
DataTable dtProductData = new DataTable();
var url = "";
if (ddlSelectProduct.SelectedValue == "0")
{
url = "https://www.kimonolabs.com/api/du33b7qw?apikey=rIUTL1gnwlZf0c0S8aDdLfGpMPGblfhN"; // Venom
}
else if (ddlSelectProduct.SelectedValue == "1")
{
url = "https://www.kimonolabs.com/api/biu6l4c8?&apikey=rIUTL1gnwlZf0c0S8aDdLfGpMPGblfhN"; // Optimum Whey
}
else if (ddlSelectProduct.SelectedValue == "2")
{
url = "https://www.kimonolabs.com/api/7qpe5n4g?&apikey=rIUTL1gnwlZf0c0S8aDdLfGpMPGblfhN"; // Pea Protein
}
else if (ddlSelectProduct.SelectedValue == "3")
{
url = "https://www.kimonolabs.com/api/87yhw5ha?&apikey=rIUTL1gnwlZf0c0S8aDdLfGpMPGblfhN"; // Nutrients Direct Whey Protein
}
else if (ddlSelectProduct.SelectedValue == "4")
{
url = "https://www.kimonolabs.com/api/adx2qlak?&apikey=rIUTL1gnwlZf0c0S8aDdLfGpMPGblfhN"; // Swisse Men’s Ultivite
}
else if (ddlSelectProduct.SelectedValue == "5")
{
url = "https://www.kimonolabs.com/api/5161uvtw?&apikey=rIUTL1gnwlZf0c0S8aDdLfGpMPGblfhN"; // Beagle Telecom
}
else if (ddlSelectProduct.SelectedValue == "6")
{
url = "https://www.kimonolabs.com/api/4t9u4z0y?&apikey=rIUTL1gnwlZf0c0S8aDdLfGpMPGblfhN"; // Bigpond
}
dtProductData = Review.GetDataFromURL(url);
ProductDetails.Visible = true;
CommentDetails.Visible = true;
lblProductName.Text = dtProductData.Rows[0]["ProductName"].ToString();
lblAverageRatings.Text = dtProductData.Rows[0]["AverageRating"].ToString();
lblTotalRating.Text = dtProductData.Rows[0]["OutofRating"].ToString();
int PositiveCount = dtProductData.Select("Interpretation = 'Positive'").Length;
int NegativeCount = dtProductData.Select("Interpretation = 'Negative'").Length;
int UndCount = dtProductData.Select("Interpretation = 'Undetermined'").Length;
int TotalCount = dtProductData.Rows.Count;
lblPositiveComments.Text = PositiveCount + "/" + TotalCount;
lblNegativeComments.Text = NegativeCount + "/" + TotalCount;
lblUndComments.Text = UndCount + "/" + TotalCount;
StringBuilder objStringBuilder = RenderGrid(dtProductData);
divResult.InnerHtml = objStringBuilder.ToString();
}
示例7: Print
public void Print(DataTable barcodeTable)
{
DataRow[] barcodeRows = barcodeTable.Select("ISMIX='0'", "BARCODEORDER");
foreach (DataRow row in barcodeRows)
{
barcodeRow = row;
if (row["MIXID"].ToString().Trim().Length != 0)
mixRows = barcodeTable.Select(String.Format("MIXID='{0}' AND ISMIX='1'", row["MIXID"]));
else
mixRows = null;
printDoc.Print();
}
}
示例8: FilterData
private static void FilterData(DataTable emps, DataTable jobs, string resType)
{
//notice that except for resType = ASSIGNED and jobType = All, these filters
//all depends on both JobId and Userid data because all of these look at the
//allocations table, whose rows include jobid, userid fields.
//restypes are: ASSIGNED, ALLOCATED, UNALLOCATED, OVERALLOCATED, UNDERALLOCATED
long start = DateTime.Now.Ticks;
ArrayList toRemove = new ArrayList();
DataRow[] rows = null;
//filter for "Allocated" jobs
foreach (DataRow row in jobs.Rows)
{
int job = Convert.ToInt32(row["JobId"]);
rows = emps.Select("JobId=" + job + " AND AnyMins>0");
if (rows.Length == 0)
toRemove.Add(row);
}
if (toRemove.Count > 0)
foreach (object row in toRemove)
jobs.Rows.Remove((DataRow)row);
switch (resType)
{
case "ALLOCATED":
rows = emps.Select("HrsAllocated<=0 AND RealPerson='Y'");
foreach (DataRow row in rows)
emps.Rows.Remove(row);
break;
case "UNALLOCATED":
rows = emps.Select("HrsAllocated>0 AND RealPerson='Y'");
foreach (DataRow row in rows)
emps.Rows.Remove(row);
break;
case "OVERALLOCATED":
rows = emps.Select("HrsAllocated < (HrsAvailable*60) AND RealPerson='Y'");
foreach (DataRow row in rows)
emps.Rows.Remove(row);
break;
case "UNDERALLOCATED":
//only show ppl who are allocd less hrs than their max
rows = emps.Select("HrsAllocated > (HrsAvailable*60) AND RealPerson='Y'");
foreach (DataRow row in rows)
emps.Rows.Remove(row);
break;
}
long end = DateTime.Now.Ticks;
Debug.WriteLine("filterdata() in deptgrid took: " + (end - start).ToString("n") + " ticks");
}
示例9: BuildMenuJasonString
private string BuildMenuJasonString(DataTable dtMenus)
{
StringBuilder menuBuilder = new StringBuilder();
string formater = string.Empty;
menuBuilder.Append(@"{ 'menus': [");
//分兩級菜單,第一級為模塊名,第二級為頁麵菜單
//1. 首先獲取模塊名,根據排序字段進行升序排序
DataRow[] drRoots = dtMenus.Select("PARENT_ID is NULL", "SORTINDEX ASC");
//2. 遍曆模塊,獲取模塊下麵的頁麵菜單。並將頁麵菜單進行升序排序
int rootIndex = 0;
foreach (DataRow dr in drRoots)
{
rootIndex++;
//模塊ID
string rootID = dr["SORTINDEX"].ToString();
//模塊圖片路徑,如果未設置,則設置默認的圖片
string rootIconUrl = dr["ICONURL"].ToString().Trim().Length == 0 ? "icon-sys" : dr["ICONURL"].ToString().Trim();
//模塊名
string rootMenuName = dr["TITLE"].ToString();
formater = @"{ 'menuid': '" + rootID + "', 'icon': '" + rootIconUrl + "', 'menuname': '" + rootMenuName + "', 'menus': [";
menuBuilder.Append(formater);
string parentID = dr["PK_ID"].ToString();
DataRow[] drMenus = dtMenus.Select("PARENT_ID='" + parentID + "'", "SORTINDEX ASC");
int menuIndex = 0;
foreach (DataRow drMenu in drMenus)
{
menuIndex++;
//菜單ID
string menuID = drMenu["SORTINDEX"].ToString();
//菜單圖片路徑,如果未設置,則設置默認的圖片
string menuIconUrl = drMenu["ICONURL"].ToString().Trim().Length == 0 ? "icon-nav" : drMenu["ICONURL"].ToString().Trim();
//菜單名
string menuName = drMenu["TITLE"].ToString();
//菜單對應頁麵路徑
string menuPageURL = drMenu["PAGEURL"].ToString().ToLower().Replace("~/pages","..");
if (menuIndex < drMenus.Length)
formater = @"{ 'menuid': '" + menuID + "', 'icon': '" + menuIconUrl + "', 'menuname': '" + menuName + "', 'url': '" + menuPageURL + "'},";
else
formater = @"{ 'menuid': '" + menuID + "', 'icon': '" + menuIconUrl + "', 'menuname': '" + menuName + "', 'url': '" + menuPageURL + "'}]}";
menuBuilder.Append(formater);
}
if (rootIndex < drRoots.Length)
menuBuilder.Append(",");
else
menuBuilder.Append("]}");
}
return menuBuilder.ToString();
}
示例10: GetSkillPanelBmp
public Bitmap GetSkillPanelBmp(ref DataTable skillTable, int characterClassId, bool forceRecreate)
{
_skillTable = skillTable;
int generalSkillTableId = 0;
string folder = Directory.GetCurrentDirectory() + @"\images\";
string bmpPath = folder + characterClassId + ".bmp";
string select = "skillTab = '" + characterClassId + "'";
DataRow[] skills = _skillTable.Select(select);
select = "skillTab = '" + generalSkillTableId + "'";
DataRow[] generalSkills = _skillTable.Select(select);
if (!File.Exists(bmpPath) || forceRecreate)
{
if(!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
//Bitmap classSkillPanel = new Bitmap(_size.Width, _size.Height);
Bitmap classSkillPanel = new Bitmap(_unscaledSize.Width, _unscaledSize.Height);
Graphics g = Graphics.FromImage(classSkillPanel);
g.Clear(Color.Transparent);
Bitmap connectorLns = CreateConnectorLines(skills);
Bitmap generalSkl = CreateGeneralSkills(generalSkills);
Bitmap classSkl = CreateClassSkills(skills);
g.DrawImage(connectorLns, new Point());
g.DrawImage(generalSkl, new Point());
g.DrawImage(classSkl, new Point());
classSkillPanel = ReScaleBitmap(classSkillPanel, 802, 746);
classSkillPanel.Save(bmpPath);
g.Dispose();
}
else
{
CreateGeneralSkills(generalSkills);
CreateClassSkills(skills);
}
return (Bitmap)Bitmap.FromFile(bmpPath);
}
示例11: CreateNode
//�����ڵ�
public void CreateNode(int parentid, Microsoft.Web.UI.WebControls.TreeNode parentnode, DataTable dt)
{
DataRow[] drs = dt.Select("ParentID= " + parentid);//ѡ�������ӽڵ�
foreach (DataRow r in drs)
{
string nodeid = r["NodeID"].ToString();
string text = r["Text"].ToString();
string location = r["Location"].ToString();
string url = r["Url"].ToString();
string imageurl = r["ImageUrl"].ToString();
int permissionid = int.Parse(r["PermissionID"].ToString().Trim());
Microsoft.Web.UI.WebControls.TreeNode node = new Microsoft.Web.UI.WebControls.TreeNode();
node.Text = text + " <a href=\"modify.aspx?id=" + nodeid + "\">��</a> " +
" <a onClick=\"if (!window.confirm('�����Ҫɾ��������¼��')){return false;}\" href=\"delete.aspx?id=" + nodeid + "\">ɾ��</a>" +
" <a href=\"add.aspx?nodeid="+nodeid+"\">���ӽڵ�</a>";
node.NodeData = nodeid;
//node.NavigateUrl = url;
//node.Target = TargetFrame;
node.ImageUrl = "../" + imageurl;
node.Expanded = false;
int sonparentid = int.Parse(nodeid);// or =location
if (parentnode == null)
{
TreeView1.Nodes.Clear();
parentnode = new Microsoft.Web.UI.WebControls.TreeNode();
TreeView1.Nodes.Add(parentnode);
}
parentnode.Nodes.Add(node);
CreateNode(sonparentid, node, dt);
}//endforeach
}
示例12: ExportFilteredDataTableToCsv
public static void ExportFilteredDataTableToCsv(DataTable targetDataTable, string targetFilePath, string filterString)
{
using (System.IO.StreamWriter outFile = new System.IO.StreamWriter(targetFilePath, false, Encoding.UTF8))
{
for (int i = 0; i < targetDataTable.Columns.Count; i++)
{
outFile.Write("\"");
outFile.Write(targetDataTable.Columns[i].ColumnName.Replace("\"", "\"\""));
outFile.Write("\"");
outFile.Write(i == targetDataTable.Columns.Count - 1 ? Environment.NewLine : ",");
}
foreach (DataRow row in targetDataTable.Select(filterString))
{
for (int i = 0; i < targetDataTable.Columns.Count; i++)
{
outFile.Write("\"");
if (targetDataTable.Columns[i].DataType.Equals(typeof(DateTime)))
outFile.Write(FormatDateFullTimeStamp((DateTime)row[i]));
else
outFile.Write(row[i].ToString().Replace("\"", "\"\""));
outFile.Write("\"");
outFile.Write(i == targetDataTable.Columns.Count - 1 ? Environment.NewLine : ",");
}
}
}
}
示例13: btnCompararStock_Click
private void btnCompararStock_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
string Connection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Benja\\Desktop\\libro1.xlsx;Extended Properties=\"Excel 12.0;HDR=YES;IMEX=1\";";
OleDbConnection con = new OleDbConnection(Connection);
System.Data.DataTable tblOriginal = new System.Data.DataTable();
OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [original$]", con);
myCommand.Fill(tblOriginal);
System.Data.DataTable tblModificado = new System.Data.DataTable();
myCommand = new OleDbDataAdapter("select * from [modificado$]", con);
myCommand.Fill(tblModificado);
int contador = 0;
ArrayList miArray = new ArrayList();
foreach (DataRow rowOriginal in tblOriginal.Rows)
{
string articulo = rowOriginal["Articulo"].ToString();
DataRow[] rowfound = tblModificado.Select("Articulo LIKE '" + articulo + "'");
if (rowfound.Count() == 0)
{
miArray.Add(articulo);
}
foreach (DataRow rowModificado in rowfound)
{
string originalMakro = rowOriginal["Makro"].ToString();
string modificadoMakro = rowModificado["Makro"].ToString();
string originalJesus = rowOriginal["Jesus Maria"].ToString();
string modificadoJesus = rowModificado["Jesus Maria"].ToString();
if (originalMakro != modificadoMakro || originalJesus != modificadoJesus)
MessageBox.Show(rowOriginal["Articulo"].ToString());
}
contador++;
}
MessageBox.Show(contador.ToString());
Cursor.Current = Cursors.Arrow;
}
示例14: Select
/// <summary>
/// 獲取表數據
/// </summary>
/// <param name="startIndex">開始的位置(由0開始)</param>
/// <param name="count">要查詢的條數(傳入0為查全部)</param>
/// <param name="select">查詢條件</param>
/// <param name="dt">DataTable數據集</param>
/// <returns>結果集</returns>
public static DataTable Select(int startIndex, int count, string select, DataTable dt)
{
DataRow[] dr = dt.Select(select);
int length = startIndex + count;
DataTable returndt = dt.Clone();
if (count == 0)
{
count = dr.Length;
}
else if (count > dr.Length)
{
count = dr.Length;
}
else if (dr.Length < length)
{
for (int i = startIndex; i < dr.Length; i++)
{
returndt.ImportRow(dr[i]);
}
}
else
{
for (int i = startIndex; i < length; i++)
{
returndt.ImportRow(dr[i]);
}
}
return returndt;
}
示例15: WizardSection_ConfirmButtonClick
protected void WizardSection_ConfirmButtonClick(object sender, EventArgs e)
{
DataTable dtTest = new DataTable();
if (WizardSection.ActiveStep == this.WizardStep2)
{
strSQL = "select b.APTestID,b.Sectionid from AP_SavedTest a ";
strSQL += " join AP_SavedSection b on a.APTestID = b.APTestID ";
strSQL += " and PortfolioID = " + strPID + " and SchoolID = " + SchoolID + " and IsActiveStatus = 1 ";
dtTest = CCLib.Common.DataAccess.GetDataTable(strSQL);
DataRow[] drs = dtTest.Select("SectionID=1");
if (dtTest.Rows.Count == 0)
{
strSQL = "insert into AP_SavedTest(PortfolioID,SchoolID,GradeNumber) values(" + strPID + "," + SchoolID + "," + dtStudent.Rows[0]["GradeNumber"].ToString() + ")";
int intAPTestID = CCLib.Common.DataAccess.ExecuteDbWithIntResult(strSQL + "; select @@identity;");
strTestID = intAPTestID.ToString();
}
else
strTestID = dtTest.Rows[0]["APTestID"].ToString();
if (drs.Length == 0)
{
try
{
strSQL = "insert into AP_SavedSection(SectionID,APTestID,APRegID,StartTime,EndTime,Answers) values(1," + strTestID + ",0,'" + lblDate.Text + " 12:00:00 PM','" + DateTime.Now + "','" + ViewState["Result"].ToString() + "')";
CCLib.Common.DataAccess.ExecuteNonQuery(strSQL);
}
catch (System.Data.SqlClient.SqlException ex)//avoid duplicate records
{
if (ex.Message.IndexOf("Violation of UNIQUE KEY constraint 'un_section'. ") < 0)
throw;
}
if (dtTest.Rows.Count == 5)
{
strSQL = "select SectionID,Answers from AP_SavedSection where APTestID=" + strTestID + " order by SectionID";
dtAnswers = CCLib.Common.DataAccess.GetDataTable(strSQL);
if (dtAnswers.Rows.Count > 0)
{
for (int i = 0; i < dtAnswers.Rows.Count; i++)
{
strAnswers[i] = dtAnswers.Rows[i]["Answers"].ToString();
}
scoTest = new CareerCruisingWeb.CCLib.AbilityProfiler.Score();
scoTest.ScoreTest(strAnswers);
strSQL = "";
for (int j = 0; j < 6; j++)
{
strSQL += "update AP_SavedSection set CorrectAnswers = " + scoTest.CorrectAnswers[j].ToString() + ", ConvertedScore = " + scoTest.ScaledScores[scoTest.SubTestMatchingAbilityNameIndex[j]].ToString() + ", Percentile = " + scoTest.PercentileScores[j].ToString() + " where APTestID=" + strTestID + " and SectionID = " + Convert.ToString(j + 1) + "; ";
}
CCLib.Common.DataAccess.ExecuteNonQuery(strSQL);
}
DataRow drwPCSCriteria = CareerCruisingWeb.CCLib.PCS.SDPCS.GetPCSCriteria(dtStudent.Rows[0]["GradeNumber"].ToString());
DataRow drwPCSStatus = CareerCruisingWeb.CCLib.PCS.SDPCS.GetPCSStatus(strPID, drwPCSCriteria);
CCLib.PCS.SDPCS.UpdatePCSStatusFromSection("AbilityProfiler", strPID, drwPCSCriteria, drwPCSStatus);
}
strURL = "APSpecialResult.aspx?PP=1&PID=" + strPID;
Response.Write("<script language='javascript'>alert('Your changes have been saved.');location.href='" + strURL + "';</script>");
}
else
Response.Write("<script language='javascript'>alert('There is already an instance of the Ability Profiler associated with your account.');</script>");
}
}