using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; /// /// Summary description for Validate /// public class Validate { //SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["con"]); SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString); public Validate() { // // TODO: Add constructor logic here // } public void Authentication(String id, String pass, ref Label uAuth, ref Label uLog, ref Label uType, ref Label err) { try { SqlCommand cmd = new SqlCommand("Select * from tbl_AdminLogin Where LoginId='" + id + "'", con); SqlDataReader dr; con.Open(); dr = cmd.ExecuteReader(); if (dr.Read()) { if (dr["Password"].ToString().Trim() != pass) { uAuth.Text = "No"; uLog.Text = ""; uType.Text = ""; err.Text = "Alert! : Invalid Password"; } else { uAuth.Text = "Yes"; uLog.Text = dr["LoginId"].ToString().Trim(); uType.Text = dr["Type"].ToString().Trim(); err.Text = "Loding..."; } } else { err.Text = "Alert! : Invalid Login Id"; uAuth.Text = "No"; } } catch (Exception ex) { uAuth.Text = "No"; err.Text = "Alert! : " + ex.Message; } finally { con.Close(); } } public void Authentication2(String id, String pass, ref Label uAuth, ref Label uLog, ref Label err, ref Label empname) { try { SqlCommand cmd = new SqlCommand("Select * from tbl_Employeelogin Where EmpName='" + id + "'", con); SqlDataReader dr; con.Open(); dr = cmd.ExecuteReader(); if (dr.Read()) { if (dr["Password"].ToString().Trim() != pass) { uAuth.Text = "No"; uLog.Text = ""; err.Text = "Alert! : Invalid Password"; } else if (dr["Password"].ToString().Trim() == pass) { uAuth.Text = "Yes"; uLog.Text = dr["EmpName"].ToString().Trim(); empname.Text = dr["EmpName"].ToString().Trim(); err.Text = "Loding..."; } } else { uAuth.Text = "No"; err.Text = "Alert! : Invalid Employee Id"; } } catch (Exception ex) { uAuth.Text = "No"; err.Text = "Alert! : " + ex.Message; } finally { con.Close(); } } public void Authentication_Client(String id, String pass, ref Label cAuth, ref Label cClientId, ref Label cName, ref Label err) { try { SqlCommand cmd = new SqlCommand("Select * from tbl_ClientMaster Where Email='" + id + "'", con); SqlDataReader dr; con.Open(); dr = cmd.ExecuteReader(); if (dr.Read()) { if (dr["Password"].ToString().Trim() != pass) { cAuth.Text = "No"; cClientId.Text = ""; cName.Text = ""; err.Text = "Alert! : Invalid Password"; } else if (dr["Password"].ToString().Trim() == pass) { cAuth.Text = "Yes"; cClientId.Text = dr["Email"].ToString().Trim(); cName.Text = dr["ClientName"].ToString().Trim(); err.Text = "Loding..."; } } else { err.Text = "Alert! : Invalid Login Id"; cAuth.Text = "No"; } } catch (Exception ex) { cAuth.Text = "No"; err.Text = "Alert! : " + ex.Message; } finally { con.Close(); } } //---------------------------------------------------------------------------- public void Check_Unique(string sel, string tbl, string val, ref Label err) { if (sel == "") { err.Text = "Alert! Please Enter " + sel; } else { try { if ((con.State == ConnectionState.Open)) { con.Close(); } SqlCommand cmd = new SqlCommand("Select " + sel + " from " + tbl + " Where " + sel + " ='" + val + "'", con); SqlDataReader dr; con.Open(); dr = cmd.ExecuteReader(); if (dr.Read()) { err.Text = "Alert! " + val + " already exixts, Please choose another"; } else { err.Text = "Yes"; } } catch (Exception ex) { err.Text = "Chk Error :" + ex.Message; } finally { con.Close(); } } } public void Check_Unique2(string sel, string tbl, string val, string val2, ref Label err) { if (sel == "") { err.Text = "Alert! Please Enter " + sel; } else { try { if ((con.State == ConnectionState.Open)) { con.Close(); } SqlCommand cmd = new SqlCommand("Select " + sel + " from " + tbl + " Where " + sel + " ='" + val + "'", con); SqlDataReader dr; con.Open(); dr = cmd.ExecuteReader(); if (dr.Read()) { err.Text = "Alert! " + val2 + " already exixts, Please choose another"; } else { err.Text = "Yes"; } } catch (Exception ex) { err.Text = "Chk Error :" + ex.Message; } finally { con.Close(); } } } }