Php Problem with mysql_query() - authentication

I've been having problems with my php code. I seem to be getting an error from #mysql_query().
Here's my code for php:
<?php
// A simple PHP script demonstrating how to connect to MySQL.
// Press the 'Run' button on the top to start the web server,
// then click the URL that is emitted to the Output tab of the console.
$servername = getenv('IP');
$username = getenv('C9_USER');
$passwordp = "";
$database = "game_database";
$dbport = 3306;
// Create connection
mysql_connect($servername, $username, $passwordp, $dbport)or die("Cant Connect to server");
mysql_select_db($database) or die("Cant connect to database");
// Check connection
$Email = $_REQUEST["Email"];
$Password= $_REQUEST["Password"];
if (!$Email || !$Password){
echo"Email or password must be used";
}
else{
$SQL = "SELECT * FROM 'users' WHERE Email = '" . $Email ."'";
$result_id = #mysql_query($SQL) or die("Database Error");
$Total = mysql_num_rows($result_id);
if ($Total){
$datas = #mysql_fetch_array($result_id);
if (strcmp($Password, $datas["Password"])){
$sql2 = "SELECT Characters FROM users WHERE Email = '" . $Email ."'";
$result_id2 = #mysql_query($sql2) or die("Database Error!!!");
while ($row = mysql_fetch_array($result_id2)){
echo $row ["Characters"];
echo ":";
echo "Success";
}
}
else{
echo "WrongPassword";
}
}else {
echo "NameDoesNotExist";
}
}
?>
Here's my code for C#:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class LoginScript : MonoBehaviour {
#region Variables
//Static Variables
public static string Email = "";
public static string Password = "";
//Private Variables
private string createAccountUrl = "https://credmanager-rowanharley.c9.io/createaccount.php";
private string loginUrl = "https://credmanager-rowanharley.c9.io/loginaccount.php";
private string ConfirmPass= "";
private string CreateEmail = "";
private string CreatePassword = "";
//Public Variables
public string currentMenu = "Login";
//GUI test section
public float X;
public float Y;
public float Width;
public float Height;
#endregion
// Use this for initialization
void Start () {
}
void OnGUI(){
//If current menu is = login call login screen
if (currentMenu == "Login"){
LoginGUI();
}
//If current menu is = Create Account call CreateAccount screen
else if(currentMenu == "CreateAccount"){
CreateAccountGUI();
}
}
//This method will login to accounts
void LoginGUI(){
GUI.Box (new Rect (210, 15, 300, 300), "Login");
if (GUI.Button (new Rect (250, 275, 105, 35), "Register Now!!!")) {
currentMenu = "CreateAccount";
}
if (GUI.Button (new Rect (370, 275, 105, 35), "Login!")) {
StartCoroutine(LoginAccount());
}
GUI.Label(new Rect(225, 55, 290, 100), "Before Continuing you need to login or register.");
GUI.Label(new Rect(215, 102, 100, 100), "Email:");
Email = GUI.TextField (new Rect (330, 100, 150, 25), Email);
GUI.Label(new Rect(215, 150, 100, 100), "Password:");
Password = GUI.TextField (new Rect (330, 147, 150, 25), Password);
}
void CreateAccountGUI(){
GUI.Box (new Rect (210, 15, 300, 300), "Register to save progress");
if (GUI.Button (new Rect (250, 275, 105, 35), "Back")) {
currentMenu = "Login";
}
GUI.Label(new Rect(225, 55, 290, 100), "Register NOW!!!");
GUI.Label(new Rect(215, 102, 100, 100), "Email:");
CreateEmail = GUI.TextField (new Rect (330, 100, 150, 25), CreateEmail);
GUI.Label(new Rect(215, 150, 100, 100), "Password:");
CreatePassword = GUI.TextField (new Rect (330, 147, 150, 25), CreatePassword);
GUI.Label(new Rect(215, 198, 122, 100), "Confirm Password:");
ConfirmPass = GUI.TextField (new Rect (330, 194, 150, 25), ConfirmPass);
GUI.Box (new Rect (210, 15, 300, 300), "Register to save progress");
if (GUI.Button (new Rect (250, 275, 105, 35), "Back")) {
currentMenu = "Login";
}
if (GUI.Button (new Rect (370, 275, 105, 35), "Create Account")) {
if (CreatePassword == ConfirmPass){
StartCoroutine("CreateAccount");
}
else{
Debug.Log("Both Passwords are not the same");
}
}
}
IEnumerator CreateAccount(){
//this sends info to php form
WWWForm CreateAccountForm = new WWWForm ();
CreateAccountForm.AddField ("Email", CreateEmail);
CreateAccountForm.AddField ("Password", CreatePassword);
WWW CreateAccountWWW = new WWW (createAccountUrl, CreateAccountForm);
yield return CreateAccountWWW;
if (CreateAccountWWW.error != null) {
Debug.LogError ("Failed to Create Account. Is Internet On? Is URL Correct? Error Message: " + CreateAccountWWW.error);
} else {
string CreateAccountReturn = CreateAccountWWW.text;
Debug.Log("Successfully Created Account " + CreateEmail);
Application.LoadLevel("MainScene");
}
}
IEnumerator LoginAccount(){
Debug.Log ("Attempting to login...");
WWWForm Form = new WWWForm ();
Form.AddField ("Email", Email);
Form.AddField ("Password", Password);
WWW LoginAccountWWW = new WWW (loginUrl, Form);
yield return LoginAccountWWW;
if (LoginAccountWWW.error != null) {
Debug.LogError("Problem with Database. Error Message: " + LoginAccountWWW.error);
}
else {
string LogText = LoginAccountWWW.text;
Debug.Log(LogText);
string[] LogTextSplit = LogText.Split(':');
if (LogTextSplit[1] == "Success"){
Application.LoadLevel("MainScene");
}
}
}
}
When I press play from unity editor I get error: "Database Error" from #mysql_query() on $result_id.

use query string as format like this
"SELECT m.name FROM test.members WHERE name=%s OR id=%d OR sex IN (%a)", "Evil 'injection'", 'NaN', array('male', 'female', 'both', 'other', "Alien quote'man"));

Related

Ogmo Tilemap not showing in the game

So I am doing the haxe flixel TurnBasedRPG tutorial
I am pretty much a noob so I wont be surprised if this is just a stupid mistake I did.
But when I try to put my ogmo tilemap into the game, it doesnt show
Here is my Playstate.hx file
package;
import flixel.FlxG;
import flixel.FlxState;
import flixel.addons.editors.ogmo.FlxOgmo3Loader.EntityData;
import flixel.addons.editors.ogmo.FlxOgmo3Loader;
import flixel.tile.FlxTilemap;
class PlayState extends FlxState
{
var player:Player;
var map:FlxOgmo3Loader;
var walls:FlxTilemap;
override public function create()
{
map = new FlxOgmo3Loader(AssetPaths.HaxeFlixel_Tutorial__ogmo, AssetPaths.level_1__json);
walls = map.loadTilemap(AssetPaths.tiles__png, "walls");
walls.follow();
walls.setTileProperties(1, NONE);
walls.setTileProperties(2, ANY);
player = new Player();
map.loadEntities(placeEntities, "entities");
add(walls);
add(player);
super.create();
}
function placeEntities(entity:EntityData)
{
if (entity.name == "player")
{
player.setPosition(entity.x, entity.y);
}
}
override public function update(elapsed:Float)
{
super.update(elapsed);
FlxG.collide(player, walls);
}
}
Player.hx:
package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.math.FlxPoint;
import flixel.util.FlxColor;
class Player extends FlxSprite
{
static inline var SPEED:Float = 200;
public function new(x:Float = 0, y:Float = 0)
{
super(x, y);
loadGraphic(AssetPaths.player__png, true, 16, 16);
drag.x = drag.y = 1600;
setSize(8, 8);
offset.set(4, 4);
setFacingFlip(LEFT, false, false);
setFacingFlip(RIGHT, true, false);
animation.add("lr", [3, 4, 3, 5], 6, false);
animation.add("u", [6, 7, 6, 8], 6, false);
animation.add("d", [0, 1, 0, 2], 6, false);
}
function updateMovement()
{
var up:Bool = false;
var down:Bool = false;
var left:Bool = false;
var right:Bool = false;
var newAngle:Float = 0;
right = FlxG.keys.anyPressed([RIGHT, D]);
down = FlxG.keys.anyPressed([DOWN, S]);
left = FlxG.keys.anyPressed([LEFT, A]);
up = FlxG.keys.anyPressed([UP, W]);
if (up || down || left || right)
{
if (up && down)
{
up = down = false;
}
if (left && right)
{
left = right = false;
}
if (up)
{
newAngle = -90;
if (left)
newAngle -= 45;
else if (right)
newAngle += 45;
facing = UP;
}
else if (down)
{
newAngle = 90;
if (left)
newAngle += 45;
else if (right)
newAngle -= 45;
facing = DOWN;
}
else if (left)
{
newAngle = 180;
facing = LEFT;
}
else if (right)
{
newAngle = 0;
facing = RIGHT;
}
// determine our velocity based on angle and speed
velocity.set(SPEED, 0);
velocity.rotate(FlxPoint.weak(0, 0), newAngle);
// if the player is moving (velocity is not 0 for either axis), we need to change the animation to match their facing
if ((velocity.x != 0 || velocity.y != 0) && touching == NONE)
{
switch (facing)
{
case LEFT, RIGHT:
animation.play("lr");
case UP:
animation.play("u");
case DOWN:
animation.play("d");
case _:
}
}
}
}
override function update(elapsed:Float)
{
updateMovement();
super.update(elapsed);
}
}
If you want to see any other file please ask me because I have been stuck on this for 3 hours now

how fex eror in regestration laravel 8

public_html/core/app/Http/Controllers/Advertiser/Auth/RegisterController.php (line 64)
public function showRegistrationForm()
{
$page_title = "Advertiser Sign Up";
$info = json_decode(json_encode(getIpInfo()), true);
$country_code = #implode(',', $info['code']);
return view($this->activeTemplate . 'advertiser.auth.register', compact('page_title','country_code'));
}

Processing is not communicating with Arduino Uno and the console is spouting garbage

I'm working on making a small G4P GUI as test for Arduino communication.
Control Panel
So it’s just basic: when X button is pressed, send Y to the console, and the Arduino does whatever with Y, but the Processing console is just full of garbage.
The trash
Arduino wiring
Here is the code for the Arduino:
int rLED = 7;
int gLED = 8;
int R = 11;
int G = 12;
int B = 13;
void setup() {
pinMode(rLED, OUTPUT);
pinMode(gLED, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
char state = Serial.read();
if(state == '1')
{
digitalWrite (rLED, HIGH);
}
if(state == '2')
{
digitalWrite (rLED, LOW);
}
if(state == '3')
{
digitalWrite (gLED, HIGH);
}
if(state == '4')
{
digitalWrite (gLED, LOW);
}
}
}
Here is the code for Processing:
import processing.serial.*;
// Need G4P library
import g4p_controls.*;
Serial myPort;
public void setup() {
size(480, 320, JAVA2D);
createGUI();
customGUI();
// Place your setup code here
myPort = new Serial(this, "COM4", 9600);
}
public void draw() {
background(230);
}
public void handleButtonEvents(GButton button, GEvent event) {
if (button == rLED && event == GEvent.CLICKED) {
myPort.write('1');
delay(100);
myPort.write('2');
}
if (button == button1 && event == GEvent.CLICKED) {
myPort.write('3');
delay(100);
myPort.write('4');
}
}
// Use this method to add additional statements
// to customise the GUI controls
public void customGUI() {
}
Here is the code for the GUI (Processing):
public void Red_Blink(GButton source, GEvent event) { // _CODE_:rLED:951221:
println("rLED - GButton >> GEvent." + event + " # " + millis());
} // _CODE_:rLED:951221:
public void Green_Blink(GButton source, GEvent event) { // _CODE_:button1:443069:
println("button1 - GButton >> GEvent." + event + " # " + millis());
} // _CODE_:button1:443069:
public void Red_int(GCustomSlider source, GEvent event) { // _CODE_:Red:702179:
println("custom_slider1 - GCustomSlider >> GEvent." + event + " # " + millis());
} // _CODE_:Red:702179:
public void Green_int(GCustomSlider source, GEvent event) { // _CODE_:Green:645891:
println("custom_slider2 - GCustomSlider >> GEvent." + event + " # " + millis());
} // _CODE_:Green:645891:
public void Blue_int(GCustomSlider source, GEvent event) { // _CODE_:Blue:372420:
println("Blue - GCustomSlider >> GEvent." + event + " # " + millis());
} // _CODE_:Blue:372420:
// Create all the GUI controls.
// autogenerated do not edit
public void createGUI() {
G4P.messagesEnabled(false);
G4P.setGlobalColorScheme(GCScheme.GOLD_SCHEME);
G4P.setCursor(ARROW);
surface.setTitle("Controll panel ");
tittle = new GLabel(this, 180, 10, 150, 30);
tittle.setTextAlign(GAlign.CENTER, GAlign.MIDDLE);
tittle.setText("Controll arduino");
tittle.setTextBold();
tittle.setLocalColorScheme(GCScheme.BLUE_SCHEME);
tittle.setOpaque(false);
rLED = new GButton(this, 60, 80, 80, 30);
rLED.setText("blink red LED");
rLED.setLocalColorScheme(GCScheme.RED_SCHEME);
rLED.addEventHandler(this, "Red_Blink");
button1 = new GButton(this, 150, 80, 80, 30);
button1.setText("blink greed LED");
button1.setLocalColorScheme(GCScheme.GREEN_SCHEME);
button1.addEventHandler(this, "Green_Blink");
Red = new GCustomSlider(this, 20, 140, 440, 40, "grey_blue");
Red.setShowValue(true);
Red.setLimits(150, 0, 255);
Red.setNumberFormat(G4P.INTEGER, 0);
Red.setLocalColorScheme(GCScheme.RED_SCHEME);
Red.setOpaque(false);
Red.addEventHandler(this, "Red_int");
Green = new GCustomSlider(this, 18, 200, 440, 40, "grey_blue");
Green.setShowValue(true);
Green.setLimits(50, 0, 255);
Green.setNumberFormat(G4P.INTEGER, 0);
Green.setLocalColorScheme(GCScheme.GREEN_SCHEME);
Green.setOpaque(false);
Green.addEventHandler(this, "Green_int");
label1 = new GLabel(this, 200, 130, 80, 20);
label1.setTextAlign(GAlign.CENTER, GAlign.MIDDLE);
label1.setText("Red");
label1.setLocalColorScheme(GCScheme.BLUE_SCHEME);
label1.setOpaque(false);
label2 = new GLabel(this, 200, 190, 80, 20);
label2.setTextAlign(GAlign.CENTER, GAlign.MIDDLE);
label2.setText("Green");
label2.setLocalColorScheme(GCScheme.BLUE_SCHEME);
label2.setOpaque(false);
Blue = new GCustomSlider(this, 20, 260, 440, 40, "grey_blue");
Blue.setShowValue(true);
Blue.setLimits(150, 0, 255);
Blue.setNumberFormat(G4P.INTEGER, 0);
Blue.setLocalColorScheme(GCScheme.BLUE_SCHEME);
Blue.setOpaque(false);
Blue.addEventHandler(this, "Blue_int");
label3 = new GLabel(this, 200, 250, 80, 20);
label3.setTextAlign(GAlign.CENTER, GAlign.MIDDLE);
label3.setText("Blue");
label3.setLocalColorScheme(GCScheme.BLUE_SCHEME);
label3.setOpaque(false);
}
// Variable declarations
// autogenerated do not edit
GLabel tittle;
GButton rLED;
GButton button1;
GCustomSlider Red;
GCustomSlider Green;
GLabel label1;
GLabel label2;
GCustomSlider Blue;
GLabel label3;
The problem seems to be in the Processing code in the setup() function.
Try this:
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600);

Instagram & Processing - Real time view

I'm working on a small app similar to instaprint and need some help. I'm using the source code from Globalgram by Andrew Haskin, it searches instagram for a particular hashtag and displays the most recent image posted with that hashtag. The problem is it only does it once, I need it to continuously search for the hashtag and display an image when a new one is added, so a refresh, I've been tinkering with it but to no avail. Any help would be greatly appreciated
Code Below :
import com.francisli.processing.http.*;
PFont InstagramFont;
PImage backgroundimg;
PImage brand;
PImage userphoto;
PImage profilepicture;
String username;
String tag;
String[] tagStrings;
com.francisli.processing.http.HttpClient client;
void setup() {
size(580, 900);
smooth();
backgroundimg = loadImage("iso_background.jpg");
brand = loadImage("iso.jpg");
InstagramFont = loadFont("Helvetica-Bold-36.vlw");
client = new com.francisli.processing.http.HttpClient(this, "api.instagram.com");
client.useSSL = true;
//// instantiate a new HashMap
HashMap params = new HashMap();
//// put key/value pairs that you want to send in the request
params.put("access_token", "------ACCESS TOKEN HERE------");
params.put("count", "1");
client.GET("/v1/tags/coffee/media/recent.json", params);
}
void responseReceived(com.francisli.processing.http.HttpRequest request, com.francisli.processing.http.HttpResponse response) {
println(response.getContentAsString());
//// we get the server response as a JSON object
com.francisli.processing.http.JSONObject content = response.getContentAsJSONObject();
//// get the "data" value, which is an array
com.francisli.processing.http.JSONObject data = content.get("data");
//// get the first element in the array
com.francisli.processing.http.JSONObject first = data.get(0);
//// the "user" value is another dictionary, from which we can get the "full_name" string value
println(first.get("user").get("full_name").stringValue());
//// the "caption" value is another dictionary, from which we can get the "text" string value
//println(first.get("caption").get("text").stringValue());
//// get profile picture
println(first.get("user").get("profile_picture").stringValue());
//// the "images" value is another dictionary, from which we can get different image URL data
println(first.get("images").get("standard_resolution").get("url").stringValue());
com.francisli.processing.http.JSONObject tags = first.get("tags");
tagStrings = new String[tags.size()];
for (int i = 0; i < tags.size(); i++) {
tagStrings[i] = tags.get(i).stringValue();
}
username = first.get("user").get("full_name").stringValue();
String profilepicture_url = first.get("user").get("profile_picture").stringValue();
profilepicture = loadImage(profilepicture_url, "png");
String userphoto_url = first.get("images").get("standard_resolution").get("url").stringValue();
userphoto = loadImage(userphoto_url, "png");
//noLoop();
}
void draw() {
background(255);
imageMode(CENTER);
image(brand, 100, height/1.05);
if (profilepicture != null) {
image(profilepicture, 60, 70, 90, 90);
}
imageMode(CENTER);
if (userphoto != null) {
image(userphoto, width/2, height/2.25, 550, 550);
}
textFont(InstagramFont, 20);
if (username != null) {
text(username, 110, 115);
fill(0);
}
textFont(InstagramFont, 15);
if ((tagStrings != null) && (tagStrings.length > 0)) {
String line = tagStrings[0];
for (int i = 1; i < tagStrings.length; i++) {
line += ", " + tagStrings[i];
}
text(line, 25, 720, 550, 50);
fill(0);
}
}
AFAIK it should be the
client.GET("/v1/tags/coffee/media/recent.json", params);
line that actually polls Instagram. Try wrapping that in a function like this:
void getGrams() {
client.GET("/v1/tags/coffee/media/recent.json", params);
}
then call that once in setup() and then again when you want to ...
I'd start with trying to do it on mousePressed() or keyPressed(), so that it only fires once when you really want it to
Don't try to do it in draw() without a timer (something like if(frameCount % 5000 == 0) which will fire every five seconds ((which may be too fast still but you get the idea))

Gridview_RowEditing empty values

I have a gridview control that i am manually binding the data in. When i edit a row and update it the values of the text boxes that are sent are always the Old Values. I've found a few threads on this but have not had any luck extracting the new values.
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>
Private Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
Dim gv As GridView = sender
For i As Integer = 0 To gv.Columns.Count Step 1
Dim cell As DataControlFieldCell = gv.Rows(e.RowIndex).Cells(i)
gv.Columns(0).ExtractValuesFromCell(e.NewValues, cell, DataControlRowState.Edit, True)
Next
For Each s As DictionaryEntry In e.NewValues
Debug.Print(s.Key & " | " & s.Value)
Next
ds.Tables("testTable").Rows(e.RowIndex).BeginEdit()
[ ... ]
ds.Tables("testTable").Rows(e.RowIndex).EndEdit()
GridView1.EditIndex = -1
BindData()
End Sub
I also want to point out that the ExtractValuesFromCell code is just my most recent attempt to get the New Data. Prior to that i was using something like this
Dim tb as TextBox = sender.Rows(e.RowIndex).Cells(1).Controls(0)
Label1.Text = tb.Text
Also here is how the data looks to start
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (ds.Tables.Count = 0) Then
ds.Tables.Add("testTable")
ds.Tables("testTable").Columns.Add("Driver Name")
ds.Tables("testTable").Columns.Add("Total")
ds.Tables("testTable").Columns.Add("# Of Calls")
ds.Tables("testTable").Columns("Total").ReadOnly = True
ds.Tables("testTable").Columns("# Of Calls").ReadOnly = True
Dim newRow As DataRow = ds.Tables("testTable").NewRow()
newRow("Driver Name") = ""
newRow("Total") = ""
newRow("# Of Calls") = ""
ds.Tables("testTable").Rows.Add(newRow)
End If
BindData()
End Sub
You should DataBind your GridView only if Not Page.IsPostback, otherwise the new values are overwritten.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowupdating.aspx
public static void filedownload(string Path)
{
string str = "";
FileInfo file = new FileInfo(Path);
// Checking if file exists
if (file.Exists)
{
// Clear the content of the response
HttpContext.Current.Response.ClearContent();
// LINE1: Add the file name and attachment, which will force the open/cance/save dialog to show, to the header
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
// Add the file size into the response header
HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
// Set the ContentType
HttpContext.Current.Response.ContentType = CommonStrings.returnextension(file.Extension.ToLower());
// Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead)
HttpContext.Current.Response.WriteFile(file.FullName);
// End the response
HttpContext.Current.Response.End();
}
else
{
// 9-vgrfu8i "File Not Found!";
}
// Response.Redirect(e.CommandArgument.ToString());
}
public static string GetBarCodeid(ListBox lbListBox)
{
string strCode = "";
if (lbListBox.Items.Count > 0)
{
for (int i = 0; i < lbListBox.Items.Count; i++)
{
if (lbListBox.Items[i].Selected == true)
{
if (strCode == "")
{
strCode = lbListBox.Items[i].Value.ToString();
}
else
{
strCode += "," + lbListBox.Items[i].Value.ToString();
}
}
}
}
return strCode;
}
public static string GetBarCodeName(ListBox lbListBox)
{
string strBarCodeName = "";
if (lbListBox.Items.Count > 0)
{
for (int i = 0; i < lbListBox.Items.Count; i++)
{
if (lbListBox.Items[i].Selected == true)
{
if (strBarCodeName == "")
{
strBarCodeName = lbListBox.Items[i].Text.ToString();
}
else
{
strBarCodeName += "," + lbListBox.Items[i].Text.ToString();
}
}
}
}
return strBarCodeName;
}
public static double GetBarCodeCount(ListBox lbListBox, double Count)
{
double intBarCodeCount = 0;
if (lbListBox.Items.Count > 0)
{
for (int i = 0; i < lbListBox.Items.Count; i++)
{
if (lbListBox.Items[i].Selected == true)
{
if (intBarCodeCount == 0)
{
intBarCodeCount = 1;
}
else
{
intBarCodeCount++;
}
}
}
}
return intBarCodeCount;
}
public static void SelectListBox(ListBox lbListBox, string strBarCodeId)
{
ExecuteProcedures ex = new ExecuteProcedures(1, MasterCommonStrings.ConnectionString);
ex.Parameters.Add("#vcrBarCodeid", SqlDbType.VarChar, 500, strBarCodeId);
DataTable dt = (DataTable)ex.LoadTableWithProcedure("Proc_Erp_Trn_Get_BarCode_Bata");
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
for (int j = 0; j < lbListBox.Items.Count; j++)
{
if (dt.Rows[i]["data"].ToString() == lbListBox.Items[j].Value.ToString())
{
lbListBox.Items[j].Selected = true;
break;
}
}
}
}
}
public static string GetgridBarCode(DataTable dt, string strColumnName)
{
string strBarCodeCount = "";
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
if (Convert.ToInt32(dt.Rows[i]["intStatus"]) != 2)
{
if (dt.Rows[i][strColumnName].ToString() != "")
if (strBarCodeCount == "")
{
strBarCodeCount = dt.Rows[i][strColumnName].ToString();
}
else
{
strBarCodeCount += dt.Rows[i][strColumnName].ToString();
}
}
}
}
return strBarCodeCount;
}
public static DataTable CheckBarCodeExistsOrNot(ListBox lbListbox, string strColumeName, string strReplacegridBarCodeid, DataView dvDescription)
{
DataTable dtDescription = new DataTable();
dtDescription = (DataTable)dvDescription.Table;
string strgridBarCode = CommonFunctions.GetgridBarCode(dtDescription, strColumeName);
string strSelectBarCode = CommonFunctions.GetBarCodeid(lbListbox);
ExecuteProcedures ex = new ExecuteProcedures(3, MasterCommonStrings.ConnectionString);
ex.Parameters.Add("#vcrgridBarcodeid", SqlDbType.VarChar, 500, strgridBarCode);
ex.Parameters.Add("#vcrSelectBarcodeid", SqlDbType.VarChar, 500, strSelectBarCode);
ex.Parameters.Add("#vcrReplaceBarCodeid", SqlDbType.VarChar, 500, strReplacegridBarCodeid);
DataTable dt = (DataTable)ex.LoadTableWithProcedure("Proc_Erp_Trn_Check_BarCode_Exists_Or_Not");
return dt;
}
public static int BarcodeUpdateIntoBarCodeDrec(string strBarCode_Description_Drec_id, SqlTransaction sqlTran, SqlConnection Con)
{
ExecuteProcedures ex = new ExecuteProcedures(1, MasterCommonStrings.ConnectionString);
ex.Parameters.Add("#intBarCode_Description_Drec_id", SqlDbType.VarChar, 8000, strBarCode_Description_Drec_id);
int i = Convert.ToInt32(ex.InvokeProcedure("Proc_Erp_Trn_Update_erp_mst_BarCode_Drec", sqlTran, ValueDataType.Number, Con));
if (i != 0)
{
return i;
}
else
{
return 0;
}
}
public static string AddBarcodeToListBox(TextBox txtScanBarcode, ListBox lbScanBarCode, ListBox lbSystemBarCode)
{
string barcodePresent = "";
if (txtScanBarcode.Text != "")
{
foreach (ListItem li in lbSystemBarCode.Items)
{
if (li.Text != txtScanBarcode.Text)
{
barcodePresent = "Not In Our System";
}
else
{
if (li.Selected == true)
{
barcodePresent = "Barcode Already Scan";
txtScanBarcode.Text = "";
txtScanBarcode.Focus();
break;
}
else
{
lbScanBarCode.Items.Add(txtScanBarcode.Text);
li.Selected = true;
txtScanBarcode.Text = "";
txtScanBarcode.Focus();
barcodePresent = "Barcode Scan Successfully";
break;
}
}
}
if (barcodePresent == "Not In Our System")
{
txtScanBarcode.Text = "";
txtScanBarcode.Focus();
}
}
else
{
barcodePresent = "Please Scan Barcode";
}
return barcodePresent;
}
public static void RemoveBarCodeFromListBox(ListBox lbScanBarCode, ListBox lbSystemBarCode)
{
if (lbScanBarCode.Items.Count > 0)
{
for (int i = 0; i < lbScanBarCode.Items.Count; i++)
{
if (lbScanBarCode.Items[i].Selected)
{
foreach (ListItem li1 in lbSystemBarCode.Items)
{
if (lbScanBarCode.Items[i].Text == li1.Text)
{
li1.Selected = false;
break;
}
}
lbScanBarCode.Items.Remove(lbScanBarCode.Items[i]);
}
}
}
}
public static void AddBarcodeToGridListBox(ListBox lbBarCode, ListBox lbGridScanBarCodeDisplay)
{
if (lbBarCode.Items.Count > 0)
{
for (int i = 0; i < lbBarCode.Items.Count; i++)
{
if (lbBarCode.Items[i].Selected == true)
{
lbGridScanBarCodeDisplay.Items.Add(lbBarCode.Items[i].Text);
}
}
}
}
public static void Alert(string strMessage, System.Web.UI.Page PAGE)
{
HttpContext Current = HttpContext.Current;
string strScript = "<script type=text/javascript>alert('" + strMessage + "')</script>";
if (!PAGE.IsStartupScriptRegistered("Alert"))
{
PAGE.RegisterStartupScript("Alert", strScript);
}
}
public static int DeletedTotalDrec(DataView dv, string strTableName, string strColumnName, string Value, SqlTransaction SqlTra, SqlConnection Con)
{
DataTable dtDrec = new DataTable();
dtDrec = (DataTable)dv.Table;
int i = 0;
if (dtDrec.Rows.Count > 0)
{
ExecuteProcedures one = new ExecuteProcedures(3, MasterCommonStrings.ConnectionString);
one.Parameters.Add("#TableName", SqlDbType.VarChar, 8000, strTableName);
one.Parameters.Add("#ColumnName", SqlDbType.VarChar, 8000, strColumnName);
one.Parameters.Add("#ColumnValue", SqlDbType.VarChar, 8000, Value);
int b = Convert.ToInt32(one.InvokeProcedure("Proc_Erp_Trn_Deleted_Transction_Total_Drec", SqlTra, ValueDataType.Number, Con));
for (int j = 0; j < dtDrec.Rows.Count; j++)
{
ExecuteProcedures EX = new ExecuteProcedures(19, MasterCommonStrings.ConnectionString);
EX.Parameters.Add("#TableName", SqlDbType.VarChar, 8000, strTableName);
EX.Parameters.Add("#FirstColumnName", SqlDbType.VarChar, 8000, dtDrec.Columns[0].ColumnName.ToString());
EX.Parameters.Add("#SecondColumnName", SqlDbType.VarChar, 8000, dtDrec.Columns[1].ColumnName.ToString());
EX.Parameters.Add("#ThiredColumnName", SqlDbType.VarChar, 8000, dtDrec.Columns[2].ColumnName.ToString());
EX.Parameters.Add("#FourColumnName", SqlDbType.VarChar, 8000, dtDrec.Columns[3].ColumnName.ToString());
EX.Parameters.Add("#FiveColumnName", SqlDbType.VarChar, 8000, dtDrec.Columns[4].ColumnName.ToString());
EX.Parameters.Add("#SixtColumnName", SqlDbType.VarChar, 8000, dtDrec.Columns[5].ColumnName.ToString());
EX.Parameters.Add("#SevenColumnName", SqlDbType.VarChar, 8000, dtDrec.Columns[6].ColumnName.ToString());
EX.Parameters.Add("#EightColumnName ", SqlDbType.VarChar, 8000, dtDrec.Columns[7].ColumnName.ToString());
EX.Parameters.Add("#NineColumnName", SqlDbType.VarChar, 8000, strColumnName);
EX.Parameters.Add("#FirstColumnNameValue ", SqlDbType.VarChar, 8000, dtDrec.Rows[j][0].ToString());
EX.Parameters.Add("#SecondColumnNameValue", SqlDbType.VarChar, 8000, dtDrec.Rows[j][1].ToString());
EX.Parameters.Add("#ThiredColumnNameValue", SqlDbType.VarChar, 8000, dtDrec.Rows[j][2].ToString());
EX.Parameters.Add("#FourColumnNameValue ", SqlDbType.VarChar, 8000, dtDrec.Rows[j][3].ToString());
EX.Parameters.Add("#FiveColumnNameValue", SqlDbType.VarChar, 8000, dtDrec.Rows[j][4].ToString());
EX.Parameters.Add("#SixtColumnNameValue", SqlDbType.VarChar, 8000, dtDrec.Rows[j][5].ToString());
EX.Parameters.Add("#SevenColumnNameValue", SqlDbType.VarChar, 8000, dtDrec.Rows[j][6].ToString());
EX.Parameters.Add("#EightColumnNameValue", SqlDbType.VarChar, 8000, dtDrec.Rows[j][7].ToString());
EX.Parameters.Add("#NineColumnNameValue ", SqlDbType.VarChar, 8000, Value);
i = Convert.ToInt32(EX.InvokeProcedure("proc_erp_Trn_Insert_into_Total_Drec", SqlTra, ValueDataType.Number, Con));
}
}
return i;
}
public static bool CheckRows(Manage_Drec Description)
{
if (Description.InTable.Rows.Count > 0)
{
return true;
}else
{
return false;
}
}
#endregion
# region "Procedures"
public static void SetRadiobutton(string strStatus, RadioButton Rbyes, RadioButton rbNo)
{
if (strStatus == "Yes")
{
Rbyes.Checked = true;
}
else
{
Rbyes.Checked = false;
}
if (strStatus == "No")
{
rbNo.Checked = true;
}
else
{
rbNo.Checked = false;
}
}
public static void Set_CheckBox(bool Status, CheckBox ChkName)
{
if (Status == true)
{
ChkName.Checked = true;
}
else
{
ChkName.Checked = false;
}
}
public static void DoSomeFileWritingStuff(string message)
{
//Debug.WriteLine("Writing to file...");
try
{
using (StreamWriter writer = new StreamWriter(LOG_FILE, true))
{
if (message == "")
{
writer.WriteLine("Cache Callback: {0}", DateTime.Now);
}
else
{
writer.WriteLine(message);
}
writer.Close();
}
AspSendEmail smail = new AspSendEmail();
//smail.strHost = mail.intrawebsolns.com
smail.SendEmail("support#intrawebsolns.com", "amit4692#gmail.com", "Exception Error", message, "Error ERP");
}
catch (Exception x)
{
//Debug.WriteLine(x);
DoSomeFileWritingStuff(x.Message);
}
//Debug.WriteLine("File write successful");
}
public static void SetRights(string Rights, Panel pnl)
{
foreach (Control ctrl in pnl.Controls)
{
if (ctrl.GetType().Name == "Button")
{
if ((((Button)ctrl).ID == "btnAdd" && Rights.IndexOf("A") > -1) || (((Button)ctrl).ID == "btnEdit" && Rights.IndexOf("E") > -1)
|| (((Button)ctrl).ID == "btnDelete" && Rights.IndexOf("D") > -1))
{
ctrl.Visible = true;
}
if ((((Button)ctrl).ID == "btnAdd" && Rights.IndexOf("S") > -1) || (((Button)ctrl).ID == "btnEdit" && Rights.IndexOf("S") > -1)
|| (((Button)ctrl).ID == "btnDelete" && Rights.IndexOf("S") > -1))
{
ctrl.Visible = true;
}
}
}
}
#endregion
public static void Enable_Btn_For_Add(Button btnAdd, Button btnCancel, Button btnDelete, Button btnEdit, Button btnUpdate, Button btnexit, Button btnfind)
{
btnEdit.Enabled = false;
btnAdd.Enabled = false;
btnfind.Enabled = false;
btnUpdate.Enabled = true;
btnCancel.Enabled = true;
btnDelete.Enabled = false;
btnexit.Enabled = true;
}
public static bool Check_Entry_exists(string tableName, string columnName, string columnValue)
{
bool result=false;
try
{
ExecuteProcedures ex = new ExecuteProcedures(4, AccountCommonStrings.ConnectionString);
ex.Parameters.Add("#tableName", SqlDbType.VarChar, 100, tableName);
ex.Parameters.Add("#columnName", SqlDbType.VarChar, 100, columnName);
ex.Parameters.Add("#columnValue", SqlDbType.VarChar, 100, #columnValue);
ex.Parameters.Add("#isbitdeleted", SqlDbType.Int, 0);
string temp =Convert.ToString( ex.InvokeProcedure("proc_check_Delete_entry", ValueDataType.String));
if (temp == "false")
{
result = false;
}
else
{
result = true;
}
}
catch (Exception)
{
}
return result;
}
public static bool Check_Entry_exists(string tableName, string columnName, string columnValue,string isbitdeleted)
{
bool result = false;
try
{
ExecuteProcedures ex = new ExecuteProcedures(4, AccountCommonStrings.ConnectionString);
ex.Parameters.Add("#tableName", SqlDbType.VarChar, 100, tableName);
ex.Parameters.Add("#columnName", SqlDbType.VarChar, 100, columnName);
ex.Parameters.Add("#columnValue", SqlDbType.VarChar, 100, #columnValue);
ex.Parameters.Add("#isbitdeleted", SqlDbType.Int, isbitdeleted);
string temp = Convert.ToString(ex.InvokeProcedure("proc_check_Delete_entry", ValueDataType.String));
if (temp == "false")
{
result = false;
}
else
{
result = true;
}
}
catch (Exception)
{
}
return result;
}
}