protected void Button5_Click(object sender, EventArgs e) { System.Web.UI.HtmlControls.HtmlTextArea textArea = (System.Web.UI.HtmlControls.HtmlTextArea)(form1.FindControl("experience")); String experiences = textArea.Value; int user = Convert.ToInt32(Session["id"]); DateTime start_date = Convert.ToDateTime(startDate.Text).Date; DateTime end_date = Convert.ToDateTime(endDate.Text).Date; if (experience.Equals("")) { experiencesError.Text = "Ju lutem plotesoni fushen!"; } else { if (start_date > end_date) { experiencesError.Text = "Ju lutem jepni inputin e duhur"; } else { NormalUserDB.addExperience(experiences, start_date, end_date, user); textArea.Value = ""; ListView4.DataBind(); } } //DateTime start_date = DateTime.ParseExact(startDate.Text,"dd-MM-yyyy", null); //DateTime end_date = DateTime.ParseExact(endDate.Text, "dd-MM-yyyy", null); }
protected void Button2_Click(object sender, EventArgs e) { String opField = operationField.Items[operationField.SelectedIndex].Value; System.Web.UI.HtmlControls.HtmlTextArea textArea = (System.Web.UI.HtmlControls.HtmlTextArea)(form1.FindControl("description")); String description = textArea.Value; System.Web.UI.HtmlControls.HtmlTextArea textArea2 = (System.Web.UI.HtmlControls.HtmlTextArea)(form1.FindControl("skills")); String skills = textArea2.Value; System.Web.UI.HtmlControls.HtmlTextArea textArea3 = (System.Web.UI.HtmlControls.HtmlTextArea)(form1.FindControl("education")); String education = textArea3.Value; int user = Convert.ToInt32(Session["id"]); String type = jobtype.Items[jobtype.SelectedIndex].Value; String gendertype = gender.Items[gender.SelectedIndex].Value; if (description.Equals("") || skills.Equals("") || education.Equals("") || jobtitle.Text.Equals("")) { errors.Text = "Ju lutem plotesoni te gjitha fushat!"; } else { CompanyDB.addNotifications(opField, Convert.ToInt32(type), experience.Text, skills, gendertype, education, description, jobtitle.Text, user); Response.Redirect("mainPageCompany.aspx"); } }
protected void Page_Init() { this.EnsureChildControls(); this._book_name = Request.QueryString["book"]; this._delimiter = (System.Web.UI.HtmlControls.HtmlInputText) this.SharpUI.FindControl("delimiter"); this._data = (System.Web.UI.HtmlControls.HtmlTextArea) this.SharpUI.FindControl("data"); System.Web.UI.WebControls.Label addrname = (System.Web.UI.WebControls.Label) this.SharpUI.FindControl("addressbookLabelItem"); if (addrname != null) { addrname.Text = this._book_name; } this.SharpUI.nextPageImageButton.Enabled = false; this.SharpUI.prevPageImageButton.Enabled = false; this.SharpUI.refreshPageImageButton.Enabled = false; }
protected void send_Click(object sender, EventArgs e) { String email = ""; int id = Convert.ToInt32(Session["id"]); String query = "SELECT * FROM Users WHERE id = @id"; SqlConnection connect = UsersDB.GetConnection(); SqlCommand command = new SqlCommand(query, connect); command.Parameters.AddWithValue("@id", id); connect.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { email = Convert.ToString(reader["Email"]); } System.Web.UI.HtmlControls.HtmlTextArea textArea = (System.Web.UI.HtmlControls.HtmlTextArea)(form1.FindControl("message")); String message = textArea.Value; String body = message; System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage(); SmtpClient sc = new SmtpClient(); try { m.From = new MailAddress("*****@*****.**", "*****@*****.**"); m.To.Add(new MailAddress(useremail.Text, useremail.Text)); m.Bcc.Add(new MailAddress(email, email)); String usertype = "normal"; m.Subject = subject.Text; m.IsBodyHtml = true; m.Body = body; sc.Host = "smtp.gmail.com"; sc.Port = 587; sc.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Serena123!"); sc.EnableSsl = true; sc.Send(m); textArea.Value = ""; Label5.Text = "Email-i u dergua me sukses!"; } catch (Exception ex) { } }
protected void Button4_Click(object sender, EventArgs e) { System.Web.UI.HtmlControls.HtmlTextArea textArea = (System.Web.UI.HtmlControls.HtmlTextArea)(form1.FindControl("otherSkills")); String otherSkill = textArea.Value; if (otherSkill.Equals("")) { otherSkillsError.Text = "Ju lutem plotesoni fushen!"; } else { int user = Convert.ToInt32(Session["id"]); NormalUserDB.addOtherSkill(otherSkill, user); textArea.Value = ""; ListView3.DataBind(); } }
protected void Button1_Click(object sender, EventArgs e) { System.Web.UI.HtmlControls.HtmlTextArea textArea = (System.Web.UI.HtmlControls.HtmlTextArea)(form1.FindControl("description")); String textarea = textArea.Value; int user = Convert.ToInt32(Session["id"]); String opfield = operationField.Items[operationField.SelectedIndex].Value; if (name.Text.Equals("") || contactnumber.Text.Equals("") || contactemail.Text.Equals("") || textarea.Equals("") || state.Text.Equals("") || city.Text.Equals("") || street.Text.Equals("")) { Label8.Text = "Ju lutem plotesoni te gjitha fushat!"; } else { CompanyDB.addCompanyInfo(opfield, contactnumber.Text, contactemail.Text, textarea, user, name.Text); UsersDB.addAddress(state.Text, city.Text, street.Text, user); //UsersDB.addSocialMedia(company.Text, facebook.Text, twitter.Text, linkedin.Text, instagram.Text,user); Response.Redirect("companyProfile.aspx"); } }
protected void Button1_Click(object sender, EventArgs e) { String opField = Select1.Items[Select1.SelectedIndex].Value; System.Web.UI.HtmlControls.HtmlTextArea textArea = (System.Web.UI.HtmlControls.HtmlTextArea)(form1.FindControl("description")); String description = textArea.Value; int user = Convert.ToInt32(Session["id"]); if (jobtitle.Text.Equals("") || description.Equals("")) { Label5.Text = "Duhet ti plotesoni te gjitha fushat!"; } else { NormalUserDB.addNottification(jobtitle.Text, opField, Convert.ToInt32(Select2.Items[Select2.SelectedIndex].Value), description, user); jobtitle.Text = ""; textArea.Value = ""; ListView1.DataBind(); } }
protected void Button1_Click2(object sender, EventArgs e) { String opField = operationField.Items[operationField.SelectedIndex].Value; String contactNr = contactNumber.Text; String contactEm = contactEmail.Text; System.Web.UI.HtmlControls.HtmlTextArea textArea = (System.Web.UI.HtmlControls.HtmlTextArea)(form1.FindControl("description")); String description = textArea.Value; int user = Convert.ToInt32(Session["id"]); if (contactEm.Equals("") || contactNr.Equals("") || description.Equals("") || state.Text.Equals("") || city.Text.Equals("") || street.Text.Equals("")) { infoError.Text = "Ju lutem plotesoni te gjitha fushat!"; } else { NormalUserDB.normalUserInfo(opField, contactNr, contactEm, description, user); UsersDB.addAddress(state.Text, city.Text, street.Text, user); //UsersDB.addSocialMedia("", facebook.Text, twitter.Text, linkedin.Text, instagram.Text, user); Response.Redirect("profile.aspx"); } }
protected void Page_Init() { this.EnsureChildControls(); this._book_name = Request.QueryString["book"]; this._delimiter=(System.Web.UI.HtmlControls.HtmlInputText)this.SharpUI.FindControl("delimiter"); this._data=(System.Web.UI.HtmlControls.HtmlTextArea)this.SharpUI.FindControl("data"); System.Web.UI.WebControls.Label addrname = (System.Web.UI.WebControls.Label)this.SharpUI.FindControl("addressbookLabelItem"); if ( addrname!=null ) { addrname.Text = this._book_name; } this.SharpUI.nextPageImageButton.Enabled = false; this.SharpUI.prevPageImageButton.Enabled = false; this.SharpUI.refreshPageImageButton.Enabled = false; }
/// <summary> /// 清理表单 /// </summary> /// <param name="control"></param> public static void ClearForm(WebUI.Control control) { if (control == null) { return; } foreach (WebUI.Control ctl in control.Controls) { Type type = ctl.GetType(); #region 处理服务器控件 if (type == typeof(WebUI.WebControls.TextBox))//文本框 { WebUI.WebControls.TextBox box = ((WebUI.WebControls.TextBox)ctl); box.Text = ""; if (box.Attributes["isNumber"] != null) { box.Text = "0"; } } else if (type == typeof(WebUI.WebControls.DropDownList))//选择框 { ((WebUI.WebControls.DropDownList)ctl).SelectedIndex = -1; } else if (type == typeof(WebUI.WebControls.HiddenField))//隐藏域 { ((WebUI.WebControls.HiddenField)ctl).Value = ""; } else if (type == typeof(WebUI.WebControls.RadioButton))//单选框 { WebUI.WebControls.RadioButton rb = (WebUI.WebControls.RadioButton)ctl; rb.Checked = false; } else if (type == typeof(WebUI.WebControls.CheckBox))//复选框 { WebUI.WebControls.CheckBox ck = (WebUI.WebControls.CheckBox)ctl; ck.Checked = false; } else if (type == typeof(WebUI.WebControls.CheckBoxList))//复选框列表 { WebUI.WebControls.CheckBoxList ck = (WebUI.WebControls.CheckBoxList)ctl; foreach (WebUI.WebControls.ListItem li in ck.Items) { li.Selected = false; } } else if (type == typeof(WebUI.WebControls.RadioButtonList))//单框列表 { WebUI.WebControls.RadioButtonList ck = (WebUI.WebControls.RadioButtonList)ctl; foreach (WebUI.WebControls.ListItem li in ck.Items) { li.Selected = false; } } else if (type == typeof(WebUI.WebControls.ListBox))//列表框 { WebUI.WebControls.ListBox ck = (WebUI.WebControls.ListBox)ctl; foreach (WebUI.WebControls.ListItem li in ck.Items) { li.Selected = false; } } #endregion #region 处理不同Html控件 else if (type == typeof(WebUI.HtmlControls.HtmlInputText))//文本域 { WebUI.HtmlControls.HtmlInputText ct = (WebUI.HtmlControls.HtmlInputText)ctl; ct.Value = ""; if (ct.Attributes["isNumber"] != null) { ct.Value = "0"; } } else if (type == typeof(WebUI.HtmlControls.HtmlTextArea))//文本域 { WebUI.HtmlControls.HtmlTextArea ct = (WebUI.HtmlControls.HtmlTextArea)ctl; ct.Value = ""; } else if (type == typeof(WebUI.HtmlControls.HtmlSelect))//选择域 { WebUI.HtmlControls.HtmlSelect ct = (WebUI.HtmlControls.HtmlSelect)ctl; ct.SelectedIndex = -1; } else if (type == typeof(WebUI.HtmlControls.HtmlInputHidden))////隐藏域 { WebUI.HtmlControls.HtmlInputHidden ct = (WebUI.HtmlControls.HtmlInputHidden)ctl; ct.Value = ""; if (ct.Attributes["isNumber"] != null) { ct.Value = "0"; } } else if (type == typeof(WebUI.HtmlControls.HtmlInputRadioButton))//单选域 { WebUI.HtmlControls.HtmlInputRadioButton rb = (WebUI.HtmlControls.HtmlInputRadioButton)ctl; rb.Checked = false; } else if (type == typeof(WebUI.HtmlControls.HtmlInputCheckBox))//复选域 { WebUI.HtmlControls.HtmlInputCheckBox ck = (WebUI.HtmlControls.HtmlInputCheckBox)ctl; ck.Checked = false; } else if (type == typeof(WebUI.HtmlControls.HtmlInputPassword))//密码域 { WebUI.HtmlControls.HtmlInputPassword ck = (WebUI.HtmlControls.HtmlInputPassword)ctl; ck.Value = ""; } #endregion } }
/// <summary> /// 填充model /// </summary> /// <param name="entity"></param> /// <param name="control"></param> public static void FillModel(Object entity, WebUI.Control control) { if (entity == null || control == null) { return; } NameValueCollection formData = HttpContext.Current.Request.Form; PropertyInfo[] propertyList = entity.GetProperties(); foreach (PropertyInfo pi in propertyList) { string ctlId = string.Format(IdFormat, pi.Name); WebUI.Control ctl = control.FindControl(ctlId); if (ctl == null) { #region 处理HMTL标签 if (formData[ctlId] != null) { entity.SetPropertyValue(pi.Name, formData[ctlId]); } #endregion continue; } Type ctlType = ctl.GetType(); #region 处理服务器控件 if (ctlType == typeof(WebUI.WebControls.TextBox))//文本框 { entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.TextBox)ctl).Text); } else if (ctlType == typeof(WebUI.WebControls.Image))//图片 { entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.Image)ctl).ImageUrl); } else if (ctlType == typeof(WebUI.WebControls.DropDownList))//选择框 { entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.DropDownList)ctl).SelectedValue); } else if (ctlType == typeof(WebUI.WebControls.HiddenField))//隐藏域 { entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.HiddenField)ctl).Value); } else if (ctlType == typeof(WebUI.WebControls.RadioButton))//单选框 { WebUI.WebControls.RadioButton rb = (WebUI.WebControls.RadioButton)ctl; if (rb.Checked) { entity.SetPropertyValue(pi.Name, rb.Text); } else { entity.SetPropertyValue(pi.Name, ""); } } else if (ctlType == typeof(WebUI.WebControls.CheckBox))//复选框 { WebUI.WebControls.CheckBox ck = (WebUI.WebControls.CheckBox)ctl; if (ck.Checked) { entity.SetPropertyValue(pi.Name, ck.Text); } else { entity.SetPropertyValue(pi.Name, ""); } } else if (ctlType == typeof(WebUI.WebControls.CheckBoxList))//复选框列表 { WebUI.WebControls.CheckBoxList ck = (WebUI.WebControls.CheckBoxList)ctl; string rs = ""; foreach (WebUI.WebControls.ListItem li in ck.Items) { if (li.Selected) { rs += "," + li.Value; } } if (rs.Length > 1) { rs = rs.Substring(1); } entity.SetPropertyValue(pi.Name, rs); } else if (ctlType == typeof(WebUI.WebControls.RadioButtonList))//单框列表 { WebUI.WebControls.RadioButtonList ck = (WebUI.WebControls.RadioButtonList)ctl; entity.SetPropertyValue(pi.Name, ck.SelectedValue); } else if (ctlType == typeof(WebUI.WebControls.ListBox))//列表框 { WebUI.WebControls.ListBox ck = (WebUI.WebControls.ListBox)ctl; string rs = ""; foreach (WebUI.WebControls.ListItem li in ck.Items) { if (li.Selected) { rs += "," + li.Value; } } if (rs.Length > 1) { rs = rs.Substring(1); } entity.SetPropertyValue(pi.Name, rs); } #endregion #region 处理不同Html控件 else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputText))//文本域 { WebUI.HtmlControls.HtmlInputText ct = (WebUI.HtmlControls.HtmlInputText)ctl; entity.SetPropertyValue(pi.Name, ct.Value); } else if (ctlType == typeof(WebUI.HtmlControls.HtmlTextArea))//文本域 { WebUI.HtmlControls.HtmlTextArea ct = (WebUI.HtmlControls.HtmlTextArea)ctl; entity.SetPropertyValue(pi.Name, ct.Value); } else if (ctlType == typeof(WebUI.HtmlControls.HtmlSelect))//选择域 { WebUI.HtmlControls.HtmlSelect ct = (WebUI.HtmlControls.HtmlSelect)ctl; entity.SetPropertyValue(pi.Name, ct.Items[ct.SelectedIndex].Value); } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputHidden))////隐藏域 { WebUI.HtmlControls.HtmlInputHidden ct = (WebUI.HtmlControls.HtmlInputHidden)ctl; entity.SetPropertyValue(pi.Name, ct.Value); } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputRadioButton))//单选域 { WebUI.HtmlControls.HtmlInputRadioButton rb = (WebUI.HtmlControls.HtmlInputRadioButton)ctl; if (rb.Checked) { entity.SetPropertyValue(pi.Name, rb.Value); } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputCheckBox))//复选域 { WebUI.HtmlControls.HtmlInputCheckBox ck = (WebUI.HtmlControls.HtmlInputCheckBox)ctl; if (ck.Checked) { entity.SetPropertyValue(pi.Name, ck.Value); } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputPassword))//密码域 { WebUI.HtmlControls.HtmlInputPassword ck = (WebUI.HtmlControls.HtmlInputPassword)ctl; entity.SetPropertyValue(pi.Name, ck.Value); } #endregion } }
/// <summary> /// 填充表单 /// </summary> /// <param name="entity"></param> /// <param name="control"></param> public static void FillForm(WebUI.Control control, Object entity) { if (entity == null || control == null) { return; } PropertyInfo[] propertyList = entity.GetProperties(); foreach (PropertyInfo pi in propertyList) { WebUI.Control ctl = control.FindControl(string.Format(IdFormat, pi.Name)); if (ctl == null) { continue; } Type ctlType = ctl.GetType(); #region 处理服务器控件 if (ctlType == typeof(WebUI.WebControls.TextBox))//文本框 { if (entity.GetPropertyValue(pi.Name) != null) { ((WebUI.WebControls.TextBox)ctl).Text = entity.GetPropertyValue(pi.Name).ToString(); } } else if (ctlType == typeof(WebUI.WebControls.Image))//图片 { if (entity.GetPropertyValue(pi.Name) != null) { string imageUrl = entity.GetPropertyValue(pi.Name).ToString(); if (!string.IsNullOrEmpty(imageUrl)) { ((WebUI.WebControls.Image)ctl).ImageUrl = imageUrl; } } } else if (ctlType == typeof(WebUI.WebControls.DropDownList))//选择框 { if (entity.GetPropertyValue(pi.Name) != null) { ((WebUI.WebControls.DropDownList)ctl).SelectedValue = entity.GetPropertyValue(pi.Name).ToString(); } } else if (ctlType == typeof(WebUI.WebControls.HiddenField))//隐藏域 { if (entity.GetPropertyValue(pi.Name) != null) { ((WebUI.WebControls.HiddenField)ctl).Value = entity.GetPropertyValue(pi.Name).ToString(); } } else if (ctlType == typeof(WebUI.WebControls.RadioButton))//单选框 { WebUI.WebControls.RadioButton rb = (WebUI.WebControls.RadioButton)ctl; if (entity.GetPropertyValue(pi.Name) != null) { rb.Checked = entity.GetPropertyValue(pi.Name).ToString() == rb.Text ? true : false; } } else if (ctlType == typeof(WebUI.WebControls.CheckBox))//复选框 { WebUI.WebControls.CheckBox ck = (WebUI.WebControls.CheckBox)ctl; if (entity.GetPropertyValue(pi.Name) != null) { ck.Checked = entity.GetPropertyValue(pi.Name).ToString() == ck.Text ? true : false; } } else if (ctlType == typeof(WebUI.WebControls.CheckBoxList))//复选框列表 { WebUI.WebControls.CheckBoxList ck = (WebUI.WebControls.CheckBoxList)ctl; if (entity.GetPropertyValue(pi.Name) != null) { string sel = entity.GetPropertyValue(pi.Name).ToString(); foreach (WebUI.WebControls.ListItem li in ck.Items) { if (sel.IndexOf(",") > -1 && (sel.IndexOf(li.Value + ",") > -1 || sel.IndexOf("," + li.Value) > -1)) { li.Selected = true; } else if (sel.IndexOf(",") == -1 && sel == li.Value) { li.Selected = true; } else { li.Selected = false; } } } } else if (ctlType == typeof(WebUI.WebControls.RadioButtonList))//单框列表 { WebUI.WebControls.RadioButtonList ck = (WebUI.WebControls.RadioButtonList)ctl; if (entity.GetPropertyValue(pi.Name) != null) { ck.SelectedValue = entity.GetPropertyValue(pi.Name).ToString(); } } else if (ctlType == typeof(WebUI.WebControls.ListBox))//列表框 { WebUI.WebControls.ListBox ck = (WebUI.WebControls.ListBox)ctl; if (entity.GetPropertyValue(pi.Name) != null) { string sel = entity.GetPropertyValue(pi.Name).ToString(); foreach (WebUI.WebControls.ListItem li in ck.Items) { if (sel.IndexOf(",") > -1 && (sel.IndexOf(li.Value + ",") > -1 || sel.IndexOf("," + li.Value) > -1)) { li.Selected = true; } else if (sel.IndexOf(",") == -1 && sel == li.Value) { li.Selected = true; } else { li.Selected = false; } } } } #endregion #region 处理不同Html控件 else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputText))//文本域 { WebUI.HtmlControls.HtmlInputText ct = (WebUI.HtmlControls.HtmlInputText)ctl; if (entity.GetPropertyValue(pi.Name) != null) { ct.Value = entity.GetPropertyValue(pi.Name).ToString(); } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlTextArea))//文本域 { WebUI.HtmlControls.HtmlTextArea ct = (WebUI.HtmlControls.HtmlTextArea)ctl; if (entity.GetPropertyValue(pi.Name) != null) { ct.Value = entity.GetPropertyValue(pi.Name).ToString(); } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlSelect))//选择域 { WebUI.HtmlControls.HtmlSelect ct = (WebUI.HtmlControls.HtmlSelect)ctl; if (entity.GetPropertyValue(pi.Name) != null) { for (int i = 0; i < ct.Items.Count; i++) { if (ct.Items[i].Value == entity.GetPropertyValue(pi.Name).ToString()) { ct.SelectedIndex = i; } } } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputHidden))////隐藏域 { WebUI.HtmlControls.HtmlInputHidden ct = (WebUI.HtmlControls.HtmlInputHidden)ctl; if (entity.GetPropertyValue(pi.Name) != null) { ct.Value = entity.GetPropertyValue(pi.Name).ToString(); } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputRadioButton))//单选域 { WebUI.HtmlControls.HtmlInputRadioButton rb = (WebUI.HtmlControls.HtmlInputRadioButton)ctl; if (rb.Checked && entity.GetPropertyValue(pi.Name) != null) { rb.Checked = entity.GetPropertyValue(pi.Name).ToString() == rb.Value ? true : false; } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputCheckBox))//复选域 { WebUI.HtmlControls.HtmlInputCheckBox ck = (WebUI.HtmlControls.HtmlInputCheckBox)ctl; if (entity.GetPropertyValue(pi.Name) != null) { if (entity.GetPropertyValue(pi.Name).ToString().IndexOf("," + ck.Value) != -1) { ck.Checked = true; } } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputPassword))//密码域 { WebUI.HtmlControls.HtmlInputPassword ck = (WebUI.HtmlControls.HtmlInputPassword)ctl; if (entity.GetPropertyValue(pi.Name) != null) { ck.Value = entity.GetPropertyValue(pi.Name).ToString(); } } #endregion } }