Exemple #1
0
 protected void centerSaveButton_Click(object sender, EventArgs e)
 {
     if (centerNameTextBox.Text == "" || districtDropDownList.SelectedIndex == -1 ||
         thanaDropDownList.SelectedIndex == -1)
     {
         msgLabel.Text = "Please enter the value";
     }
     else
     {
         aCenter.CenterName = centerNameTextBox.Text;
         aCenter.CenterCode = GenerateCenterCodeCode();
         // string password = CreateRandomPassword();
         string password = CreateRandomPassword();
         string key      = "pavel";
         byte[] hashKey  = aManager.GetHashKey(key);
         aCenter.CenterPassword = aManager.Encrypt(hashKey, password);
         aCenter.ThanaId        = Convert.ToInt32(thanaDropDownList.SelectedValue);
         string test = aManager.Save(aCenter);
         if (test == "Saved Succesfully")
         {
             string decrptedPassword = aManager.Decrypt(hashKey, aCenter.CenterPassword);
             Session["centerName"] = aCenter.CenterName;
             Session["centerCode"] = aCenter.CenterCode;
             Session["password"]   = decrptedPassword;
             //Response.Redirect("DisplayCenter.aspx?centerName=" + aCenter.CenterName + "&centerCode=" +
             //                  aCenter.CenterCode + "&password="******"DisplayCenterPage.aspx");
         }
         else
         {
             msgLabel.Text = test;
         }
     }
 }
Exemple #2
0
        protected void savecentralControlEntryButton_OnClick(object sender, EventArgs e)
        {
            string key = "i am Ram";

            byte[] hashKey = centerManager.GetHashKey(key);

            center.Name = nameTextBox.Text;

            center.DistrictId = int.Parse(districtDropDownList.SelectedValue.ToString());

            center.ThanaId = int.Parse(thanaDropDownList.SelectedValue.ToString());

            string districtname = districtDropDownList.SelectedItem.Text;
            string thananame    = thanaDropDownList.SelectedItem.Text;

            center.Code = GetCode(districtname, thananame);

            string password = GetPassword();

            center.Password = centerManager.Encrypt(hashKey, password);



            if (!centerManager.HasThisCenterExists(center.Name, center.ThanaId))
            {
                centerManager.Insert(center);


                string decryptedpassword = centerManager.Decrypt(hashKey, center.Password);

                Response.Redirect("CenterInfoUI.aspx?districtName=" + districtname + "&thanaName=" + thananame +
                                  "&centerName=" + center.Name + "&centerCode=" + center.Code + "&centerPassword="******"Error";
            }
        }