protected void Page_Load(object sender, EventArgs e) { var id = Request["ID"]; var idNull = string.IsNullOrEmpty(id); using (var con = DAL.con()) { if (idNull) { Item = ThuChiDal.SelectByLastest(con, Security.CqId); } else { Item = ThuChiDal.SelectById(con, Convert.ToInt64(id)); var phoi = PhoiDal.SelectById(Item.PHOI_ID); var xe = XeDal.SelectById(phoi.XE_ID); phoi.Xe = xe; Item.Phoi = phoi; } } ThuCapPhoiAdd.Item = Item; }
protected void Page_Load(object sender, EventArgs e) { var loggedIn = Security.IsAuthenticated(); var Id = Request["Id"]; var PHOI_ID = Request["PHOI_ID"]; var STTBX = Request["STTBX"]; var STTALL = Request["STTALL"]; var XE_ID = Request["XE_ID"]; var Ngay = Request["Ngay"]; var Tien = Request["Tien"]; var XVB_ID = Request["XVB_ID"]; var Inserted = string.IsNullOrEmpty(Id); switch (subAct) { case "save": #region save if (loggedIn) { var Item = Inserted ? ThuChiDal.SelectByLastest(DAL.con(), Security.CqId) : ThuChiDal.SelectById(Convert.ToInt32(Id)); if (!string.IsNullOrEmpty(Tien)) { Item.Tien = Convert.ToDouble(Tien); } Item.CQ_ID = Security.CqId; if (!string.IsNullOrEmpty(PHOI_ID)) { Item.PHOI_ID = Convert.ToInt64(PHOI_ID); var phoi = PhoiDal.SelectById(Item.PHOI_ID); Item.XE_ID = Convert.ToInt32(phoi.XE_ID); } if (!string.IsNullOrEmpty(Ngay)) { Item.Ngay = Convert.ToDateTime(Ngay, new CultureInfo("vi-vn")); } if (Inserted) { Item.NguoiTao = Security.Username; Item.NgayTao = DateTime.Now; Item.RowId = Guid.NewGuid(); } if (Inserted) { var giaoCa = GiaoCaDal.Current(Security.CqId, Security.Username); Item.GIAOCA_ID = giaoCa.ID; giaoCa.DoanhThu += Item.Tien; giaoCa.NgayCapNhat = DateTime.Now; GiaoCaDal.Update(giaoCa); } Item.NgayCapNhat = DateTime.Now; Item.XVB_ID = Convert.ToInt64(XVB_ID); Item = Inserted ? ThuChiDal.Insert(Item) : ThuChiDal.Update(Item); if (Inserted) { if (!string.IsNullOrEmpty(XVB_ID)) { var xvb = XeVaoBenDal.SelectById(Convert.ToInt64(XVB_ID)); xvb.TC_ID = Item.ID; xvb.TrangThai = 800; xvb.NguoiXuLyThanhToan = Security.Username; xvb.NgayThanhToanXong = xvb.NgayCapNhat = DateTime.Now; XeVaoBenDal.Update(xvb); } var chamCongByPhoiId = ChamCongDal.SelectByPhoiId(Item.PHOI_ID); foreach (var item in chamCongByPhoiId) { item.NgayCapNhat = DateTime.Now; item.Draff = false; ChamCongDal.Update(item); } } rendertext(Item.ID.ToString()); } rendertext("0"); break; #endregion case "remove": #region remove if (loggedIn) { var Item = XeVaoBenDal.SelectById(Convert.ToInt64(Id)); if (Item.Username == Security.Username) { LaiXeDal.DeleteById(Item.ID); rendertext("0"); } } rendertext("-1"); break; #endregion case "getLatest": #region getLatest if (loggedIn) { var item = ThuChiDal.SelectByLastest(DAL.con(), Security.CqId); rendertext(string.Format("({0})", JavaScriptConvert.SerializeObject(item))); } rendertext("-1"); break; #endregion case "search": #region search #endregion default: break; } }
protected void Page_Load(object sender, EventArgs e) { var loggedIn = Security.IsAuthenticated(); var Id = Request["Id"]; var uname = Security.Username; switch (subAct) { case "GetNewers": if (loggedIn) { var list = XeVaoBenDal.ListTsLenPhoi(DAL.con(), Security.CqId, 100); if (list.Any()) { ListTodayAjax.List = list; ListTodayAjax.Visible = true; } else { rendertext(""); } } break; case "GetChoThanhToan": if (loggedIn) { var list = XeVaoBenDal.ListTsChoThanhToan(DAL.con(), Security.CqId, 100); if (list.Any()) { TS_XeChoThanhToanAjax.List = list; TS_XeChoThanhToanAjax.Visible = true; } else { rendertext(""); } } break; case "GetDaThanhToan": if (loggedIn) { var list = XeVaoBenDal.ListTsDaThanhToan(DAL.con(), Security.CqId, 100); if (list.Any()) { TS_XeDaThanhToanAjax.List = list; TS_XeDaThanhToanAjax.Visible = true; } else { rendertext(""); } } break; case "GetYeuCauThanhToan": if (loggedIn) { var list = XeVaoBenDal.ListTsChoThanhToan(DAL.con(), Security.CqId, 100).OrderByDescending(x => x.TrangThai). ThenByDescending(x => x.ID).ToList(); if (list.Any()) { AjaxListYeuCauThanhToanHangDoi.List = list; AjaxListYeuCauThanhToanHangDoi.Visible = true; } else { rendertext(""); } } break; case "ListDuyetDeNghiTruyThu": if (loggedIn) { var list = XeVaoBenDal.ListTruyThu(DAL.con(), Security.CqId, 100).OrderByDescending(x => x.TrangThai). ThenByDescending(x => x.ID).ToList(); if (list.Any()) { AjaxListDuyetDeNghiTruyThu.List = list; AjaxListDuyetDeNghiTruyThu.Visible = true; } else { rendertext(""); } } break; case "GetYeuCauXuLyListByUsername": if (loggedIn) { var list = XeVaoBenDal.ListTsLenPhoi(DAL.con(), Security.CqId, 100).OrderByDescending(x => x.TrangThai). ThenByDescending(x => x.XE_GioXuatBen).ToList(); if (!list.Any()) { rendertext(""); } AjaxListYeuCauXuLyHangDoi.List = list; AjaxListYeuCauXuLyHangDoi.Visible = true; } break; case "YeuCauXuLy": if (!string.IsNullOrEmpty(Id)) { var item = XeVaoBenDal.SelectById(Convert.ToInt64(Id)); item.TrangThai = 200; item.NgayYeuCauXuLy = item.NgayCapNhat = DateTime.Now; item = XeVaoBenDal.Update(item); } break; case "YeuCauXuatBen": if (!string.IsNullOrEmpty(Id)) { var item = XeVaoBenDal.SelectById(Convert.ToInt64(Id)); item.TrangThai = 820; item.NgayCapNhat = DateTime.Now; item = XeVaoBenDal.Update(item); } break; case "YeuCauThanhToan": if (!string.IsNullOrEmpty(Id)) { var item = XeVaoBenDal.SelectById(Convert.ToInt64(Id)); item.TrangThai = 600; item.NgayYeuCauThanhToan = item.NgayCapNhat = DateTime.Now; item = XeVaoBenDal.Update(item); } break; case "RestoreXeChuaXuLy": if (!string.IsNullOrEmpty(Id)) { var xvb = XeVaoBenDal.SelectById(Convert.ToInt64(Id)); xvb.TrangThai = 100; xvb.NgayCapNhat = DateTime.Now; xvb = XeVaoBenDal.Update(xvb); } break; case "RestoreXeChuaThanhToan": if (!string.IsNullOrEmpty(Id)) { var xvb = XeVaoBenDal.SelectById(Convert.ToInt64(Id)); xvb.TrangThai = 400; xvb.NgayCapNhat = DateTime.Now; xvb = XeVaoBenDal.Update(xvb); } break; case "NhanYeuCauThanhToan": if (!string.IsNullOrEmpty(Id)) { var xvb = XeVaoBenDal.SelectById(Convert.ToInt64(Id)); xvb.TrangThai = 700; xvb.NguoiNhanYeuCauThanhToan = Security.Username; xvb.NgayNhanYeuCauThanhToan = xvb.NgayCapNhat = DateTime.Now; xvb = XeVaoBenDal.Update(xvb); var thuChi = ThuChiDal.SelectByLastest(DAL.con(), Security.CqId); var phoi = PhoiDal.SelectById(xvb.PHOI_ID); var xe = XeDal.SelectById(phoi.XE_ID); thuChi.XeVaoBen = xvb; phoi.Xe = xe; thuChi.Phoi = phoi; rendertext(string.Format("({0})", JavaScriptConvert.SerializeObject(thuChi))); } break; case "GetCurrentCapPhoi": if (loggedIn) { var item = XeVaoBenDal.ListByCurrentCapPhoiByUser(DAL.con(), Security.CqId, Security.Username).FirstOrDefault(); if (item != null) { rendertext(string.Format("({0})", JavaScriptConvert.SerializeObject(item))); } rendertext(""); } break; case "GetCurrentThuCapPhoi": if (loggedIn) { var item = XeVaoBenDal.ListByCurrentThuCapPhoiByUser(DAL.con(), Security.CqId, Security.Username).FirstOrDefault(); if (item != null) { var thuChi = ThuChiDal.SelectByLastest(DAL.con(), Security.CqId); var phoi = PhoiDal.SelectById(item.PHOI_ID); var xe = XeDal.SelectById(phoi.XE_ID); thuChi.XeVaoBen = item; phoi.Xe = xe; thuChi.Phoi = phoi; rendertext(string.Format("({0})", JavaScriptConvert.SerializeObject(thuChi))); } rendertext(""); } break; default: break; } }