protected void grdDVT_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { try { SYS_Session session = (SYS_Session)Session["SYS_Session"]; CBDN.DM_LoSelectByIDDViResult HoatDong = (CBDN.DM_LoSelectByIDDViResult)grdDVT.GetRow(grdDVT.FocusedRowIndex); CBDN.DM_Lo cv = new CBDN.DM_Lo(); cv = db.DM_Los.SingleOrDefault(x => x.IDMaDViQly == HoatDong.IDTram && x.IDMaDViQly == int.Parse(session.User.ma_dviqly)); db.DM_Los.DeleteOnSubmit(cv); db.SubmitChanges(); _DataBind(); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Xoá lộ thành công');", true); } catch (Exception ex) { } finally { e.Cancel = true; } }
protected void btnCapNhat_Click(object sender, EventArgs e) { SYS_Session session = (SYS_Session)Session["SYS_Session"]; if (cmbTram.Value + "" == "") { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Bạn phải chọn trạm');", true); return; } var dmtram = db.DM_Trams.SingleOrDefault(x => x.IDTram == int.Parse(cmbTram.Value + "")); if (Session["Add"] + "" == "0") { CBDN.DM_LoSelectByIDDViResult cv = (CBDN.DM_LoSelectByIDDViResult)grdDVT.GetRow(grdDVT.FocusedRowIndex); CBDN.DM_Lo qtCT = db.DM_Los.SingleOrDefault(x => x.IDLo == cv.IDLo); if (!CheckName(txtMaDuongDat.Text, cv.IDLo)) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã lộ không được trùng');", true); return; } if (txtTenDuongDay.Value + "" == "") { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Tên lộ không thể bỏ trống');", true); return; } //CBDN.DM_Lo qtCT = new CBDN.DM_Lo(); qtCT.TenLo = txtTenDuongDay.Text; qtCT.MoTa = txtmoTa.Text; qtCT.IDChiNhanh = dmtram.IDChiNhanh; qtCT.IDTram = dmtram.IDTram; if (CkHoatDong.Checked) qtCT.HoatDong = 1; else qtCT.HoatDong = 0; db.SubmitChanges(); } else { if (txtMaDuongDat.Text + "" == "") { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã lộ không được để trống');", true); txtMaDuongDat.Focus(); return; } if (txtTenDuongDay.Text == "") { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Tên lộ không được để trống');", true); txtTenDuongDay.Focus(); return; } if (!CheckName(txtMaDuongDat.Text, 0)) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã lộ không được trùng');", true); return; } CBDN.DM_Lo cv = new CBDN.DM_Lo(); cv.MaLo = txtMaDuongDat.Text; cv.IDMaDViQly = int.Parse(session.User.ma_dviqly); cv.TenLo = txtTenDuongDay.Text; cv.IDChiNhanh = dmtram.IDChiNhanh; cv.MoTa = txtmoTa.Text; cv.IDTram = dmtram.IDTram; if (CkHoatDong.Checked) cv.HoatDong = 1; else cv.HoatDong = 0; db.DM_Los.InsertOnSubmit(cv); db.SubmitChanges(); } pcAddRoles.ShowOnPageLoad = false; _DataBind(); }