protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { ntf.VisibleOnPageLoad = true; t_LanguageTranslate entity = new t_LanguageTranslate { Contents = txtContent.Text, Noted = txtNoted.Text }; bool updateStatus = languageBL.Update(entity, contentId); string message = (updateStatus) ? "Cập nhật thành công" : "Cập nhật không thành công"; ntf.Text = message; } }
public bool Update(t_LanguageTranslate entity, int id) { try { t_LanguageTranslate content = FindSingle(x => x.Id == id); //content.ControlId = entity.ControlId; content.Contents = entity.Contents; //content.Noted = entity.Noted; context.SaveChanges(); return(true); } catch (Exception) { return(false); } }
protected void btnUpdate_Click(object sender, EventArgs e) { int index = 0; foreach (GridViewRow gvr in GridView1.Rows) { if (index > 0) { TextBox type_vi = ((TextBox)gvr.FindControl("Content_vi")); type_vi.Enabled = false; TextBox type_en = ((TextBox)gvr.FindControl("Content_en")); type_en.Enabled = false; TextBox type_other = ((TextBox)gvr.FindControl("Content_other")); type_other.Enabled = false; // Update to SQL t_LanguageTranslate entity_vi = new t_LanguageTranslate { Contents = type_vi.Text, }; string Id_vi = (gvr.FindControl("Id_vi") as HiddenField).Value; bool updateStatus = languageBL.Update(entity_vi, int.Parse(Id_vi)); t_LanguageTranslate entity_en = new t_LanguageTranslate { Contents = type_en.Text, }; string Id_en = (gvr.FindControl("Id_en") as HiddenField).Value; updateStatus = languageBL.Update(entity_en, int.Parse(Id_en)); t_LanguageTranslate entity_other = new t_LanguageTranslate { Contents = type_other.Text, }; string Id_other = (gvr.FindControl("Id_other") as HiddenField).Value; updateStatus = languageBL.Update(entity_other, int.Parse(Id_other)); } index++; } }
protected void Page_Load(object sender, EventArgs e) { string linkID = string.IsNullOrEmpty(Request.QueryString["Id"]) ? "0" : Request.QueryString["Id"]; // Load language contents if (!IsPostBack) { contentId = int.Parse(linkID); t_LanguageTranslate content = languageBL.FindSingle(x => x.Id == contentId); // Vietnamese language zone if (content != null) { //txtControlId.Text = content.ControlId; txtContent.Text = content.Contents; txtNoted.Text = content.Noted; } // Required messgage warning //RequiredFieldValidator1.ErrorMessage = "** Required value"; RequiredFieldValidator2.ErrorMessage = "** Required value"; } }
public void Remove(t_LanguageTranslate entity) { throw new NotImplementedException(); }
public bool Add(t_LanguageTranslate entity) { throw new NotImplementedException(); }
public bool Update(t_LanguageTranslate entity, int id) { return(languageRepository.Update(entity, id)); }