protected override void Render(HtmlTextWriter writer) { var sb = new StringBuilder(); var cs = this.Page.ClientScript; #region Tham số HttpContext c = HttpContext.Current; var ID = c.Request["ID"]; var NDTC_ID = c.Request["NDTC_ID"]; var SoPhieu = c.Request["SoPhieu"]; var SoTien = c.Request["SoTien"]; var Mota = c.Request["Mota"]; var NgayTao = c.Request["NgayTao"]; var NguoiTao = c.Request["NguoiTao"]; var NgaySua = c.Request["NgaySua"]; var NguoiSua = c.Request["NguoiSua"]; var LoaiQuy = c.Request["LoaiQuy"]; var LoaiCandoi = c.Request["LoaiCandoi"]; var isCandoi = c.Request["isCandoi"]; var Thu = c.Request["Thu"]; var XN_ID = c.Request["XN_ID"]; var P_ID = c.Request["P_ID"]; var DV_ID = c.Request["DV_ID"]; var TuNgay = c.Request["TuNgay"]; var DenNgay = c.Request["DenNgay"]; var _q = c.Request["q"]; List <jgridRow> ListRow = new List <jgridRow>(); var danhMucKyHieu = DanhMucDal.SelectByMa("TC-THU"); var danhMucReportHeader = DanhMucDal.SelectByMa("BAOCAO-HEADER-THUCHI"); var danhMucReportFooter = DanhMucDal.SelectByMa("BAOCAO-FOOTER-THUCHI"); var draff = Request["draff"]; var isThu = true; #endregion switch (subAct) { case "get": #region lấy dữ liệu cho grid var pagerGet = ThuChiDal.pagerTuNgayDenNgay(jgrsidx + " " + jgrsord, _q, Convert.ToInt32(jgRows), isThu, TuNgay, DenNgay, NDTC_ID, null, true); string prefixMas = danhMucKyHieu.KyHieu; foreach (var item in pagerGet.List) { ListRow.Add(new jgridRow(item.ID.ToString(), new string[] { item.ID.ToString() , item.NDTC_Ten , prefixMas + item.SoPhieu , item.P_Ten , item.Mota , item.NgayTao.ToString("dd-MM-yyyy") , Lib.TienVietNam(item.SoTien) , item.NguoiTao_Ten , (item.NguoiTao == Security.Username).ToString() , (item.XN_ID != Guid.Empty).ToString() , (item.DV_ID != Guid.Empty).ToString() })); } jgrid gridSPAdm = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage , pagerGet.TotalPages.ToString() , pagerGet.Total.ToString() , ListRow); sb.Append(JavaScriptConvert.SerializeObject(gridSPAdm)); break; #endregion case "del": #region xóa if (!string.IsNullOrEmpty(ID)) { ThuChiDal.DeleteById(new Guid(ID)); } break; #endregion case "edit": #region chỉnh sửa if (!string.IsNullOrEmpty(ID)) { var item = ThuChiDal.SelectById(new Guid(ID)); string prefixMa = danhMucKyHieu.KyHieu; item.SoPhieu = prefixMa + item.SoPhieu; sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(item)); } break; #endregion case "draff": #region draff if (Security.IsAuthenticated()) { var item = ThuChiDal.SelectByDraff(isThu); string prefixMa = danhMucKyHieu.KyHieu; item.SoPhieu = prefixMa + item.SoPhieu; sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(item)); } break; #endregion case "save": #region save if (Security.IsAuthenticated()) { var item = draff == "1" ? new ThuChi() : ThuChiDal.SelectById(new Guid(ID)); var prefixMa = danhMucKyHieu.KyHieu; SoPhieu = SoPhieu.Replace(prefixMa, ""); item.SoPhieu = SoPhieu; if (!string.IsNullOrEmpty(DV_ID)) { item.DV_ID = new Guid(DV_ID); } item.LoaiCandoi = Convert.ToInt32(LoaiCandoi); item.LoaiQuy = Convert.ToInt32(LoaiQuy); item.Mota = Mota; if (!string.IsNullOrEmpty(NDTC_ID)) { item.NDTC_ID = new Guid(NDTC_ID); } item.NgaySua = DateTime.Now; item.NguoiSua = Security.Username; if (!string.IsNullOrEmpty(P_ID)) { item.P_ID = new Guid(P_ID); } item.SoTien = Convert.ToDouble(SoTien); item.Thu = isThu; if (!string.IsNullOrEmpty(XN_ID)) { item.XN_ID = new Guid(XN_ID); } item.isCandoi = true; item.NgayTao = Convert.ToDateTime(NgayTao, new CultureInfo("vi-Vn")); if (draff == "1") { item.ID = new Guid(ID); item.NguoiTao = NguoiTao; item = ThuChiDal.Insert(item); } else { item = ThuChiDal.Update(item); } // TODO: Tiếp tục phần thu chi sb.Append("1"); } break; #endregion case "reports": #region bao cao if (!string.IsNullOrEmpty(ID)) { var itemIn = Lib.GetResource(Assembly.GetExecutingAssembly(), "quanLyThuDauKy.in-natural.htm"); var item = ThuChiDal.SelectById(new Guid(ID)); sb.AppendFormat(itemIn , string.Format("Ngày {4}{0} tháng {3}{1} năm {2}", item.NgayTao.Day, item.NgayTao.Month, item.NgayTao.Year, item.NgayTao.Month < 10 ? "0" : "", item.NgayTao.Day < 10 ? "0" : "") , item.NDTC_Ten , string.Format("{0}{1}", danhMucKyHieu.KyHieu, item.SoPhieu) , (item.LoaiQuy == 1 ? "Tài khoản" : "Tiền mặt") , Lib.TienVietNam(item.SoTien) , Lib.So_chu(item.SoTien) , item.P_Ten , item.NguoiTao_Ten , item.Mota , domain , danhMucReportHeader.Description , danhMucReportFooter.Description); } break; #endregion case "scpt": #region Nạp js sb.AppendFormat(@"{0}" , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.thuChiMgr.quanLyThuDauKy.JScript1.js")); //sb.AppendFormat(@"{0}" // , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.thuChiMgr.quanLyThuDauKy.Publish.js")); break; #endregion default: #region nạp var listFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId); sb.Append(Lib.GetResource(Assembly.GetExecutingAssembly(), "quanLyThuDauKy.mdl.htm")); sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>" , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.thuChiMgr.quanLyThuDauKy.JScript1.js") , "{quanLyThuDauKyDauKyFn.loadgrid();}"); sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(listFn)); break; #endregion } writer.Write(sb.ToString()); base.Render(writer); }
protected void Page_Load(object sender, EventArgs e) { var NDTC_ID = Request["NDTC_ID"]; var CQ_ID = Request["CQ_ID"]; var MaPhieu = Request["MaPhieu"]; var SoPhieu = Request["SoPhieu"]; var SoPhieuAll = Request["SoPhieuAll"]; var SoTien = Request["SoTien"]; var Mota = Request["Mota"]; var NgayTrenPhieu = Request["NgayTrenPhieu"]; var NgayTao = Request["NgayTao"]; var NguoiTao = Request["NguoiTao"]; var NgayCapNhat = Request["NgayCapNhat"]; var NguoiCapNhat = Request["NguoiCapNhat"]; var LoaiQuy = Request["LoaiQuy"]; var LoaiCandoi = Request["LoaiCandoi"]; var isCandoi = Request["isCandoi"]; var Thu = Request["Thu"]; var XN_ID = Request["XN_ID"]; var P_ID = Request["P_ID"]; var PDV_ID = Request["PDV_ID"]; var CTV_ID = Request["CTV_ID"]; var PGV_ID = Request["PGV_ID"]; var PBH_ID = Request["PBH_ID"]; var Xoa = Request["Xoa"]; var XoaAdm = Request["XoaAdm"]; XoaAdm = string.IsNullOrEmpty(XoaAdm) ? "false" : "true"; Xoa = string.IsNullOrEmpty(Xoa) ? "false" : "true"; var logged = Security.IsAuthenticated(); var Id = Request["ID"]; var IdNull = string.IsNullOrEmpty(Id); var refUrl = Request["refUrl"]; if (!string.IsNullOrEmpty(refUrl)) { refUrl = Server.UrlDecode(refUrl); } switch (subAct) { case "save": #region Thêm Thu chi if (logged) { var item = ThuChiDal.SelectById(new Guid(Id)); IdNull = item.ID == Guid.Empty; if (IdNull) { item = new ThuChi { ID = new Guid(Id), NgayTao = DateTime.Now, NguoiTao = Security.UserId, NguoiCapNhat = Security.UserId, NgayCapNhat = DateTime.Now }; } else { item.NgayCapNhat = DateTime.Now; item.NguoiCapNhat = Security.UserId; } item.isCandoi = false; if (!string.IsNullOrEmpty(LoaiQuy)) { item.LoaiQuy = Convert.ToInt32(LoaiQuy); } if (!string.IsNullOrEmpty(NgayTrenPhieu)) { item.NgayTrenPhieu = Convert.ToDateTime(NgayTrenPhieu, new CultureInfo("vi-vn")); } if (!string.IsNullOrEmpty(SoTien)) { item.SoTien = Convert.ToDouble(SoTien); } if (!string.IsNullOrEmpty(P_ID)) { item.P_ID = new Guid(P_ID); } if (!string.IsNullOrEmpty(PDV_ID)) { item.PDV_ID = new Guid(PDV_ID); } if (!string.IsNullOrEmpty(CTV_ID)) { item.CTV_ID = new Guid(CTV_ID); } if (!string.IsNullOrEmpty(PGV_ID)) { item.PGV_ID = new Guid(PGV_ID); } if (!string.IsNullOrEmpty(PBH_ID)) { item.PBH_ID = new Guid(PBH_ID); } if (!string.IsNullOrEmpty(NDTC_ID)) { item.NDTC_ID = new Guid(NDTC_ID); } if (!string.IsNullOrEmpty(SoPhieu)) { item.SoPhieu = Convert.ToInt32(SoPhieu); } item.Thu = Convert.ToBoolean(Thu); item.Mota = Mota; if (IdNull) { item = ThuChiDal.Insert(item); #region log LogDal.log(item, new Log() { Checked = false , Info = string.Format("{1} thêm mới phiếu thu: {0}", item.Ma, Security.Username) , NgayTao = DateTime.Now , Username = Security.Username , PRowId = item.ID , PTen = item.Ma , RequestIp = Request.UserHostAddress , RawUrl = refUrl , LLOG_ID = 1 , Ten = "Thêm" }); #endregion } else { item = ThuChiDal.Update(item); #region log LogDal.log(item, new Log() { Checked = false , Info = string.Format("{1} sửa phiếu thu: {0}", item.Ma, Security.Username) , NgayTao = DateTime.Now , Username = Security.Username , PRowId = item.ID , PTen = item.Ma , RequestIp = Request.UserHostAddress , RawUrl = refUrl , LLOG_ID = 2 , Ten = "Sửa" }); #endregion } //SearchManager.Add(Ten, item.IndexNoiDung, item.IndexContent, Ten, item.ID.ToString(), item.Url, typeof(SuKien).Name); TimKiemDal.Add(item, item.ID); rendertext(item.ID.ToString()); } break; #endregion case "remove": #region Xóa if (Security.IsAuthenticated()) { var item = ThuChiDal.SelectById(new Guid(Id)); if (item.NguoiTao == Security.UserId) { ThuChiDal.DeleteById(new Guid(Id)); //SearchManager.Remove(Id); TimKiemDal.DeleteByPRowId(DAL.con(), item.ID); #region log LogDal.log(item, new Log() { Checked = false , Info = string.Format("{1} xóa thu: {0}", item.Ma, Security.Username) , NgayTao = DateTime.Now , Username = Security.Username , PRowId = item.ID , PTen = item.Ma , RequestIp = Request.UserHostAddress , RawUrl = refUrl , LLOG_ID = 3 , Ten = "Xóa" }); #endregion rendertext("1"); } else { rendertext("0"); } } break; #endregion default: break; } }
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; } }