protected void btnSave_Click(object sender, EventArgs e) { if (txtAddress.Text != "" && txtFullName.Text != "" && txtMobile.Text != "" && ddlDonerBloodGroup.SelectedValue != "0" && ddlGender.SelectedValue != "0") { string Password = chk.stringCheck("select Password from DonerRegistation where DonerID='" + Session["DonerUserID"].ToString() + "' "); string Image = Session["DonerImage"].ToString(); if (txtPassword.Text != "") { Password = txtPassword.Text; } string name = ""; int err = 0; if (ProfilePhotoUploader.HasFile) { string file = Path.GetExtension(ProfilePhotoUploader.FileName.ToLower()); if (file == ".jpg") { string ext = ".jpg"; name = DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss"); ProfilePhotoUploader.SaveAs(Server.MapPath("~/Donor/Temp/" + name + ext)); string path = Server.MapPath("~/Donor/Temp/" + name + ext); string DocDetails = Server.MapPath("~/Donor/Details/" + name + ext); string DocFeedBack = Server.MapPath("~/Donor/FeedBack/" + name + ext); string Pageview = Server.MapPath("~/Donor/PageView/" + name + ext); string DoctorProfile = Server.MapPath("~/Donor/Profile/" + name + ext); //-------------------------------Doctor Details image System.Drawing.Image obj; Bitmap newimage; obj = System.Drawing.Image.FromFile(path); ImageFormat imgformat = obj.RawFormat; newimage = new Bitmap(obj, 170, 170); newimage.Save(DocDetails, imgformat); //----------------------------Doctor FeedBack Image System.Drawing.Image obj2; Bitmap newimage2; obj2 = System.Drawing.Image.FromFile(path); ImageFormat imgformat2 = obj2.RawFormat; newimage2 = new Bitmap(obj2, 80, 80); newimage2.Save(DocFeedBack, imgformat2); //-------------------------- Doctor Page view System.Drawing.Image obj3; Bitmap newimage3; obj3 = System.Drawing.Image.FromFile(path); ImageFormat imgformat3 = obj3.RawFormat; newimage3 = new Bitmap(obj3, 120, 120); newimage3.Save(Pageview, imgformat3); //------------------------- Doctor Profile Image System.Drawing.Image obj4; Bitmap newimage4; obj4 = System.Drawing.Image.FromFile(path); ImageFormat imgformat4 = obj4.RawFormat; newimage4 = new Bitmap(obj4, 200, 200); newimage4.Save(DoctorProfile, imgformat4); Image = name + ext; } else { err++; lblResult.Text = "Image is only .jpg"; } } SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "update DonerRegistation set Fullname='" + txtFullName.Text + "',Password='******',BloodGroup='" + ddlDonerBloodGroup.SelectedItem.ToString() + "',Mobile='" + txtMobile.Text + "',Gender='" + ddlGender.SelectedValue.ToString() + "',Photo='" + Image + "',Category='" + ddlDonerBloodGroup.SelectedValue.ToString() + "' where DonerID='" + Session["DonerUserID"].ToString() + "'"; con.Open(); cmd.ExecuteNonQuery(); con.Close(); if (err == 0) { lblResult.Text = "Update Sucessfully."; } } else { lblResult.Text = "Fill All Froms Then Click Update."; } }
protected void btnSave_Click(object sender, EventArgs e) { lblResult.Text = ""; int err = 0; bool Password = false; bool Photo_Upload = false; string EXT = ""; if (txtPassword.Text != "") { if (txtRePassword.Text != "") { if (txtPassword.Text != txtRePassword.Text) { err++; lblResult.ForeColor = System.Drawing.Color.Red; lblResult.Text += "Password Not Match.<br/>"; } else { Password = true; } } else { err++; lblResult.ForeColor = System.Drawing.Color.Red; lblResult.Text += "Type Retry Password!<br/>"; } } if (ProfilePhotoUploader.HasFile) { string File_Ext = Path.GetExtension(ProfilePhotoUploader.FileName.ToLower()); if (File_Ext == ".jpg") { EXT = ".jpg"; Photo_Upload = true; } else if (File_Ext == ".jpeg") { EXT = ".jpeg"; Photo_Upload = true; } else if (File_Ext == ".png") { EXT = ".png"; Photo_Upload = true; } else { err++; lblResult.ForeColor = System.Drawing.Color.Red; lblResult.Text += "Image Upload (*.jpg, *.jpeg, *.png)<br/>"; } } if (err == 0) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; string DoctorID = Session["DoctorID"].ToString(); if (Password == true) { cmd.CommandText = "update DoctorRegistation set Password='******' where DoctorID='" + Session["DoctorID"].ToString() + "'"; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } if (Photo_Upload == true) { ProfilePhotoUploader.SaveAs(Server.MapPath("~/Doctor/Temp/" + DoctorID + EXT)); Verify vr = new Verify(); vr.ImageEdit(DoctorID + EXT); cmd.CommandText = "update DoctorRegistation set DoctorPhoto='" + DoctorID + EXT + "' where DoctorID='" + DoctorID + "'"; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } cmd.CommandText = string.Format(@"update DoctorRegistation set FullName='{0}',Qualification='{1}',Expertise='{2}',PresentProfession='{3}',Telephone='{4}',Address='{5}',DoctorDetails='{6}' where DoctorID='{7}' ", txtFullName.Text, txtQualification.Text, txtExpertise.Text, txtPresentProfession.Text, txtTelephone.Text, txtAddress.Text, txtDoctorBio.Text, DoctorID); con.Open(); cmd.ExecuteNonQuery(); con.Close(); lblResult.ForeColor = System.Drawing.Color.Green; lblResult.Text = "Save"; } }