protected void Page_Load(object sender, EventArgs e) { var logged = Security.IsAuthenticated(); var Id = Request["Id"]; var IdNull = string.IsNullOrEmpty(Id); var q = Request["q"]; var refUrl = Request["refUrl"]; if (!string.IsNullOrEmpty(refUrl)) { refUrl = Server.UrlDecode(refUrl); } var Ma = Request["Ma"]; var HH_ID = Request["HH_ID"]; var NgayBaoHong = Request["NgayBaoHong"]; var LYDO_ID = Request["LYDO_ID"]; var MoTa = Request["MoTa"]; var NhanVien = Request["NhanVien"]; var Duyet = Request["Duyet"]; var NguoiDuyet = Request["NguoiDuyet"]; var Tien = Request["Tien"]; var NgayDuyet = Request["NgayDuyet"]; Duyet = string.IsNullOrEmpty(Duyet) ? "false" : "true"; switch (subAct) { case "save": #region Thêm khách hàng if (logged) { var item = PhieuBaoHongDal.SelectById(DAL.con(), new Guid(Id)); IdNull = item.ID == Guid.Empty; if (!string.IsNullOrEmpty(NguoiDuyet)) { item.NguoiDuyet = Convert.ToInt32(NguoiDuyet); } if (!string.IsNullOrEmpty(NhanVien)) { item.NhanVien = Convert.ToInt32(NhanVien); } if (!string.IsNullOrEmpty(LYDO_ID)) { item.LYDO_ID = new Guid(LYDO_ID); } if (!string.IsNullOrEmpty(HH_ID)) { item.HH_ID = new Guid(HH_ID); } if (!string.IsNullOrEmpty(Tien)) { item.Tien = Convert.ToDouble(Tien); } item.MoTa = MoTa; if (!string.IsNullOrEmpty(Ma)) { item.Ma = Convert.ToInt32(Ma); } if (Convert.ToBoolean(Duyet)) { if (!item.Duyet) { item.NgayDuyet = DateTime.Now; item.NguoiDuyet = Convert.ToInt32(Security.UserId); var hh = HangHoaDal.SelectById(item.HH_ID); hh.HongVay = true; hh.NgayCapNhat = DateTime.Now; hh.NguoiCapNhat = Security.UserId; HangHoaDal.Update(hh); } } item.Duyet = Convert.ToBoolean(Duyet); if (!string.IsNullOrEmpty(NgayBaoHong)) { item.NgayBaoHong = Convert.ToDateTime(NgayBaoHong, new CultureInfo("vi-vn")); } if (IdNull) { item.ID = new Guid(Id); item.NgayTao = DateTime.Now; item.NguoiTao = Security.UserId; } item.NgayCapNhat = DateTime.Now; item.NguoiCapNhat = Security.UserId; if (IdNull) { item = PhieuBaoHongDal.Insert(item); #region log LogDal.log(item, new Log() { Checked = false , Info = string.Format("{1} thêm mới phiếu báo hỏng: {0}", item.MaStr, Security.Username) , NgayTao = DateTime.Now , Username = Security.Username , PRowId = item.ID , PTen = item.MaStr , RequestIp = Request.UserHostAddress , RawUrl = refUrl , LLOG_ID = 1 , Ten = "Thêm" }); #endregion } else { item = PhieuBaoHongDal.Update(item); #region log LogDal.log(item, new Log() { Checked = false , Info = string.Format("{1} sửa phiếu báo hỏng: {0}", item.MaStr, Security.Username) , NgayTao = DateTime.Now , Username = Security.Username , PRowId = item.ID , PTen = item.MaStr , RequestIp = Request.UserHostAddress , RawUrl = refUrl , LLOG_ID = 2 , Ten = "Sửa" }); #endregion } TimKiemDal.Add(item, item.ID); rendertext(item.ID.ToString()); } break; #endregion case "remove": #region Xóa phiếu xuất nhập/ phiếu dịch vụ if (logged && !IdNull) { var item = PhieuBaoHongDal.SelectById(DAL.con(), new Guid(Id)); if (item.NguoiTao == Security.UserId) { PhieuBaoHongDal.DeleteById(new Guid(Id)); TimKiemDal.DeleteByPRowId(DAL.con(), item.ID); #region log LogDal.log(item, new Log() { Checked = false , Info = string.Format("{1} xóa phiếu báo hỏng: {0}", item.MaStr, Security.Username) , NgayTao = DateTime.Now , Username = Security.Username , PRowId = item.ID , PTen = item.MaStr , RequestIp = Request.UserHostAddress , RawUrl = refUrl , LLOG_ID = 3 , Ten = "Xóa" }); #endregion rendertext("1"); } else { rendertext("0"); } } break; #endregion case "search": #region search var pg = PhieuBaoHongDal.pagerNormal(null, false, "PBH_Ma desc", q, 10); rendertext(JavaScriptConvert.SerializeObject(pg.List), "text/javascript"); break; #endregion default: break; } }
protected override void Render(HtmlTextWriter writer) { var sb = new StringBuilder(); var cs = this.Page.ClientScript; #region Tham số var ID = Request["ID"]; var DM_ID = Request["DM_ID"]; var GH_ID = Request["GH_ID"]; var Lang = Request["Lang"]; var LangBased_ID = Request["LangBased_ID"]; var LangBased = Request["LangBased"]; var Alias = Request["Alias"]; var Ten = Request["Ten"]; var Ma = Request["Ma"]; var Keywords = Request["Keywords"]; var Description = Request["Description"]; var MoTa = Request["MoTa"]; var NoiDung = Request["NoiDung"]; var GNY = Request["GNY"]; var GiaNhap = Request["GiaNhap"]; var DonVi_ID = Request["DonVi_ID"]; var SoLuong = Request["SoLuong"]; var RowId = Request["RowId"]; var NgayTao = Request["NgayTao"]; var NguoiTao = Request["NguoiTao"]; var NgayCapNhat = Request["NgayCapNhat"]; var NguoiCapNhat = Request["NguoiCapNhat"]; var Anh = Request["Anh"]; var Publish = Request["Publish"]; var Active = Request["Active"]; var Home = Request["Home"]; var Hot1 = Request["Hot1"]; var Hot2 = Request["Hot2"]; var Hot3 = Request["Hot3"]; var Hot4 = Request["Hot4"]; var HetHang = Request["HetHang"]; var TonDinhMuc = Request["TonDinhMuc"]; var Draff = Request["Draff"]; var _q = Request["q"]; var draff = Request["draff"]; var Loai = Request["Loai"]; var Rep_Ten = Request["Rep_Ten"]; var Rep_Ngay = Request["Rep_Ngay"]; var _F_ID = Request["F_ID"]; List <jgridRow> ListRow = new List <jgridRow>(); //List<DanhMuc> ListDanhMucBG = new List<DanhMuc>(); #endregion switch (subAct) { case "get": #region lấy dữ liệu cho grid var pagerGet = HangHoaDal.ByDm("", false, jgrsidx + " " + jgrsord, _q, Convert.ToInt32(jgRows), DM_ID); foreach (HangHoa item in pagerGet.List) { ListRow.Add(new jgridRow(item.ID.ToString(), new string[] { item.ID.ToString() , item.DM_Ten , item.Ma , item.Ten , Lib.TienVietNam(item.GiaNhap) , Lib.TienVietNam(item.GNY) , item.SoLuong.ToString() , item.DonVi_Ten , string.Format("{0:dd/MM/yy}", item.NgayCapNhat) })); } 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)) { HangHoaDal.DeleteByMultiId(ID); } break; #endregion case "edit": #region chỉnh sửa if (!string.IsNullOrEmpty(ID)) { var hhitem = HangHoaDal.SelectById(new Guid(ID)); hhitem.ListFiles = FilesDal.SelectByPRowId(hhitem.ID); sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(hhitem)); } break; #endregion case "draff": #region draff sb.Append(Guid.NewGuid().ToString()); break; #endregion case "autoCompleteByQ": #region lấy dữ liệu cho grid var pagerByQ = HangHoaDal.ByDm("", false, "HH_NgayTao asc", _q, 10, string.Empty); sb.Append(JavaScriptConvert.SerializeObject(pagerByQ.List)); break; #endregion case "save": #region save if (Security.IsAuthenticated()) { var item = draff == "1" ? new HangHoa() : HangHoaDal.SelectById(new Guid(ID)); item.DM_ID = new Guid(DM_ID); item.Ten = Ten; item.Ma = Ma; item.Keywords = Keywords; item.MoTa = MoTa; item.NoiDung = NoiDung; item.GNY = Convert.ToDouble(GNY); item.GiaNhap = Convert.ToDouble(GiaNhap); item.DonVi_ID = new Guid(DonVi_ID); item.SoLuong = Convert.ToDouble(SoLuong); item.Anh = Anh; item.HetHang = Convert.ToBoolean(HetHang); item.TonDinhMuc = Convert.ToDouble(TonDinhMuc); item.NguoiCapNhat = Security.Username; item.NgayCapNhat = DateTime.Now; if (draff == "1") { item.ID = new Guid(ID); item.NgayTao = DateTime.Now; item.NguoiTao = Security.Username; item.RowId = Guid.NewGuid(); item = HangHoaDal.Insert(item); } else { item = HangHoaDal.Update(item); } sb.Append("1"); } break; #endregion case "DeleteDoc": #region Xóa tài liệu đính kèm if (!string.IsNullOrEmpty(_F_ID)) { Files item = FilesDal.SelectById(Convert.ToInt32(_F_ID)); string _files = Server.MapPath("~/lib/up/sanpham/") + item.ThuMuc + @"\"; string _file1 = _files + @"\" + item.Ten + item.MimeType; string _file2 = _files + @"\" + item.Ten + "400x400" + item.MimeType; if (Directory.Exists(_files)) { File.Delete(_file1); File.Delete(_file2); Directory.Delete(_files); } FilesDal.DeleteById(item.ID); } break; #endregion case "reports": #region bao cao var pagerGetReport = HangHoaDal.ByDm("", false, jgrsidx + " " + jgrsord, _q, Convert.ToInt32(jgRows), DM_ID); break; #endregion case "scpt": #region Nạp js sb.AppendFormat(@"{0}" , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.hangHoaMgr.JScript1.js")); //sb.AppendFormat(@"{0}" // , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.hangHoaMgr.Publish.js")); break; #endregion default: #region nạp var listFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId); sb.Append(Lib.GetResource(Assembly.GetExecutingAssembly(), "mdl.htm")); sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>" , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.hangHoaMgr.JScript1.js") , "{hangHoaMgrFn.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 logged = Security.IsAuthenticated(); var Id = Request["Id"]; var IdNull = string.IsNullOrEmpty(Id); var DM_ID = Request["DM_ID"]; var Ma = Request["Ma"]; var Ten = Request["Ten"]; var MoTa = Request["MoTa"]; var GNY = Request["GNY"]; var GiaMin = Request["GiaMin"]; var GiaMax = Request["GiaMax"]; var Anh = Request["Anh"]; var DichVu = Request["DichVu"]; var KhoVay = Request["KhoVay"]; var HetHang = Request["HetHang"]; var HongVay = Request["HongVay"]; var refUrl = Request["refUrl"]; var q = Request["q"]; if (!string.IsNullOrEmpty(refUrl)) { refUrl = Server.UrlDecode(refUrl); } DichVu = !string.IsNullOrEmpty(DichVu) ? "true" : "false"; KhoVay = !string.IsNullOrEmpty(KhoVay) ? "true" : "false"; HetHang = !string.IsNullOrEmpty(HetHang) ? "true" : "false"; HongVay = !string.IsNullOrEmpty(HongVay) ? "true" : "false"; switch (subAct) { case "save": #region Thêm khách hàng if (logged) { var item = IdNull ? new HangHoa() : HangHoaDal.SelectById(new Guid(Id)); item.Ten = Ten; item.Ma = Ma; item.Anh = Anh; item.MoTa = MoTa; item.NguoiCapNhat = Security.UserId; item.NgayCapNhat = DateTime.Now; if (!string.IsNullOrEmpty(GNY)) { item.GNY = Convert.ToDouble(GNY); } if (!string.IsNullOrEmpty(GiaMin)) { item.GiaMin = Convert.ToDouble(GiaMin); } if (!string.IsNullOrEmpty(GiaMax)) { item.GiaMax = Convert.ToDouble(GiaMax); } if (!string.IsNullOrEmpty(DM_ID)) { item.DM_ID = new Guid(DM_ID); } item.KhoVay = Convert.ToBoolean(KhoVay); item.DichVu = Convert.ToBoolean(DichVu); item.HetHang = Convert.ToBoolean(HetHang); item.HongVay = Convert.ToBoolean(HongVay); if (IdNull) { item.NgayTao = DateTime.Now; item.NguoiTao = Security.UserId; item.ID = Guid.NewGuid(); item = HangHoaDal.Insert(item); #region log LogDal.log(item, new Log() { Checked = false , Info = string.Format("{2} thêm mới hàng hóa {1}-{0}", item.Ten, item.Ma, Security.Username) , NgayTao = DateTime.Now , Username = Security.Username , PRowId = item.ID , PTen = item.Ten , RequestIp = Request.UserHostAddress , RawUrl = refUrl , LLOG_ID = 1 , Ten = "Thêm" }); #endregion } else { item = HangHoaDal.Update(item); #region log LogDal.log(item, new Log() { Checked = false , Info = string.Format("{2} sửa hàng hóa {1}-{0}", item.Ten, item.Ma, Security.Username) , NgayTao = DateTime.Now , Username = Security.Username , PRowId = item.ID , PTen = item.Ten , RequestIp = Request.UserHostAddress , RawUrl = refUrl , LLOG_ID = 2 , Ten = "Sửa" }); #endregion } TimKiemDal.Add(item, item.ID); rendertext(item.ID.ToString()); } break; #endregion case "remove": #region Xóa khách hàng if (logged && !IdNull) { var item = HangHoaDal.SelectById(new Guid(Id)); if (item.NguoiTao == Security.UserId) { HangHoaDal.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("{2} xóa khách hàng {1}-{0}", item.Ten, item.Ma, Security.Username) , NgayTao = DateTime.Now , Username = Security.Username , PRowId = item.ID , PTen = item.Ten , RequestIp = Request.UserHostAddress , RawUrl = refUrl , LLOG_ID = 3 , Ten = "Xóa" }); #endregion rendertext("1"); } else { rendertext("0"); } } break; #endregion case "search": #region search var pg = HangHoaDal.TimNhanh(q, 10); rendertext(JavaScriptConvert.SerializeObject(pg), "text/javascript"); break; #endregion default: break; } }