private void ViewContact() { ContactBSO contactBSO = new ContactBSO(); DataTable table = contactBSO.GetContactAll(); commonBSO commonBSO = new commonBSO(); commonBSO.FillToGridView(grvContact, table); }
protected void initControl(int Id) { if (Id > 0) { btn_add.Visible = false; btn_edit.Visible = true; btn_add1.Visible = false; btn_edit1.Visible = true; try { ContactBSO contactBSO = new ContactBSO(); Contact contact = contactBSO.GetContactById(Id); hddContactID.Value = Convert.ToString(contact.ContactID); txtEmail.Text = contact.Email; txtName.Text = contact.Name; txtAddress.Text = contact.Address; txtTel.Text = contact.Tel; txtFax.Text = contact.Fax; txtCity.Text = contact.City; txtCompany.Text = contact.Company; cboDay1.SelectedValue = contact.Date.Day.ToString(); cboMonth1.SelectedValue = contact.Date.Month.ToString(); cboYear1.SelectedValue = contact.Date.Year.ToString(); cboMinutes1.SelectedValue = contact.Date.Minute.ToString(); cboHour1.SelectedValue = contact.Date.Hour.ToString(); txtRequire.Text = contact.Require; } catch (Exception ex) { error.Text = ex.Message.ToString(); } } else if (Id == 0) { btn_add.Visible = true; btn_edit.Visible = false; btn_add1.Visible = true; btn_edit1.Visible = false; } }
protected void btn_edit_Click(object sender, EventArgs e) { try { Contact contact = ReceiveHtml(); ContactBSO contactBSO = new ContactBSO(); contactBSO.UpdateContact(contact); error.Text = "<div style='color:#ff0000;font:bold 12px Arial;padding:5px 0;'>Cập nhật thành công !</div>"; } catch (Exception ex) { error.Text = ex.Message.ToString(); } }
protected void grvContact_RowCommand(object sender, GridViewCommandEventArgs e) { int Id = Convert.ToInt32(e.CommandArgument.ToString()); string cName = e.CommandName.ToLower(); switch (cName) { case "_edit": Response.Redirect("~/Admin/editcontact/" + Id + "/Default.aspx"); break; case "_delete": ContactBSO contactBSO = new ContactBSO(); contactBSO.DeleteContact(Id); ViewContact(); break; } }
protected void contact_Click(object sender, EventArgs e) { try { Contact contact = ReceiveHtml(); if (txtCapcha.Text.ToLower() == Session["Random"].ToString().ToLower()) { ContactBSO contactBSO = new ContactBSO(); contactBSO.CreateContact(contact); ConfigBSO configBSO = new ConfigBSO(); Config config = configBSO.GetAllConfig(Language.language); string strBody = "Thông tin liên hệ tới Website " + config.WebName + " (" + config.WebDomain + "): <br>"; strBody += "<b>Họ tên : </b> " + NameContact.Text + "<br>"; strBody += "<b>Cơ quan công tác : </b> " + Company.Text + "<br>"; strBody += "<b>Địa chỉ : </b> " + Address.Text + "<br>"; strBody += "<b>Thành phố : </b> " + City.Text + "<br>"; strBody += "<b>Điện thoại : </b> " + Telephone.Text + "<br>"; strBody += "<b>Fax : </b> " + Fax.Text + "<br>"; strBody += "<b>Email : </b> " + Email.Text + "<br>"; strBody += "<b>Nội dung Yêu cầu : </b> " + Require.Text + "<br>"; MailBSO mailBSO = new MailBSO(); // mailBSO.EmailFrom = Email.Value; mailBSO.EmailFrom = config.Email_from; string strObj = "Thông tin liên hệ tới quản trị viên website " + config.WebName + " (" + config.WebDomain + ") - Ngày " + DateTime.Now.ToString("dd:MM:yyyy"); mailBSO.SendMail(config.Email_to, strObj, strBody); form_register.Visible = false; form_register_send.Visible = true; ltlSucceed1.Text = Resources.resource.Contact_succeed1; //ltlSucceed2.Text = Resources.resource.Contact_succeed2; ; } } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } }