Ejemplo n.º 1
0
        public async Task <ActionResult <string> > Post(AK ak)
        {
            BigInteger a;
            uint       k;

            try
            {
                if (ak.a == null || ak.k == null)
                {
                    throw new FormatException();
                }
                a = BitOperation.BinStrToBigInteger(ak.a);
                k = Convert.ToUInt32(ak.k, 10);

                if (k > 31 || ak.a.Length > 32)
                {
                    throw new FormatException();
                }
            }
            catch (FormatException)
            {
                ModelState.AddModelError("Error", "Некорректные параметры");
                return(BadRequest(ModelState));
            }

            return(await Task.Run(() => BitOperation.BigIntegerToBinStr(BitOperation.GetBit(a, k))));
        }
    public static void func2()
    {
        Gun someAK = new AK();

        someAK.load(new AK_Mag());
        func1(someAK);
    }
    static void Main(string[] args)
    {
        Gun myGun = new AK();

        Console.WriteLine(myGun.load(new AK_Mag()));
        Console.WriteLine(myGun.load(new ShotGun_Mag()));
        func2();
    }
Ejemplo n.º 4
0
 private void Button3_Click_1(System.Object sender, System.EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(UName.Text.Trim()))
         {
             MessageBox.Show("Plz.. Enter UserName..");
         }
         else if (string.IsNullOrEmpty(OPassword.Text.Trim()))
         {
             MessageBox.Show("Plz.. Enter Old Password..");
         }
         else if (string.IsNullOrEmpty(NPassword.Text.Trim()) | string.IsNullOrEmpty(OPassword.Text.Trim()))
         {
             MessageBox.Show("Plz.. Enter New Password and Confirm it..");
         }
         else if (NPassword.Text != CPassword.Text)
         {
             MessageBox.Show("Plz.. Password You Typed Did Not Match .. Plz Enter New Password Both Boxes..");
         }
         else if (string.IsNullOrEmpty(AK.Text.Trim()))
         {
             MessageBox.Show("Plz.. Enter Access Key..");
         }
         else
         {
             con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=Bus_System;Integrated Security=True");
             con.Open();
             cmd = new SqlCommand("select username,password from Newuser where username='******' and password='******'", con);
             dr  = cmd.ExecuteReader();
             dr.Read();
             if (dr.HasRows)
             {
                 dr.Close();
                 cmd = new SqlCommand("select * from  AKPrivate where KeyIMP='" + AK.Text + "'", con);
                 dr  = cmd.ExecuteReader();
                 dr.Read();
                 if (dr.HasRows)
                 {
                     dr.Close();
                     cmd = new SqlCommand("Update Newuser Set password='******' Where username='******'", con);
                     cmd.ExecuteNonQuery();
                     MessageBox.Show("Password Changed Successfully..!");
                     AK.Clear();
                     NPassword.Clear();
                     CPassword.Clear();
                     OPassword.Clear();
                     UName.Clear();
                 }
                 else
                 {
                     MessageBox.Show("Wrong Access Key..!");
                 }
             }
             else
             {
                 MessageBox.Show("Wrong Username and Password..!");
             }
             dr.Close();
             con.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Sorry.. Something Went Wrong..! Or " + ex.Message);
     }
 }