protected void btnUnLock_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]; if (checkBox.Checked == true) { try { dem++; string idKhaiThue = item["idKhaiThue"].Text.Trim().Replace(" ", ""); KhaiThue kt = db.KhaiThues.SingleOrDefault(x => x.idKhaiThue == int.Parse(idKhaiThue)); if (kt != null) { kt.TrangThaiHoatDong = true; int idngungnghi = int.Parse(item["mattngungnghi"].Text.Trim()); thongtinngungnghi tt = db.thongtinngungnghis.SingleOrDefault(x => x.mattngungnghi == idngungnghi); if (tt != null) { db.thongtinngungnghis.DeleteOnSubmit(tt); } db.SubmitChanges(); st.Append("$.notify('Mở khoá trạng thái 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); } loadData(); }
protected void btnLock_Click(object sender, EventArgs e) { GridDataItem item; st.Clear(); int dem = 0; string strErr = ""; 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++; TextBox txb = (TextBox)item["ClientSelectColumn"].FindControl("txtLyDo"); TextBox txttungay = (TextBox)item["ClientSelectColumn"].FindControl("txttungay"); TextBox txtdenngay = (TextBox)item["ClientSelectColumn"].FindControl("txtdenngay"); TextBox txtNgayNopDon = (TextBox)item["ClientSelectColumn"].FindControl("txtNgayNopDon"); if (IsNullTextBox(txttungay)) { ShowMess("Không được để trống từ ngày"); strErr = "1"; txttungay.Focus(); break; } if (IsNullTextBox(txtdenngay)) { ShowMess("Không được để trống đến ngày"); txtdenngay.Focus(); strErr = "1"; break; } if (IsNullTextBox(txtNgayNopDon)) { ShowMess("Không được để trống ngày nộp đơn"); txtNgayNopDon.Focus(); strErr = "1"; break; } if (IsNullTextBox(txb)) { ShowMess("Không được để trống lý do"); txb.Focus(); strErr = "1"; break; } else { DateTime dTuNgay, dDenNgay, dNgayNop; dTuNgay = DateTime.ParseExact(txttungay.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); dDenNgay = DateTime.ParseExact(txtdenngay.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); dNgayNop = DateTime.ParseExact(txtNgayNopDon.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); int Result = DateTime.Compare(dTuNgay, dDenNgay); if (Result > 0) { ShowMess("Từ ngày phải nhỏ hơn hoặc bằng đến ngày"); txtdenngay.Focus(); break; } string idKhaiThue = item["idKhaiThue"].Text.Trim().Replace(" ", ""); KhaiThue kt = db.KhaiThues.SingleOrDefault(x => x.idKhaiThue == int.Parse(idKhaiThue)); if (kt != null) { if (kt.TrangThaiHoatDong == false) { st.Append("$.notify('Hộ kinh doanh đã ngưng nghỉ',{className: 'error',globalPosition: 'bottom right'});"); ClientScript.RegisterClientScriptBlock(this.GetType(), "", st.ToString(), true); } else { kt.TrangThaiHoatDong = false; var tt = db.thongtinngungnghis.OrderByDescending(x => x.mattngungnghi).FirstOrDefault(); int idngungnghi = 0; if (tt != null) { idngungnghi = tt.mattngungnghi + 1; } thongtinngungnghi a = new thongtinngungnghi { mattngungnghi = idngungnghi, idKhaiThue = int.Parse(idKhaiThue), tungay = dTuNgay, denngay = dDenNgay, ngaynopdon = dNgayNop, lydo = txb.Text }; db.thongtinngungnghis.InsertOnSubmit(a); db.SubmitChanges(); st.Append("$.notify('Khoá trạng thái 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); } if (strErr == "") { loadData(); } }