protected void grdCity_RowDeleting(object sender, GridViewDeleteEventArgs e) { int cityId = Convert.ToInt32(grdCity.DataKeys[e.RowIndex].Values[0]); string str = grdCity.Rows[e.RowIndex].Cells[1].Text; if (dbCommon.CheckDuplicateByQuery("select count(*) from area where cityid='" + cityId + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!','" + str + " exist in Area.', 'warning');", true); } else if (dbCommon.CheckDuplicateByQuery("select count(*) from address where cityid='" + cityId + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!','" + str + " exist in Address.', 'warning');", true); } else if (dbCommon.CheckDuplicateByQuery("select count(*) from custompackage where departurecityid='" + cityId + "' or destinationcityid='" + cityId + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!','" + str + " exist in Custom Package.', 'warning');", true); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!','" + str + " exist in Custom Package.', 'success');", true); List <SqlParameter> sqlp = new List <SqlParameter>(); sqlp.Add(new SqlParameter("@FieldName", "cityid")); sqlp.Add(new SqlParameter("@FieldValue", cityId)); sqlp.Add(new SqlParameter("@TableName", "city")); dbCommon.SaveData(sqlp, "DeleteDataFromTable"); this.BindGrid(); } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (btnSubmit.Text == "Submit") { int maxId = dbCommon.CheckDuplicateByQuery("select IsNUll(Max(experience_id),0)+1 from LAS_experience"); bool b = dbCommon.boolInsertData("insert into LAS_experience (experience_id,login_id,from_date,to_date,description) " + " values('" + maxId + "', '" + Session["Slogin_id"].ToString() + "', " + " '" + DateTime.Parse(txtfrom.Text.ToString()).ToString("yyyy-MM-dd") + "','" + DateTime.Parse(txttodate.Text.ToString()).ToString("yyyy-MM-dd") + "', " + " '" + txtdescription.Text.ToString().Trim() + "') "); if (b == true) { Response.Redirect("experience.aspx"); } } else { bool b = dbCommon.boolInsertData("update LAS_experience set description='" + txtdescription.Text.ToString().Trim() + "', from_date='" + DateTime.Parse(txtfrom.Text.ToString()).ToString("yyyy-MM-dd") + "', " + " to_date='" + DateTime.Parse(txttodate.Text.ToString()).ToString("yyyy-MM-dd") + "' " + " where experience_id='" + ViewState["id"].ToString() + "' "); if (b == true) { Response.Redirect("experience.aspx"); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { string sqlStr = ""; if (btnSubmit.Text == "Submit") { int maxId = dbCommon.CheckDuplicateByQuery("select IsNUll(Max(review_id),0)+1 from LAS_review"); sqlStr = "insert into LAS_review (review_id,description,create_date,appointment_id) " + " values('" + maxId + "','" + txtReview.Text.ToString().Replace("'", " ") + "',GETDATE(),'" + ViewState["aid"] + "')"; if (dbCommon.boolInsertData(sqlStr) == true) { Response.Redirect("view_appointment.aspx"); } } else { sqlStr = "update LAS_review set description='" + txtReview.Text.ToString().Replace("'", " ") + "' where review_id='" + ViewState["aid"].ToString() + "'"; if (dbCommon.boolInsertData(sqlStr) == true) { Response.Redirect("view_appointment.aspx"); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (lblDErrorMsg.Text == "") { if (btnSubmit.Text == "Submit") { int maxId = dbCommon.CheckDuplicateByQuery("select IsNUll(Max(service_id),0)+1 from LAS_service"); bool b = dbCommon.boolInsertData("insert into LAS_service (service_id,login_id,description,fees) " + " values('" + maxId + "', '" + Session["Slogin_id"].ToString() + "', " + " '" + txtService.Text.ToString().Trim() + "','" + txtCharge.Text.ToString().Trim() + "') "); if (b == true) { Response.Redirect("services.aspx"); } } else { bool b = dbCommon.boolInsertData("update LAS_service set description='" + txtService.Text.ToString().Trim() + "', fees='" + txtCharge.Text.ToString().Trim() + "' " + " where service_id='" + ViewState["id"].ToString() + "' "); if (b == true) { Response.Redirect("services.aspx"); } } } }
protected void grdPackageType_RowDeleting(object sender, GridViewDeleteEventArgs e) { int packagecategoryID = Convert.ToInt16(grdPackageType.DataKeys[e.RowIndex].Values[0]); DataTable dt = new DataTable(); dt = dbCommon.DisplayDataParam("packagecategory", "pkgimgsrc", "packagecategoryid = " + packagecategoryID); if (dbCommon.CheckDuplicateByQuery("select count(*) from package where packagecategoryid='" + packagecategoryID + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!','" + grdPackageType.Rows[e.RowIndex].Cells[0].Text + " exist in Package.', 'warning');", true); } else { foreach (DataRow dr in dt.Rows) { string strPhysicalFolder = Server.MapPath("~/Images/Package/"); if (dr["pkgimgsrc"].ToString() != "" && File.Exists(strPhysicalFolder + dr["pkgimgsrc"].ToString())) { File.Delete(strPhysicalFolder + dr["pkgimgsrc"].ToString()); } break; } this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!', '" + grdPackageType.Rows[e.RowIndex].Cells[0].Text + " is Delete.', 'success');", true); dbCommon.DeleteData("packagecategoryid", packagecategoryID, "packagecategory"); this.BindGrid(); } }
protected void grdPackageItinerary_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { dbCommon.SetUpdateId("imageAddId", ddPackageName.SelectedValue.ToString()); int cId = Convert.ToInt16(grdPackageItinerary.DataKeys[e.RowIndex].Values[0]); if (dbCommon.CheckDuplicateByQuery("select count(*) from packageitineraryactivity where packageitineraryid='" + cId + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!','" + grdPackageItinerary.Rows[e.RowIndex].Cells[1].Text + " exist in Package Itineray Activity.', 'warning');", true); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!', '" + grdPackageItinerary.Rows[e.RowIndex].Cells[1].Text + " is Delete.', 'success');", true); List <SqlParameter> sqlp = new List <SqlParameter>(); sqlp.Add(new SqlParameter("@TableName", "packageitinerary")); sqlp.Add(new SqlParameter("@FieldName", "packageitineraryid")); sqlp.Add(new SqlParameter("@FieldValue", cId)); if (dbCommon.SaveData(sqlp, "DeleteDataFromTable") == true) { Response.Redirect("PackageItinerary.aspx"); } } } catch (Exception) { } }
protected void btnsubmit_Click(object sender, EventArgs e) { if (btnsubmit.Text == "Submit") { int maxId = dbCommon.CheckDuplicateByQuery("select IsNUll(Max(office_id),0)+1 from LAS_office"); bool b = dbCommon.boolInsertData("insert into LAS_office (office_id,login_id,office_name,address,pincode,mobile,email_id,area_id) " + " values('" + maxId + "', '" + Session["Slogin_id"].ToString().Trim() + "','" + txtname.Text.ToString().Trim() + "', " + " '" + txtaddress.Text.ToString().Trim() + "','" + txtpostalcode.Text.ToString().Trim() + "','" + txtmobile.Text.ToString().Trim() + "', " + " '" + txtemail.Text.ToString().Trim() + "', '" + cmbarea.SelectedValue.ToString().Trim() + "' ) "); if (b == true) { Response.Redirect("office_info.aspx"); } } else { bool b = dbCommon.boolInsertData("update LAS_office set office_name='" + txtname.Text.ToString().Trim() + "'," + " address='" + txtaddress.Text.ToString().Trim() + "',pincode='" + txtpostalcode.Text.ToString().Trim() + "', " + " mobile='" + txtmobile.Text.ToString().Trim() + "',email_id='" + txtemail.Text.ToString().Trim() + "', " + " area_id='" + cmbarea.SelectedValue.ToString().Trim() + "' " + " where office_id='" + ViewState["id"].ToString() + "' "); if (b == true) { Response.Redirect("office_info.aspx"); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (lblDErrorMsg.Text == "") { if (btnSubmit.Text == "Save") { int maxId = dbCommon.CheckDuplicateByQuery("select IsNUll(Max(area_id),0)+1 from LAS_area"); bool b = dbCommon.boolInsertData("insert into LAS_area (area_id,area_name,city_id) " + " values('" + maxId + "', '" + txtArea.Text.ToString().Trim() + "','" + cmbCity.SelectedValue.ToString() + "') "); if (b == true) { Response.Redirect("area.aspx"); } } else { bool b = dbCommon.boolInsertData("update LAS_area set area_name='" + txtArea.Text.ToString().Trim() + "', city_id='" + cmbCity.SelectedValue.ToString() + "' " + " where area_id='" + ViewState["id"].ToString() + "' "); if (b == true) { Response.Redirect("area.aspx"); } } } }
protected void btnSubmit_Click(object sender, EventArgs e) { int maxId = dbCommon.CheckDuplicateByQuery("select IsNUll(Max(order_id),0)+1 from orderMst"); string s = Session["Scompany_id"].ToString(); bool i2 = dbCommon.boolInsertData("insert into orderMst(order_id,login_id,company_id,date_time,pick_up_date,amount,totalqty)" + " Values('" + maxId + "','" + Session["Slogin_id"].ToString() + "','" + Session["Scompany_id"].ToString() + "', " + " SYSDATETIME(),'" + DateTime.Parse(txtPickUpDate.Text.ToString()).ToString("yyyy-MM-dd hh:mm") + "','" + txtTotAmount.Text.ToString() + "','" + txtTotQty.Text.ToString() + "') "); if (i2 == true) { try { foreach (GridViewRow row in GridView1.Rows) { TextBox txtQty = (TextBox)row.Cells[6].FindControl("TextBoxS"); if (txtQty.Text.ToString() != "") { dbCommon.boolInsertData("insert into order_details(order_id, item_id, quantity, price) " + " Values('" + maxId + "','" + row.Cells[0].Text.ToString() + "','" + txtQty.Text.ToString() + "','" + row.Cells[4].Text.ToString() + "') "); } } Response.Redirect("past_order.aspx"); } catch (Exception) { } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (lblDErrorMsg.Text == "") { if (btnSubmit.Text == "Save") { int maxId = dbCommon.CheckDuplicateByQuery("select IsNUll(Max(country_id),0)+1 from LAS_Country"); bool b = dbCommon.boolInsertData("insert into LAS_country (country_id,country_name) " + " values('" + maxId + "', '" + txtCountry.Text.ToString().Trim() + "') "); if (b == true) { Response.Redirect("country.aspx"); } } else { bool b = dbCommon.boolInsertData("update LAS_country set country_name='" + txtCountry.Text.ToString().Trim() + "' " + " where country_id='" + ViewState["id"].ToString() + "' "); if (b == true) { Response.Redirect("country.aspx"); } } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (lblDErrorMsg.Text == "") { if (btnSubmit.Text == "Submit") { int maxId = dbCommon.CheckDuplicateByQuery("select IsNUll(Max(designation_id),0)+1 from designation"); bool b = dbCommon.boolInsertData("insert into designation (designation_id,designation_name) " + " values('" + maxId + "', '" + txtDescription.Text.ToString().Trim() + "') "); if (b == true) { Response.Redirect("designation.aspx"); } } else { bool b = dbCommon.boolInsertData("update designation set designation_name='" + txtDescription.Text.ToString().Trim() + "' " + " where designation_id='" + ViewState["id"].ToString() + "' "); if (b == true) { Response.Redirect("designation.aspx"); } } } }
protected void txtEmail_TextChanged(object sender, EventArgs e) { int i = 0; string sqlQry = ""; sqlQry = "select count(*) from login where email='" + txtEmail.Text.ToString().Trim() + "' "; if (btnSubmit.Text == "Update") { sqlQry += " and login_id not in('" + ViewState["id"].ToString() + "')"; } i = dbCommon.CheckDuplicateByQuery(sqlQry); if (i >= 1) { lblDErrorMsg.Text = "* This email exist."; lblDErrorMsg.Visible = true; } else { lblDErrorMsg.Text = ""; lblDErrorMsg.Visible = false; } }
public void checkItemData() { int i = 0; string sqlQry = ""; sqlQry = "select count(*) from item where item_name='" + txtItem.Text.ToString() + "' and item_type='" + cmbItemtype.SelectedValue.ToString() + "' "; if (btnSubmit.Text == "Update") { sqlQry += " and item_id not in('" + ViewState["id"].ToString() + "')"; } i = dbCommon.CheckDuplicateByQuery(sqlQry); if (i >= 1) { lblDErrorMsg.Text = "* This item and type exist."; lblDErrorMsg.Visible = true; } else { lblDErrorMsg.Text = ""; lblDErrorMsg.Visible = false; } }
protected void grdCountry_RowDeleting(object sender, GridViewDeleteEventArgs e) { int cId = Convert.ToInt16(grdCountry.DataKeys[e.RowIndex].Values[0]); string str = grdCountry.Rows[e.RowIndex].Cells[0].Text; if (dbCommon.CheckDuplicateByQuery("select COUNT(*) from city where countryid='" + cId + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!', '" + str + " is exist in city!', 'warning');", true); } else if (dbCommon.CheckDuplicateByQuery("select COUNT(*) from user_details where countryid='" + cId + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!', '" + str + " is exist in user!', 'warning');", true); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!', '" + str + " is Delete !', 'success');", true); dbCommon.DeleteData("countryid", cId, "country"); this.BindGrid(); } }
protected void grdAddPackage_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { int cId = Convert.ToInt16(grdAddPackage.DataKeys[e.RowIndex].Values[0]); string str = grdAddPackage.Rows[e.RowIndex].Cells[1].Text; if (dbCommon.CheckDuplicateByQuery("select count(*) from packageimage where packageid='" + cId + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!','This Package name " + str + " is exist in Package Image.', 'warning');", true); } else if (dbCommon.CheckDuplicateByQuery("select count(*) from bookpackage where packageid='" + cId + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!','This Package name " + str + " is exist in Book Activity Details.', 'warning');", true); } else if (dbCommon.CheckDuplicateByQuery("select count(*) from PackageHotelPrice where packageid='" + cId + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!','This Package name " + str + " is exist in Hotel Price.', 'warning');", true); } else if (dbCommon.CheckDuplicateByQuery("select count(*) from packageitinerary where packageid='" + cId + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!','This Package name " + str + " is exist in Package Itinerary.', 'warning');", true); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!', '" + str + " is Delete.', 'success');", true); List <SqlParameter> sqlp = new List <SqlParameter>(); sqlp.Add(new SqlParameter("@TableName", "Package")); sqlp.Add(new SqlParameter("@FieldName", "Packageid")); sqlp.Add(new SqlParameter("@TabId", cId)); sqlp.Add(new SqlParameter("@LoginId", "1")); if (dbCommon.SaveData(sqlp, "DeleteFlgById") == true) { Response.Redirect("AddPackage.aspx"); } } } catch (Exception) { } }
protected void grdArea_RowDeleting(object sender, GridViewDeleteEventArgs e) { int AreaID = Convert.ToInt32(grdArea.DataKeys[e.RowIndex].Values[0]); string str = grdArea.Rows[e.RowIndex].Cells[2].Text; if (dbCommon.CheckDuplicateByQuery("select count(*) from activity where areaid='" + AreaID + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!','" + str + " is exist in Activity.', 'warning');", true); } else if (dbCommon.CheckDuplicateByQuery("select count(*) from packageitinerary where areaid='" + AreaID + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!','" + str + " is exist in Package Itinerary.', 'warning');", true); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!', '" + str + " is Delete.', 'success');", true); List <SqlParameter> sqlp = new List <SqlParameter>(); sqlp.Add(new SqlParameter("@FieldName", "areaid")); sqlp.Add(new SqlParameter("@FieldValue", AreaID)); sqlp.Add(new SqlParameter("@TableName", "area")); dbCommon.SaveData(sqlp, "DeleteDataFromTable"); this.BindGrid(); } }
protected void grdHotelType_RowDeleting(object sender, GridViewDeleteEventArgs e) { int HoteltypeID = Convert.ToInt32(grdHotelType.DataKeys[e.RowIndex].Values[0]); string str = grdHotelType.Rows[e.RowIndex].Cells[0].Text; if (dbCommon.CheckDuplicateByQuery("select count(*) from PackageHotelPrice where hoteltypeid='" + HoteltypeID + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!','" + str + " exist in Package Hotel Price.', 'warning');", true); } else if (dbCommon.CheckDuplicateByQuery("select count(*) from custompackage where hoteltypeid='" + HoteltypeID + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!','" + str + " exist in Custom Package.', 'warning');", true); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!', '" + str + " is Delete.', 'success');", true); List <SqlParameter> sqlp = new List <SqlParameter>(); sqlp.Add(new SqlParameter("@FieldName", "hoteltypeid")); sqlp.Add(new SqlParameter("@FieldValue", HoteltypeID)); sqlp.Add(new SqlParameter("@TableName", "hoteltype")); dbCommon.SaveData(sqlp, "DeleteDataFromTable"); this.BindGrid(); } }
protected void txtEmail_TextChanged(object sender, EventArgs e) { int i = 0; string sqlQuery = ""; sqlQuery = "select Count(login_id) from Login " + " where email='" + txtEmail.Text.Trim() + "'"; i = dbCommon.CheckDuplicateByQuery(sqlQuery); if (i >= 1) { lblEmail_V.Text = "*Email Id Exist."; } else { lblEmail_V.Text = ""; } }
protected void txtService_TextChanged(object sender, EventArgs e) { int i = 0; DBConnectionClass conD = new DBConnectionClass("CheckDuplicateData"); //List<SqlParameter> sqlp = new List<SqlParameter>(); //sqlp.Clear(); //sqlp.Add(new SqlParameter("@TableName", "LAS_service")); //sqlp.Add(new SqlParameter("@FieldName", "description")); //sqlp.Add(new SqlParameter("@FieldValue", txtService.Text.ToString().Trim())); string sqlStr = ""; sqlStr = "select * from LAS_service where description='" + txtService.Text.ToString().Trim() + "' and login_id='" + Session["Slogin_id"].ToString() + "' "; if (btnSubmit.Text == "Update") { sqlStr = sqlStr + " and service_id!='" + ViewState["id"].ToString() + "' "; } i = conD.CheckDuplicateByQuery(sqlStr); if (i >= 1) { if (btnSubmit.Text == "Update") { lblDErrorMsg.Text = "* This service exist."; } else { lblDErrorMsg.Text = ""; } if (btnSubmit.Text == "Submit") { lblDErrorMsg.Text = "* This service exist."; } } else { lblDErrorMsg.Text = ""; } }
protected void grdDesignation_RowDeleting(object sender, GridViewDeleteEventArgs e) { int cId = Convert.ToInt16(grdDesignation.DataKeys[e.RowIndex].Values[0]); string str = grdDesignation.Rows[e.RowIndex].Cells[0].Text; if (dbCommon.CheckDuplicateByQuery("select count(*) from user_details where designationid='" + cId + "'") > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!', 'This Designation Type name " + str + " is exist in User Details.', 'warning');", true); ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('This Designation Type name " + str + " is exist in User Details.');", true); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "swal('Delete!', '" + str + " is Delete.', 'success');", true); List <SqlParameter> sqlp = new List <SqlParameter>(); sqlp.Add(new SqlParameter("@FieldName", "designationid")); sqlp.Add(new SqlParameter("@FieldValue", cId)); sqlp.Add(new SqlParameter("@TableName", "designation")); dbCommon.SaveData(sqlp, "DeleteDataFromTable"); this.BindGrid(); } }
protected void btnSubmit_Click(object sender, EventArgs e) { string sqlStr = ""; int maxId = dbCommon.CheckDuplicateByQuery("select IsNUll(Max(appointment_id),0)+1 from LAS_appointment"); sqlStr = "insert into LAS_appointment(appointment_id,office_id,user_login_id,book_date,book_time,book_reason,a_status) " + " values('" + maxId + "','" + dbCommon.GetUpdateId("officeId") + "','" + Session["Slogin_id"].ToString() + "','" + DateTime.Parse(lblLDate.Text.ToString()).ToString("yyyy-MM-dd") + "','" + DateTime.Parse(lblLTime.Text.ToString()).ToString("H:mm") + "', '" + txtReason.Text.ToString().Replace("'", " ") + "','0') "; bool i = dbCommon.boolInsertData(sqlStr); if (i == true) { dbCommon.EmptyUpdateId("officeId"); dbCommon.EmptyUpdateId("bookTime"); dbCommon.EmptyUpdateId("bookDate"); Response.Redirect("view_appointment.aspx"); } else { Response.Write("<script>"); Response.Write("alert('Appointment not booked. Try again.');"); Response.Write("</script>"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (btnSubmit.Text == "Submit") { int maxId = dbCommon.CheckDuplicateByQuery("select IsNUll(Max(complain_id),0)+1 from complain"); string s = Session["Scompany_id"].ToString(); bool i2 = dbCommon.boolInsertData("insert into complain(complain_id,login_id,order_id,description)" + " Values('" + maxId + "','" + Session["Slogin_id"].ToString() + "','" + Request.QueryString["cid"].ToString() + "', " + " '" + txtComplaint.Text.ToString() + "') "); if (i2 == true) { Response.Redirect("complain.aspx"); } } else { bool i2 = dbCommon.boolInsertData("update complain set description='" + txtComplaint.Text.ToString().Replace("'", " ") + "' " + " where order_id='" + ViewState["id"].ToString() + "' "); if (i2 == true) { Response.Redirect("complain.aspx"); } } }
protected void ValidateUser() { DBConnectionClass conLoginUser = new DBConnectionClass(); string ipv4 = "", ipv6 = ""; List <SqlParameter> sqlp = new List <SqlParameter>(); sqlp.Add(new SqlParameter("@UserLoginName", txtLoginId.Text.ToString())); sqlp.Add(new SqlParameter("@Password", conLoginUser.HashPassword(txtPassword.Text.ToString()))); List <SqlParameter> sqlULogin = new List <SqlParameter>(); string result = conLoginUser.checkUserLogin(sqlp); string status = ""; string browsertype = Request.Browser.Type; string browsername = Request.Browser.Browser; string browserversion = Request.Browser.Version; string browserplatform = Request.Browser.Platform; string osname = "", osversion = ""; try { OperatingSystem os = Environment.OSVersion; osname = os.ToString(); osversion = os.Version.ToString(); } catch (Exception) { } try { if (Dns.GetHostAddresses(Dns.GetHostName()).Length > 0) { ipv6 = Dns.GetHostAddresses(Dns.GetHostName())[0].ToString(); } ipv4 = GetLocalIPv4(NetworkInterfaceType.Ethernet).ToString(); } catch (Exception) { } switch (result) { case "InValidId": sqlULogin.Clear(); sqlULogin.Add(new SqlParameter("@IPAddress", ipv6)); sqlULogin.Add(new SqlParameter("@UnBrowser", browsername)); sqlULogin.Add(new SqlParameter("@UnOS", osname)); sqlULogin.Add(new SqlParameter("@BType", browsertype)); sqlULogin.Add(new SqlParameter("@BVersion", browserversion)); sqlULogin.Add(new SqlParameter("@BPlateForm", browserplatform)); sqlULogin.Add(new SqlParameter("@OSVersion", osversion)); sqlULogin.Add(new SqlParameter("@IUserName", txtLoginId.Text)); sqlULogin.Add(new SqlParameter("@IPV4", ipv4)); conLoginUser.SaveData(sqlULogin, "AddUnknownUserLogin"); status = "Invalid User Name Or Password."; break; case "Guest": status = "You need to register with use to login."; break; case "InPass": sqlULogin.Clear(); sqlULogin.Add(new SqlParameter("@emailid", txtLoginId.Text.ToString())); sqlULogin.Add(new SqlParameter("@IPAddress", ipv6)); sqlULogin.Add(new SqlParameter("@TBrowser", browsername)); sqlULogin.Add(new SqlParameter("@BOS", osname)); sqlULogin.Add(new SqlParameter("@BType", browsertype)); sqlULogin.Add(new SqlParameter("@BVersion", browserversion)); sqlULogin.Add(new SqlParameter("@BPlateForm", browserplatform)); sqlULogin.Add(new SqlParameter("@OSVersion", osversion)); sqlULogin.Add(new SqlParameter("@IPV4", ipv4)); conLoginUser.SaveData(sqlULogin, "InvalidLoginAdd"); status = "Invalid User Name Or Password."; break; case "InActive": sqlULogin.Clear(); sqlULogin.Add(new SqlParameter("@emailid", txtLoginId.Text.ToString())); sqlULogin.Add(new SqlParameter("@UserPassword", conLoginUser.HashPassword(txtPassword.Text.ToString()))); DataTable dtUserIn = new DataTable(); dtUserIn = conLoginUser.DisplayData(sqlULogin, "MstUserView").Tables[0]; string userId = ""; foreach (DataRow drUserIn in dtUserIn.Rows) { userId = drUserIn["UserId"].ToString(); if (drUserIn["designationid"].ToString() == "4") { status = "Your account is De-Activate please check you email and confirm your Email-id."; } else { status = "Your account is De-Active. Contect Admin."; } break; } sqlULogin.Clear(); sqlULogin.Add(new SqlParameter("@UserId", userId)); sqlULogin.Add(new SqlParameter("@IPAddress", ipv6)); sqlULogin.Add(new SqlParameter("@TBrowser", browsername)); sqlULogin.Add(new SqlParameter("@BType", browsertype)); sqlULogin.Add(new SqlParameter("@BVersion", browserversion)); sqlULogin.Add(new SqlParameter("@BPlateForm", browserplatform)); sqlULogin.Add(new SqlParameter("@OSVersion", osversion)); sqlULogin.Add(new SqlParameter("@BOS", osname)); sqlULogin.Add(new SqlParameter("@IPV4", ipv4)); sqlULogin.Add(new SqlParameter("@LoginType", "I")); conLoginUser.SaveData(sqlULogin, "TraceLoginAdd"); break; case "Valid": Configuration config = WebConfigurationManager.OpenWebConfiguration("~/Web.Config"); SessionStateSection section = (SessionStateSection)config.GetSection("system.web/sessionState"); Session.Timeout = 60 * 60; sqlULogin.Clear(); sqlULogin.Add(new SqlParameter("@emailid", txtLoginId.Text.ToString())); sqlULogin.Add(new SqlParameter("@UserPassword", conLoginUser.HashPassword(txtPassword.Text.ToString()))); DataTable dtUserInfo = new DataTable(); dtUserInfo = conLoginUser.DisplayData(sqlULogin, "MstUserView").Tables[0]; foreach (DataRow drUserInfo in dtUserInfo.Rows) { Session["LoginUserName"] = drUserInfo["user_fname"].ToString() + " " + drUserInfo["user_lname"].ToString(); Session["LoginUserId"] = drUserInfo["UserId"].ToString(); Session["LoginUserRole"] = drUserInfo["usertype"].ToString(); Session["LoginUserDesignation"] = drUserInfo["designationid"].ToString(); Response.Cookies["CookieLoginUserId"].Value = drUserInfo["UserId"].ToString(); Response.Cookies["CookieLoginUserId"].Expires = DateTime.Now.AddDays(30); sqlULogin.Clear(); sqlULogin.Add(new SqlParameter("@UserId", drUserInfo["UserId"].ToString())); sqlULogin.Add(new SqlParameter("@IPAddress", ipv6)); sqlULogin.Add(new SqlParameter("@TBrowser", browsername)); sqlULogin.Add(new SqlParameter("@BType", browsertype)); sqlULogin.Add(new SqlParameter("@BVersion", browserversion)); sqlULogin.Add(new SqlParameter("@BPlateForm", browserplatform)); sqlULogin.Add(new SqlParameter("@OSVersion", osversion)); sqlULogin.Add(new SqlParameter("@BOS", osname)); sqlULogin.Add(new SqlParameter("@LoginType", "A")); sqlULogin.Add(new SqlParameter("@IPV4", ipv4)); conLoginUser.SaveData(sqlULogin, "TraceLoginAdd"); Response.Cookies["LoginSessionId"].Value = conLoginUser.CheckDuplicateByQuery("select MAX(TraceId) from TraceLogin where UserId='" + drUserInfo["UserId"].ToString() + "'").ToString(); Response.Cookies["LoginSessionId"].Expires = DateTime.Now.AddDays(30); switch (Session["LoginUserRole"].ToString()) { case "ADMIN": Session["LoginUserDesignationType"] = drUserInfo["designation"].ToString(); Session["UserImage"] = drUserInfo["profileimg"].ToString(); Response.Redirect("../Admin/UserProfile.aspx"); break; case "USER": Response.Redirect("../User/HomePage.aspx"); break; } } break; } spanDisplay.InnerHtml = status; }