Example #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        Vehicle_Info v_info = new Vehicle_Info();
        Vehicle_Sp   v_sp   = new Vehicle_Sp();
        Memb_Sp      m_sp   = new Memb_Sp();



        string uname_recieved = Session["username"].ToString();
        int    no_of_bus      = m_sp.return_nob(uname_recieved) - i;

        v_info.Bus_Reg_No = Txtbrno.Text;
        if (v_sp.CompareBusRegNo(v_info.Bus_Reg_No) == 0)
        {
            v_info.BusName  = Txtbname.Text;
            v_info.Model_No = Txtmno.Text;

            int own_id;
            own_id = (m_sp.GetMaxCode() - 1);

            v_info.Own_No = own_id;
            v_sp.Add_Vehicles(v_info);

            i++;

            if (no_of_bus <= 1)
            {
                i = 0;

                Response.Redirect("admin_regn.aspx");
            }
            else
            {
                Response.Redirect("admin_vehicle_info.aspx");
            }
            Txtbname.Text = "";
            Txtbrno.Text  = "";
            Txtmno.Text   = "";
        }
        else
        {
            lbexists.Text = "This Regno already exists, To see more about it!!//add link btn to vehicle view grid";
        }
    }
Example #2
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;
        }
    }