protected string SaveImageFile()
        {
            var PhotoPath = "";

            try
            {
                if (ClientPhoto != null)
                {
                    //Save the photo in Folder
                    var    fileExt  = Path.GetExtension(ClientPhoto.FileName);
                    string fileName = Guid.NewGuid() + fileExt;
                    var    subPath  = Server.MapPath("~/uploadfiles");

                    //Check SubPath Exist or Not
                    if (!Directory.Exists(subPath))
                    {
                        Directory.CreateDirectory(subPath);
                    }
                    //End : Check SubPath Exist or Not

                    var path = Path.Combine(subPath, fileName);
                    ClientPhoto.SaveAs(path);

                    PhotoPath = clsobj.GetURL() + "/uploadfiles/" + fileName;
                }
            }
            catch
            {
            }
            return(PhotoPath);
        }
Пример #2
0
        //protected void GrdBlogList_RowCommand(object sender, GridViewCommandEventArgs e)
        //{
        //    int id = 0;
        //    if (e.CommandName == "Deleterec")
        //    {
        //        id = Convert.ToInt32(e.CommandArgument);
        //        int result = clsobj.DeleteDreamHouse(id);
        //        //FillGridData();
        //    }
        //    else if (e.CommandName == "Editrec")
        //    {
        //        id = Convert.ToInt32(e.CommandArgument);
        //        DataTable dt = new DataTable();
        //        dt = clsobj.GetDreamHousebyID(id);
        //        txtName.Text = dt.Rows[0]["Title"].ToString();


        //    }
        //    else
        //    {

        //    }
        //}

        #endregion PageListGrid Events & Method

        #region Button Click
        protected void btnUploadImage_Click(object sender, EventArgs e)
        {
            try
            {
                var photopath = "";

                if (ClientPhoto.PostedFile != null && ClientPhoto.PostedFile.FileName != "")
                {
                    //Save the photo in Folder
                    var    fileExt  = Path.GetExtension(ClientPhoto.FileName);
                    string fileName = Guid.NewGuid() + fileExt;
                    var    subPath  = Server.MapPath("~/uploadfiles");

                    //Check SubPath Exist or Not
                    if (!Directory.Exists(subPath))
                    {
                        Directory.CreateDirectory(subPath);
                    }
                    //End : Check SubPath Exist or Not

                    var path = Path.Combine(subPath, fileName);
                    ClientPhoto.SaveAs(path);

                    photopath = clsobj.GetURL() + "/uploadfiles/" + fileName;
                }

                var Status = rblList.SelectedValue;
                var gender = Gender.SelectedValue;
                var source = Source.SelectedValue;


                int AdminClientId = clsobj.InsertAdminClient(txtName.Text, txtDob.Text, txtEmail.Text, txtPhoneNo.Text, txtAddress.Text, source, Status, gender, photopath, Remarks.Text);

                txtName.Text    = "";
                txtPhoneNo.Text = "";
                txtDob.Text     = "";
                txtEmail.Text   = "";
                txtAddress.Text = "";

                Response.Redirect("~/Admin/AdminClientList.aspx", false);
            }

            catch (Exception ex)
            {
                // ErrorLogging.WriteLog(ex.ToString());
            }
        }