protected void btnSave_Click(object sender, EventArgs e) { GridDataItem item; st.Clear(); string strErr = ""; int dem = 0; for (int i = 0; i < grid.Items.Count; i++) { item = (GridDataItem)grid.Items[i]; CheckBox checkBox = (CheckBox)item["ClientSelectColumn"].Controls[0]; TextBox txtSoTien = (TextBox)item["ClientSelectColumn"].FindControl("txtSoTien"); if (checkBox.Checked == true) { try { dem++; string id = item["idSoNo"].Text.Trim().Replace(" ", ""); sono sn = db.sonos.SingleOrDefault(x => x.idSoNo == int.Parse(id)); if (sn != null) { sn.SoTien = int.Parse(txtSoTien.Text.Replace(",", "")); sn.Editer = Session["taikhoan"].ToString(); sn.EditTime = DateTime.Now; db.SubmitChanges(); st.Append("$.notify('Thao tác thành công',{className: 'success',globalPosition: 'bottom right'});"); ClientScript.RegisterClientScriptBlock(this.GetType(), "", st.ToString(), true); } } catch (Exception mess) { st.Append("$.notify('" + mess.Message + "',{className: 'error',globalPosition: 'bottom right'});"); ClientScript.RegisterClientScriptBlock(this.GetType(), "", st.ToString(), true); } } } if (dem == 0) { st.Append("$.notify('Vui lòng chọn 1 mẫu tin',{className: 'error',globalPosition: 'bottom right'});"); ClientScript.RegisterClientScriptBlock(this.GetType(), "", st.ToString(), true); } getDataSearch(); }
protected void btnCreate_Click(object sender, EventArgs e) { GridDataItem item; st.Clear(); int dem = 0; for (int i = 0; i < grid.Items.Count; i++) { item = (GridDataItem)grid.Items[i]; CheckBox checkBox = (CheckBox)item["ClientSelectColumn"].Controls[0]; if (checkBox.Checked == true) { try { dem++; string idSoBoThue = item["idSoBoThue"].Text.Trim().Replace(" ", ""); string ReturnMess = ""; string masothue = item["masothue"].Text.Trim().Replace(" ", ""); List <SoLieuTuKhoBac> lstsl = db.SoLieuTuKhoBacs.Where(x => x.masothue == masothue).ToList(); foreach (SoLieuTuKhoBac sl in lstsl) { if (int.Parse(sl.KyThue.Substring(0, 2)) != DateTime.Now.Month) { sono s = db.sonos.SingleOrDefault(x => x.KyThue == sl.KyThue && x.masothue == sl.masothue && x.tieumuc == sl.tieumuc); if (s != null) { long?a = s.SoTien - sl.SoTienNop; if (a <= 0) { db.sonos.DeleteOnSubmit(s); db.SubmitChanges(); } } } } db.ChamBoThue(idSoBoThue, ref ReturnMess); if (ReturnMess != "") { st.Append("$.notify('" + ReturnMess + "',{className: 'error',globalPosition: 'bottom right'});"); ClientScript.RegisterClientScriptBlock(this.GetType(), "", st.ToString(), true); } else { st.Append("$.notify('Thao tác thành công',{className: 'success',globalPosition: 'bottom right'});"); ClientScript.RegisterClientScriptBlock(this.GetType(), "", st.ToString(), true); } } catch (Exception ms) { st.Append("$.notify('" + ms.Message + "',{className: 'error',globalPosition: 'bottom right'});"); ClientScript.RegisterClientScriptBlock(this.GetType(), "", st.ToString(), true); } } } if (dem == 0) { st.Append("$.notify('Vui lòng chọn 1 mẫu tin',{className: 'error',globalPosition: 'bottom right'});"); ClientScript.RegisterClientScriptBlock(this.GetType(), "", st.ToString(), true); } }