public void SelfCheckRandomSeed() { Random rnd = new Random(); string seed = rnd.Next(int.MaxValue).ToString(); Assert.IsTrue(Verhoeff.GenerateVerhoeff(seed) == Verhoeff.GenerateVerhoeff(seed)); }
/// <summary> /// Añade N digitos Verhoeff a una cadena de texto /// <param name="value">cadena donde se añadiran digitos Verhoeff</param> /// <param name="max">cantidad de digitos a agregar</param> /// <returns>cadena original + N digitos Verhoeff</returns> /// </summary> private static String addVerhoeffDigit(String value, int max) { for (int i = 1; i <= max; i++) { value = String.Concat(value, Verhoeff.generateVerhoeff(value)); } return(value); }
public string ValidateAadharCard(string input) { bool Status = Verhoeff.ValidateVerhoeff(input); string s = ""; if (Status == true) { s = "true"; } return(s); }
protected void TxtAdhaarNo_TextChanged(object sender, EventArgs e) { bool abc = Verhoeff.validateVerhoeff(TxtAdhaarNo.Text); if (abc == true) { } else { lblaadharerror.Text = "Aadhar card is not valid"; } }
public void ValidateAKnownVerhoeff() { // known SCTID = 48176007 has check digit 7. // all other check digits should fail... for (int i = 0; i < 9; i++) { if (i != 7 && Verhoeff.ValidateVerhoeff("4817600" + i)) { Assert.Fail(); } } // ... But pass when 7 Assert.IsTrue(Verhoeff.ValidateVerhoeff("48176007")); }
public void CheckAgainstKnownList() { // Cycle through ExistingSNOMEDCTIds, checking check didgits // ExistingSNOMEDCTIds consist of ConceptIds for all top level concept in Jan 2014, and associate DescriptionIds, and Defining ReflationshipIds string[] ExistingSNOMEDCTIds = { "48176007", "71388002", "78621006", "105590001", "123037004", "123038009", "243796009", "254291000", "260787004", "272379006", "308916002", "362981000", "363787002", "370115009", "373873005", "404684003", "410607006", "419891008", "900000000000441003", "80268017", "118588011", "130458013", "169710016", "189056010", "190895018", "291656011", "364629017", "378526013", "388424018", "388425017", "388426016", "388427013", "388428015", "407503013", "452305016", "470725012", "482116013", "486911019", "491692013", "573283013", "645163010", "652584013", "724699017", "724710013", "754754016", "769964015", "785715019", "811548016", "819582012", "1199173018", "1212316016", "1225256013", "1458019012", "2148514019", "2156578010", "2466059019", "2472261015", "2571651013", "2573280016", "2575824015", "2576552011", "2579706018", "2609236017", "2610738018", "2615979011", "2616135016", "108642591000036118", "900000000000951010", "900000000000952015", "144487025", "144519022", "144611029", "145047021", "145312020", "145315022", "146186027", "146315028", "146410021", "146531021", "146535028", "146538026", "1019504021", "1019522024", "1713837029", "2472459022", "2565789025", "2840535024", "3792608028" }; foreach (var Id in ExistingSNOMEDCTIds) { if (Verhoeff.ValidateVerhoeff(Id) != true) { Assert.Fail(Id + " failed Verhoeff validation"); break; } } Assert.IsFalse(false); }
protected void a3_TextChanged(object sender, EventArgs e) { string aadharid = a1.Text + a2.Text + a3.Text; string aid = Verhoeff.validateVerhoeff(aadharid).ToString(); if (aid == "True") { } else { objCommon.ShowAlertMessage("InValid Aadhaar ID -Please Check"); a1.Text = ""; a2.Text = ""; a3.Text = ""; return; } }
static void Main(string[] args) { int ns = 1223221; SCTIdGenerator foo = new SCTIdGenerator(ns); SCTIdRepository Repo = new SCTIdRepository(ns); Console.WriteLine("NameSpace =" + ns.ToString()); string bar = foo.GenerateConceptId().ToString(); Console.WriteLine("ConceptId =" + bar); Repo.ReserveId(bar); bar = foo.GenerateConceptId().ToString(); Console.WriteLine("ConceptId =" + bar); Repo.ReserveId(bar); bar = foo.GenerateConceptId().ToString(); Console.WriteLine("ConceptId =" + bar); Repo.ReserveId(bar); Console.WriteLine(); bar = foo.GenerateDescriptionId().ToString(); Console.WriteLine("DescriptionId =" + bar); Repo.ReserveId(bar); Console.WriteLine(); bar = foo.GenerateRelationshipId().ToString(); Console.WriteLine("RelationshipId =" + bar); Repo.ReserveId(bar); string codeString = "0123456789"; string beep = codeString.Substring(codeString.Length - 6, 3); Console.WriteLine("This should be 456 : " + beep); Console.WriteLine("48176007 has check digit = " + Verhoeff.GenerateVerhoeff("4817600")); Repo.DumpRepository(); Console.WriteLine("Repo Dumped."); Console.ReadKey(); }
protected bool Validate_Save() { if (ddl_AnimalType.SelectedValue == "0") { objCommon.ShowAlertMessage("Select AnimalType"); ddl_AnimalType.Focus(); return(false); } if (ddlBreed.SelectedValue == "0") { objCommon.ShowAlertMessage("Select Breed"); ddlBreed.Focus(); return(false); } if ((!rbnFemale.Checked) && (!rbnMale.Checked)) { objCommon.ShowAlertMessage("Select Gender"); return(false); } if (txtAnimalAge.Text.Trim() == "") { objCommon.ShowAlertMessage("Enter Animal Age"); txtAnimalAge.Focus(); return(false); } if (txtAnimalOwner.Text == "") { objCommon.ShowAlertMessage("Enter Owner Name"); txtAnimalOwner.Focus(); return(false); } if (ddl_dist_code.SelectedValue == "0") { objCommon.ShowAlertMessage("Select District"); ddl_dist_code.Focus(); return(false); } if (ddl_mandal_code.SelectedValue == "0") { objCommon.ShowAlertMessage("Select Mandal"); ddl_mandal_code.Focus(); return(false); } if (txtvillage.Text == "") { objCommon.ShowAlertMessage("Enter City/Village"); txtvillage.Focus(); return(false); } if (txtmbno.Text == "") { objCommon.ShowAlertMessage("Please Enter Mobile Number"); return(false); } else { if (!objValidate.ISMobileNo(txtmbno.Text, 9, 9)) { objCommon.ShowAlertMessage("Please Enter Valid Mobile Number"); return(false); } } if (rdExempted.SelectedIndex < 0) { objCommon.ShowAlertMessage("Select an option for Exempted Category"); rdExempted.Focus(); return(false); } if (txtVdate.Text.Trim() != "") { if (!objValidate.IsDate(txtVdate.Text.Trim())) { objCommon.ShowAlertMessage("Enter Valid Visit Date"); txtVdate.Focus(); return(false); } } if (a1.Text == "" || a2.Text == "" || a3.Text == "") { objCommon.ShowAlertMessage("Please Enter Aadhaar Number"); return(false); } else if (a1.Text.Length != 4 || a2.Text.Length != 4 || a3.Text.Length != 4) { objCommon.ShowAlertMessage("Please Enter Valid Aadhaar Number"); return(false); } else { if (!objValidate.IsNumberOk(a1.Text + a2.Text + a3.Text)) { objCommon.ShowAlertMessage("Enter Valid Aadhar No"); txtVdate.Focus(); return(false); } string aid = Verhoeff.validateVerhoeff(a1.Text + a2.Text + a3.Text).ToString(); if (aid == "True") { } else { objCommon.ShowAlertMessage("InValid Aadhaar ID -Please Check"); a1.Text = ""; a2.Text = ""; a3.Text = ""; return(false); } } if (ddlcategory.SelectedValue == "0") { objCommon.ShowAlertMessage("Select Category"); ddl_mandal_code.Focus(); return(false); } string purposelist = ""; foreach (System.Web.UI.WebControls.ListItem item in ddlpurpose.Items) { if (item.Selected) { if (purposelist == "") { purposelist += item.Value; } else { purposelist += "," + item.Value; } } } if (purposelist == "") { objCommon.ShowAlertMessage("Please Select Purpose"); return(false); } return(true); }
public void RelationshipIdHasCheckDigit() { GenerateArtificalRelationshipId(); Assert.IsTrue(Verhoeff.ValidateVerhoeff(ArtificalRelationshipId.ToString())); }
public void DescriptionIdHasCheckDigit() { GenerateArtificalDescriptionId(); Assert.IsTrue(Verhoeff.ValidateVerhoeff(ArtificalDescriptionId.ToString())); }
public void ConceptIdHasCheckDigit() { GenerateArtificalConceptId(); Assert.IsTrue(Verhoeff.ValidateVerhoeff(ArtificalConceptId.ToString())); }
public void GenerateAKnownVerhoeff() { //known SCTID = 48176007 has check digit 7.4817600 should generate same check digit Assert.IsTrue("7" == Verhoeff.GenerateVerhoeff("4817600")); }
public void SelfValidateVerhoeff(string c) { Assert.IsTrue(Verhoeff.ValidateVerhoeff(c)); }
protected void btnSave_Click(object sender, EventArgs e) { lblErrMsg.Text = ""; var dateformat = DateTime.Parse(txtDOb.Text); string datea = dateformat.ToString("yyyy-MM-dd"); DateTime d1 = new DateTime(2017, 12, 31); DateTime d2 = Convert.ToDateTime(datea); dateclass date = new dateclass(); date = date.DateDifference(d1, d2); Int32 year = date.Pyear; Int32 month = date.Pmonth; Int32 day = date.Pday; double Age = year + month / 12 + day / 30.5; bool abc = Verhoeff.validateVerhoeff(TxtAdhaarNo.Text); if (abc == true) { con.Open(); SqlCommand cmd = new SqlCommand("Select Start_Date,End_Date FROM tblpost where Id ='" + ddlpost.SelectedValue + "'", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet dsAge = new DataSet(); da.Fill(dsAge); lblaadharerror.Text = ""; if (Age >= Convert.ToInt32(dsAge.Tables[0].Rows[0]["Start_Date"]) && rbtnGover.SelectedValue == "No" && Age <= Convert.ToInt32(dsAge.Tables[0].Rows[0]["End_Date"])) { entryobj.PostCode = ddlpost.SelectedValue; entryobj.CandidateName = txtName.Text.Trim(); entryobj.FatherHusbandName = txtFname.Text.Trim(); entryobj.MotherName = txtMname.Text.Trim(); entryobj.Aadharnumber = TxtAdhaarNo.Text.Trim(); entryobj.Retiredemployee = rbtnGover.SelectedValue; IFormatProvider provider = new System.Globalization.CultureInfo("en-CA", true); String datetime = txtDOb.Text.Trim(); Session["PostCode"] = ddlpost.SelectedValue; Session["PostName"] = ddlpost.SelectedItem.Text; Session["CandidateName"] = txtName.Text.Trim(); Session["FatherHusbandName"] = txtFname.Text.Trim(); Session["MotherName"] = txtMname.Text.Trim(); Session["DOB"] = txtDOb.Text.Trim(); CheckIfExist(); } else if (Age >= Convert.ToInt32(dsAge.Tables[0].Rows[0]["Start_Date"]) && Age <= 62 && rbtnGover.SelectedValue == "Yes") { entryobj.PostCode = ddlpost.SelectedValue; entryobj.CandidateName = txtName.Text.Trim(); entryobj.FatherHusbandName = txtFname.Text.Trim(); entryobj.MotherName = txtMname.Text.Trim(); IFormatProvider provider = new System.Globalization.CultureInfo("en-CA", true); String datetime = txtDOb.Text.Trim(); Session["PostCode"] = ddlpost.SelectedValue; Session["PostName"] = ddlpost.SelectedItem.Text; Session["CandidateName"] = txtName.Text.Trim(); Session["FatherHusbandName"] = txtFname.Text.Trim(); Session["MotherName"] = txtMname.Text.Trim(); Session["DOB"] = txtDOb.Text.Trim(); Session["Aadharnumber"] = txtDOb.Text.Trim(); CheckIfExist(); } else { if (rbtnGover.SelectedValue == "Yes" && Age >= Convert.ToInt32(dsAge.Tables[0].Rows[0]["Start_Date"]) && Age >= 62) { lblErrMsg.Text = "You are Over Age"; lblErrMsg.Visible = true; } else { if (Age <= Convert.ToInt32(dsAge.Tables[0].Rows[0]["Start_Date"]) && Age <= Convert.ToInt32(dsAge.Tables[0].Rows[0]["End_Date"])) { lblErrMsg.Text = "You are Under Age"; lblErrMsg.Visible = true; } else { lblErrMsg.Text = "You are Over Age"; lblErrMsg.Visible = true; } } } } else { lblaadharerror.Text = "Aadhar card is not valid"; } }