public HtmlTable htbDisplayVerticalData(string strQuery) { HtmlTable htbReturn = new HtmlTable(); HtmlTableRow htrRow = new HtmlTableRow(); string strValue = ""; if (objDB.blnOpenResultSet(strQuery) == true) { while (objDB.blnResultsMoveNextRow() == true) { for (int intCount = 0; intCount < arlColumns.Count; intCount++) { htrRow = new HtmlTableRow(); udsColumns objC = (udsColumns)arlColumns[intCount]; HtmlTableCell htcCell = new HtmlTableCell(); htcCell.InnerText = objC.strHeaderText; htcCell.ID = "tc_" + objC.strHeaderText; htcCell.Attributes.Add("class", objC.strHeaderClass); htcCell.Attributes.Add("style", "text-align:left"); htrRow.Controls.Add(htcCell); strValue = objDB.objResultsValue(objC.strColumnName).ToString(); string strBackgroundColor; double dblToAdd = 0; if (objDB.objResultsValue("BackgroundColor") == null) { strBackgroundColor = "#FFFFFF"; } else { strBackgroundColor = objDB.objResultsValue("BackgroundColor").ToString(); } switch (objC.strTotal) { case "S": dblToAdd = double.Parse(objDB.objResultsValue(objC.strColumnName).ToString()); break; case "C": dblToAdd = 1; break; } arrTotals[intCount] = arrTotals[intCount] + dblToAdd; if (strValue == "") { strValue = " "; } htrRow.Controls.Add(htcDisplayRecords(strValue, objC.strDataType, objC.strFormat, objC.strColumnClass, objC.strAlign)); htrRow.BgColor = strBackgroundColor; htrRow.Attributes.Add("onmouseover", "this.style.backgroundColor='#CCCCCC';"); htrRow.Attributes.Add("onmouseout", "this.style.backgroundColor='" + strBackgroundColor + "';"); htbReturn.Controls.Add(htrRow); } } } objDB.blnCloseConnection(); return(htbReturn); }
public static string strGetData(string strArrayName, string strSQL) { clsDBEngine objDB = new clsDBEngine(); string strLine = "", strReturnData = ""; int intLineCount = 0; strLine = "var " + strArrayName + " = new Array();\n"; strReturnData += strLine; if (objDB.blnOpenResultSet(strSQL) == true) { while (objDB.blnResultsMoveNextRow() == true) { strLine = ""; for (int intCount = 0; intCount < objDB.lngResultsNumCols; intCount++) { if (strLine.Length > 0) { strLine += ", "; } string strValue = strConvertForJavaScript(objDB.objResultsValue(intCount).ToString()); strLine += "'" + strValue + "'"; } if (objDB.lngResultsNumCols > 1) { strLine = strArrayName + "[" + intLineCount + "] = new Array(" + strLine + ");\n"; } else { strLine = strArrayName + "[" + intLineCount + "] = " + strLine + ";\n"; } strReturnData += strLine; intLineCount++; } } else { clsLog.blnLogError("clsMisc", "strGetData(" + strArrayName + ")", "SQL Failed : " + strSQL, objDB.strErrorMessage); } objDB.blnCloseConnection(); return(strReturnData); }
internal static bool blnGenerateimintSettlementFile(out long lngimintUpdateStamp) { const string udcErrorMethod = "blnGenerateimintSettlementFile"; string udcMerchantId = clsSettings.Get("IMINT", "MerchantId", "90009796"); string udcTerminalId = clsSettings.Get("IMINT", "TerminalId", "64211677"); const string udcActionCode = "EARN"; //const string udcClassificationCode = "CASH_CASH"; const string udcPaymentType = "CASH"; const string udcUnits = "AMOUNT"; const string udcHasSKUActivity = "0"; lngimintUpdateStamp = 0; try { if (System.IO.Directory.Exists(strFolder) == false) { System.IO.Directory.CreateDirectory(strFolder); } } catch (Exception ex) { clsLog.blnLogError(udcErrorSource, udcErrorMethod, "Error creating imint Directory : " + strFolder, ex.ToString()); return(false); } string strFileName = "", strSettlementDate = ""; ArrayList arlSettlement = new ArrayList(); ArrayList arlPaymentId = new ArrayList(); clsDBEngine objDB = new clsDBEngine(); StreamWriter stwSettlement; System.Text.StringBuilder sbrData; string strSQL = "EXECUTE spGetDataForIMINT"; if (objDB.blnOpenResultSet(strSQL) == true) { if (objDB.blnHasRecords == true) { strSettlementDate = DateTime.Now.ToString("ddMMyyyy"); } while (objDB.blnResultsMoveNextRow() == true) { if (objDB.objResultsValue("Trans_MemberType").ToString() == "IMINT") { sbrData = new System.Text.StringBuilder(); sbrData.Append(objDB.objResultsValue("Trans_MemberNo").ToString() + "|"); sbrData.Append("|||"); sbrData.Append(udcMerchantId + "|"); sbrData.Append("|"); sbrData.Append(udcTerminalId + "|"); sbrData.Append("|"); sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "|")); sbrData.Append("||"); sbrData.Append(udcActionCode + "|"); //sbrData.Append(udcClassificationCode + "|"); sbrData.Append(objDB.objResultsValue("Trans_strIMINTEventType").ToString() + "|"); sbrData.Append("||"); sbrData.Append(udcPaymentType + "|"); sbrData.Append(objDB.objResultsValue("Trans_strDate").ToString() + "|"); sbrData.Append("|"); sbrData.Append(float.Parse(objDB.objResultsValue("Trans_mnyTotal").ToString()).ToString("#") + "|"); sbrData.Append(udcUnits + "|"); sbrData.Append("||"); sbrData.Append(udcHasSKUActivity + "|"); sbrData.Append(strSettlementDate + "|"); sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "|")); sbrData.Append("|||"); sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "|")); sbrData.Append("||||||||"); arlSettlement.Add(sbrData); } else if (objDB.objResultsValue("Trans_MemberType").ToString() == "PB_SAM") { //Add Payback Samsung Base points sbrData = new System.Text.StringBuilder(); sbrData.Append(objDB.objResultsValue("Trans_MemberNo").ToString() + "|"); sbrData.Append("|||"); sbrData.Append(udcMerchantId + "|"); sbrData.Append("|"); sbrData.Append(udcTerminalId + "|"); sbrData.Append("|"); sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "|")); sbrData.Append("||"); sbrData.Append(udcActionCode + "|"); sbrData.Append(objDB.objResultsValue("Trans_strIMINTEventType").ToString() + "|"); sbrData.Append("||"); sbrData.Append(udcPaymentType + "|"); sbrData.Append(objDB.objResultsValue("Trans_strDate").ToString() + "|"); sbrData.Append("|"); sbrData.Append(float.Parse(objDB.objResultsValue("Trans_mnyTotal").ToString()).ToString("#") + "|"); sbrData.Append(udcUnits + "|"); sbrData.Append("||"); sbrData.Append(udcHasSKUActivity + "|"); sbrData.Append(strSettlementDate + "|"); sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "_Samsung_base_point|")); sbrData.Append("|||"); sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "|")); sbrData.Append("||||||||"); arlSettlement.Add(sbrData); //Add Payback Samsung 2X points sbrData = new System.Text.StringBuilder(); sbrData.Append(objDB.objResultsValue("Trans_MemberNo").ToString() + "|"); sbrData.Append("|||"); sbrData.Append(udcMerchantId + "|"); sbrData.Append("|"); sbrData.Append(udcTerminalId + "|"); sbrData.Append("|"); sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "|")); sbrData.Append("||"); sbrData.Append(udcActionCode + "|"); //sbrData.Append(udcClassificationCode + "|"); sbrData.Append("BONUS_POINTS|"); sbrData.Append("||"); sbrData.Append(udcPaymentType + "|"); sbrData.Append(objDB.objResultsValue("Trans_strDate").ToString() + "|"); sbrData.Append("|"); sbrData.Append(float.Parse(objDB.objResultsValue("Trans_mnyTotal").ToString()).ToString("#") + "|"); sbrData.Append(udcUnits + "|"); sbrData.Append("||"); sbrData.Append(udcHasSKUActivity + "|"); sbrData.Append(strSettlementDate + "|"); sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "_Samsung_bonus_point|")); sbrData.Append("|||"); sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "|")); sbrData.Append("||||||||"); arlSettlement.Add(sbrData); } } objDB.blnMoveNextResultSet(); objDB.blnResultsMoveNextRow(); lngimintUpdateStamp = long.Parse(objDB.objResultsValue("Trans_intUpdateStamp").ToString()); if (strSettlementDate.Length > 0) { strFileName = strFolder + "ACTIVITY_IMINT_BIGTREE_" + strSettlementDate + ".txt"; } } else { objDB.blnCloseConnection(); clsLog.blnLogError(udcErrorSource, udcErrorMethod, "Error fetching imint Settlement Data from DB", objDB.strErrorMessage); return(false); } objDB.blnCloseConnection(); if (strFileName.Length > 0) { try { stwSettlement = new StreamWriter(strFileName, false); for (int intCount = 0; intCount < arlSettlement.Count; intCount++) { stwSettlement.WriteLine(arlSettlement[intCount].ToString()); } stwSettlement.Close(); stwSettlement = null; } catch (Exception ex) { stwSettlement = null; clsLog.blnLogError(udcErrorSource, udcErrorMethod, "Error creating imint Settlement File", ex.ToString()); return(false); } } return(true); }
public HtmlTable htbDisplayData(string strQuery, string strWidth) { HtmlTable htbReturn = new HtmlTable(); HtmlTableRow htrRow = new HtmlTableRow(); bool blnDisplayHeader = false; string strValue = ""; int intRowCount = 0; if (strWidth != "") { htbReturn.Style.Add("width", strWidth); } for (int intCount = 0; intCount < arlColumns.Count; intCount++) { udsColumns objC = (udsColumns)arlColumns[intCount]; if (objC.strHeaderText.Length > 0) { blnDisplayHeader = true; break; } } if (blnDisplayHeader == true) { for (int intCount = 0; intCount < arlColumns.Count; intCount++) { udsColumns objC = (udsColumns)arlColumns[intCount]; HtmlTableCell htcCell = new HtmlTableCell(); htcCell.InnerText = objC.strHeaderText; htcCell.ID = "tc_" + objC.strHeaderText; htcCell.Attributes.Add("class", objC.strHeaderClass); htcCell.Attributes.Add("style", "text-align:center"); htrRow.Controls.Add(htcCell); } htbReturn.Controls.Add(htrRow); } if (objDB.blnOpenResultSet(strQuery) == true) { if (objDB.blnHasRecords == false) { htrRow = new HtmlTableRow(); HtmlTableCell tdCell = new HtmlTableCell(); tdCell.InnerText = "----------------NO RECORD FOUND----------------------"; tdCell.ColSpan = arlColumns.Count; tdCell.Attributes.Add("style", "text-align:center;color:#FF0000"); htrRow.Controls.Add(tdCell); htbReturn.Controls.Add(htrRow); return(htbReturn); } while (objDB.blnResultsMoveNextRow() == true) { intRowCount++; htrRow = new HtmlTableRow(); for (int intCount = 0; intCount < arlColumns.Count; intCount++) { udsColumns objC = (udsColumns)arlColumns[intCount]; strValue = objDB.objResultsValue(objC.strColumnName).ToString(); string strBackgroundColor; double dblToAdd = 0; if (objDB.strResultsColName(0) != "BackgroundColor") { strBackgroundColor = "#FFFFFF"; } else { strBackgroundColor = objDB.objResultsValue("BackgroundColor").ToString(); } switch (objC.strTotal) { case "S": dblToAdd = double.Parse(objDB.objResultsValue(objC.strColumnName).ToString()); break; case "C": dblToAdd = 1; break; case "A": dblToAdd = double.Parse(objDB.objResultsValue(objC.strColumnName).ToString()); break; } arrTotals[intCount] = arrTotals[intCount] + dblToAdd; if (strValue == "") { strValue = " "; } htrRow.Controls.Add(htcDisplayRecords(strValue, objC.strDataType, objC.strFormat, objC.strColumnClass, objC.strAlign)); htrRow.BgColor = strBackgroundColor; htrRow.Attributes.Add("onmouseover", "this.style.backgroundColor='#CCCCCC';"); htrRow.Attributes.Add("onmouseout", "this.style.backgroundColor='" + strBackgroundColor + "';"); } htbReturn.Controls.Add(htrRow); } } objDB.blnCloseConnection(); if (blnDisplayTotals == true) { htrRow = new HtmlTableRow(); for (int intCount = 0; intCount < arlColumns.Count; intCount++) { udsColumns objC = (udsColumns)arlColumns[intCount]; HtmlTableCell htcCell = new HtmlTableCell(); switch (objC.strTotal) { case "S": strValue = arrTotals[intCount].ToString(objC.strFormat); break; case "C": strValue = arrTotals[intCount].ToString(objC.strFormat); break; case "A": strValue = ((arrTotals[intCount]) / (intRowCount)).ToString(objC.strFormat); break; default: strValue = " "; break; } if (intCount == 0) { strValue = "Total : "; } htcCell.InnerHtml = strValue; htcCell.ID = "tc_" + objC.strColumnName; htcCell.Attributes.Add("class", objC.strHeaderClass); htcCell.Attributes.Add("style", "text-align:center"); htrRow.Controls.Add(htcCell); } htbReturn.Controls.Add(htrRow); } return(htbReturn); }
/// <summary> /// Execute the sp and return collection of array the contain companies, cinemas, events and session data for given User /// </summary> /// <param name="strUserLogin"></param> /// <returns></returns> public static string strGetData(string strUserLogin) { clsDBEngine objDB = new clsDBEngine(); string strSQL = "EXEC spForUserData @strUserLogin = '******'"; string strLine = "", strReturnData = ""; int intLineCount = 0; string strArrayName = "arrcompanies"; strLine = "<script type='text/javascript' language='javascript'>"; strLine += "var " + strArrayName + " = new Array();\n"; strReturnData += strLine; if (objDB.blnOpenResultSet(strSQL) == true) { while (objDB.blnResultsMoveNextRow() == true) { strLine = ""; for (int intCount = 0; intCount < objDB.lngResultsNumCols; intCount++) { if (strLine.Length > 0) { strLine += ", "; } string strValue = strConvertForJavaScript(objDB.objResultsValue(intCount).ToString()); strLine += "'" + strValue + "'"; } if (objDB.lngResultsNumCols > 1) { strLine = strArrayName + "[" + intLineCount + "] = new Array(" + strLine + ");\n"; } else { strLine = strArrayName + "[" + intLineCount + "] = " + strLine + ";\n"; } strReturnData += strLine; intLineCount++; } } //For Cinema if (objDB.blnMoveNextResultSet()) { intLineCount = 0; string arrCinema = "arrCinemas"; strReturnData += "var " + arrCinema + " = new Array();\n"; while (objDB.blnResultsMoveNextRow() == true) { strLine = ""; for (int intCount = 0; intCount < objDB.lngResultsNumCols; intCount++) { if (strLine.Length > 0) { strLine += ", "; } string strValue = strConvertForJavaScript(objDB.objResultsValue(intCount).ToString()); strLine += "'" + strValue + "'"; } if (objDB.lngResultsNumCols > 1) { strLine = arrCinema + "[" + intLineCount + "] = new Array(" + strLine + ");\n"; } else { strLine = arrCinema + "[" + intLineCount + "] = " + strLine + ";\n"; } strReturnData += strLine; intLineCount++; } } if (objDB.blnMoveNextResultSet()) { intLineCount = 0; string arrEvents = "arrEvents"; strReturnData += "var " + arrEvents + " = new Array();\n"; while (objDB.blnResultsMoveNextRow() == true) { strLine = ""; for (int intCount = 0; intCount < objDB.lngResultsNumCols; intCount++) { if (strLine.Length > 0) { strLine += ", "; } string strValue = strConvertForJavaScript(objDB.objResultsValue(intCount).ToString()); strLine += "'" + strValue + "'"; } if (objDB.lngResultsNumCols > 1) { strLine = arrEvents + "[" + intLineCount + "] = new Array(" + strLine + ");\n"; } else { strLine = arrEvents + "[" + intLineCount + "] = " + strLine + ";\n"; } strReturnData += strLine; intLineCount++; } } if (objDB.blnMoveNextResultSet()) { intLineCount = 0; string arrSession = "arrSessions"; strReturnData += "var " + arrSession + " = new Array();\n"; while (objDB.blnResultsMoveNextRow() == true) { strLine = ""; for (int intCount = 0; intCount < objDB.lngResultsNumCols; intCount++) { if (strLine.Length > 0) { strLine += ", "; } string strValue = strConvertForJavaScript(objDB.objResultsValue(intCount).ToString()); strLine += "'" + strValue + "'"; } if (objDB.lngResultsNumCols > 1) { strLine = arrSession + "[" + intLineCount + "] = new Array(" + strLine + ");\n"; } else { strLine = arrSession + "[" + intLineCount + "] = " + strLine + ";\n"; } strReturnData += strLine; intLineCount++; } } else { clsLog.blnLogError("clsMisc", "strGetData()", "SQL Failed : " + strSQL, objDB.strErrorMessage); } strReturnData += "</script>"; objDB.blnCloseConnection(); return(strReturnData); }