Esempio n. 1
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        lbusrex.Visible = false;

        int t1 = 0;

        Memb_Info info = new Memb_Info();
        Memb_Sp   sp   = new Memb_Sp();

        t1 = int.Parse(DropDownList1.SelectedValue.ToString());

        info.Usrname    = Txtusrname.Text;
        info.Password   = Txtpw.Text;
        info.MemberName = "";
        info.Age        = 0;
        info.Type       = t1;
        info.Address    = "";
        info.E_Mail     = "";
        info.Mobile     = "";
        info.Nob        = 0;
        info.Phot       = "";

        //info.Type = t1;
        if (sp.Compareusername(info.Usrname) == 0)
        {
            sp.Add(info);
            Txtusrname.Text = "";
            Response.Redirect("admin_home.aspx");
        }
        else
        {
            lbusrex.Text    = "UserName Exists!!";
            lbusrex.Visible = true;
        }
    }
Esempio n. 2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        int    verify = 2; // entry "2" in authorisation field represents an verified/authorised member.
        string dest   = "";
        bool   flag   = true;

        Memb_Info info = new Memb_Info();
        Memb_Sp   sp   = new Memb_Sp();

        string  imagepath = "";
        Boolean fileOK    = false;
        String  path      = Server.MapPath("~/Photos/Owners/");

        if (FileUpload1.HasFile)
        {
            String   fileExtension     = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
            String[] allowedExtensions =
            { ".gif", ".png", ".jpeg", ".jpg" };
            for (int i = 0; i < allowedExtensions.Length; i++)
            {
                if (fileExtension == allowedExtensions[i])
                {
                    fileOK = true;
                }
            }
        }

        if (fileOK)
        {
            try
            {
                imagepath = path + FileUpload1.FileName;
                FileUpload1.PostedFile.SaveAs(imagepath);
                FileInfo f = new FileInfo(imagepath);
                dest = new Memb_Sp().GetMaxCode() + "." + f.Name.Split('.')[1];



                info.MemberName = txtuname.Text;
                info.Age        = int.Parse(txtage.Text);
                info.Password   = txtpw.Text;
                info.Address    = txtadd.Text;
                info.E_Mail     = txtemid.Text;
                info.Mobile     = txtmob.Text;
                info.Nob        = int.Parse(txtnob.Text);

                info.Usrname = txtusrname.Text;
                if (sp.Compareusername(info.Usrname) != 0)
                {
                    flag = false;
                }

                if (RadioButton1.Checked)
                {
                    info.Authorised = verify;
                }

                if (flag == true)
                {
                    f.CopyTo(path + dest);
                    info.Phot = dest;



                    sp.Add(info);

                    txtusrname.Text      = "";
                    txtuname.Text        = "";
                    txtage.Text          = "";
                    txtpw.Text           = "";
                    txtvpw.Text          = "";
                    txtadd.Text          = "";
                    txtemid.Text         = "";
                    txtmob.Text          = "";
                    txtnob.Text          = "";
                    RadioButton3.Checked = true;
                    lbfile.Visible       = false;
                    lbusrname1.Visible   = false;
                    if (RadioButton1.Checked)
                    {
                        Session["username"] = info.Usrname;    //for reference to vehicle details entry
                        Session["own_name"] = info.MemberName; //-do-
                        Response.Redirect("admin_vehicle_info.aspx");
                    }
                }
                else
                {
                    lbusrname1.Text    = "user name exists.!!";
                    lbusrname1.Visible = true;
                }
                f = new FileInfo(imagepath);
                f.Delete();
            }

            catch (Exception ex)
            {
                lbfile.Text    = "File could not be uploaded.";
                lbfile.Visible = true;
            }
        }
        else
        {
            lbfile.Text    = "Cannot accept files of this type.";
            lbfile.Visible = true;
        }
    }
Esempio n. 3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string dest = "";
        bool   flag = true;

        Memb_Info info = new Memb_Info();
        Memb_Sp   sp   = new Memb_Sp();

        info.MemberName = txtuname.Text;
        info.Age        = int.Parse(txtage.Text);
        info.Password   = txtpw.Text;
        info.Address    = txtadd.Text;
        info.E_Mail     = txtemid.Text;
        info.Mobile     = txtmob.Text;
        info.Nob        = int.Parse(txtnob.Text);
        info.Usrname    = txtusrname.Text;

        if (sp.Compareusername(info.Usrname) != 0)
        {
            flag = false;
        }


        string  imagepath = "";
        Boolean fileOK    = false;
        String  path      = Server.MapPath("~/Photos/Owners/");

        if (FileUpload1.HasFile)
        {
            String   fileExtension     = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
            String[] allowedExtensions =
            { ".gif", ".png", ".jpeg", ".jpg" };
            for (int i = 0; i < allowedExtensions.Length; i++)
            {
                if (fileExtension == allowedExtensions[i])
                {
                    fileOK = true;
                }
            }
        }

        if (fileOK)
        {
            try
            {
                imagepath = path + FileUpload1.FileName;
                FileUpload1.PostedFile.SaveAs(imagepath);
                FileInfo f = new FileInfo(imagepath);
                dest = new Memb_Sp().GetMaxCode() + "." + f.Name.Split('.')[1];
                if (flag == true)
                {
                    f.CopyTo(path + dest);


                    info.Phot = dest;
                    sp.Add(info);

                    txtuname.Text   = "";
                    txtage.Text     = "";
                    txtpw.Text      = "";
                    txtvpw.Text     = "";
                    txtadd.Text     = "";
                    txtemid.Text    = "";
                    txtmob.Text     = "";
                    txtnob.Text     = "";
                    txtusrname.Text = "";


                    int id = (sp.GetMaxCode() - 1);

                    Memb_Info inf = new Memb_Info();
                    inf             = sp.ViewMember(id);
                    lbid.Text       = inf.No.ToString();
                    lbusrname2.Text = inf.Usrname;
                    lbhiname.Text   = inf.MemberName;

                    MultiView1.SetActiveView(View2);
                }
                else
                {
                    lbusrname1.Text    = "usrer name exists!!.";
                    lbusrname1.Visible = true;
                }
                f = new FileInfo(imagepath);
                f.Delete();
            }
            catch (Exception ex)
            {
                lbfile.Text    = "File could not be uploaded!!.";
                lbfile.Visible = true;
            }
        }
        else
        {
            lbfile.Text    = "Cannot accept files of this type!!.";
            lbfile.Visible = true;
        }
    }