public WHDBcontent() { Whdb=new WHDB(); AccountDal=new AccountDal(this); MemberDal=new MemberDal(this); }
public int Update(Member member) { MemberDal memberDal = new MemberDal(); return(memberDal.Update(member)); }
public int Delete(int memberId) { MemberDal memberDal = new MemberDal(); return(memberDal.Delete(memberId)); }
protected override void Render(HtmlTextWriter writer) { StringBuilder sb = new StringBuilder(); ClientScriptManager cs = this.Page.ClientScript; string _ID = Request["ID"]; string _CQ_ID = Request["CQ_ID"]; string _Ten = Request["Ten"]; string _q = Request["q"]; string _Loai_Ten = Request["Loai_Ten"]; string _Loai_ID = Request["Loai_ID"]; switch (subAct) { case "get": #region Lấy danh sách if (string.IsNullOrEmpty(jgrsidx)) { jgrsidx = "ID"; } if (string.IsNullOrEmpty(jgrsord)) { jgrsord = "asc"; } RoleCollection ListGet = RoleDal.TreeByUsername(Security.Username, _q, _CQ_ID, "ROLE_" + jgrsidx + " " + jgrsord); List <jgridRow> ListRow = new List <jgridRow>(); foreach (Role item in ListGet) { ListRow.Add(new jgridRow(item.ID.ToString() , new string[] { item.ID.ToString(), item.Ten, item.Loai_Ten, item._CoQuan.Ten })); } jgrid grid = new jgrid("1", "1", ListGet.Count.ToString(), ListRow); sb.Append(JavaScriptConvert.SerializeObject(grid)); break; #endregion case "del": #region Xóa if (!string.IsNullOrEmpty(_ID)) { RoleDal.DeleteById(_ID); } break; #endregion case "edit": #region chỉnh sửa if (!string.IsNullOrEmpty(_ID)) { sb.Append("(" + JavaScriptConvert.SerializeObject(RoleDal.SelectById(Convert.ToInt32(_ID))) + ")"); } break; #endregion case "save": #region Lưu var ItemSave = new Role(); if (!string.IsNullOrEmpty(_ID)) { ItemSave = RoleDal.SelectById(Convert.ToInt32(_ID)); } ItemSave.Ten = _Ten; ItemSave.CQ_ID = Convert.ToInt32(_CQ_ID); ItemSave.NgayCapNhat = DateTime.Now; ItemSave.Active = true; ItemSave.HeThong = true; if (!string.IsNullOrEmpty(_Loai_ID)) { ItemSave.Loai_ID = new Guid(_Loai_ID); } ItemSave.Loai_Ten = _Loai_Ten; if (!string.IsNullOrEmpty(_ID)) { ItemSave = RoleDal.Update(ItemSave); } else { ItemSave.NgayTao = DateTime.Now; ItemSave.NguoiTao = Security.Username; ItemSave.RowId = Guid.NewGuid(); ItemSave = RoleDal.Insert(ItemSave); } sb.Append("1"); break; #endregion case "getFunction": #region Lấy function theo role if (!string.IsNullOrEmpty(_ID)) { FunctionCollection ListFnByRole = FunctionDal.SelectAllFunctionByRole(_ID); if (ListFnByRole.Count > 0) { sb.Append(getTop(ListFnByRole)); } else { sb.Append("0"); } } break; #endregion case "updateFunction": #region Cập nhật thay đổi RoleFunctionDal.UpdateByRoleIdFunctionList(_ID, Request["UpdateList"], Security.Username); sb.Append("1"); break; #endregion case "getUserByRole": #region Lấy thành viên trong nhóm if (!string.IsNullOrEmpty(_ID)) { MemberCollection ListUserByRole = MemberDal.SelectByRole(_ID); if (ListUserByRole.Count > 0) { foreach (Member item in ListUserByRole) { sb.AppendFormat(@"<input type=""checkbox"" _username=""{0}"" {2} > <b>{0}</b> [ {1} ] <br/>" , item.Username, item.Ten, item.Khoa ? @"checked=""checked""" : ""); } } else { sb.Append("0"); } } break; #endregion case "updateUsers": #region Lưu thay đổi thành viên trong nhóm if (!string.IsNullOrEmpty(_ID)) { MemberRoleDal.UpdateUserListRole(Request["UpdateList"], _ID, Security.Username); sb.AppendFormat("1"); } break; #endregion default: #region nạp FunctionCollection ListFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId); sb.Append(@"<div class=""mdl-head""> <span class=""mdl-head-searchPnl ui-state-default ui-corner-all""> <a href=""javascript:;"" class=""mdl-head-clearSearch""></a> <input type=""text"" class=""mdl-head-txt mdl-head-search mdl-head-search-quanLyQuyen"" /> </span> <a class=""mdl-head-btn mdl-head-add"" id=""quanLyQuyenMdl-addBtn"" href=""javascript:quanLyQuyen.add();"">Thêm</a> <a class=""mdl-head-btn mdl-head-edit"" id=""quanLyQuyenMdl-editBtn"" href=""javascript:quanLyQuyen.edit();"">Sửa</a> <a class=""mdl-head-btn mdl-head-del"" id=""quanLyQuyenMdl-delBtn"" href=""javascript:quanLyQuyen.del();"">Xóa</a> <span class=""mdl-head-filterPnl ui-state-default ui-corner-all""> <a href=""javascript:;"" class=""mdl-head-clearSearch""></a> <input type=""text"" _value="""" class=""mdl-head-filter mdl-head-filterQuanLyQuyenByCQID""/> </span> </div> <table id=""quanLyQuyenMdl-List"" class=""mdl-list""> </table> <div id=""quanLyQuyenMdl-Pager""></div> <div class=""sub-mdl quanLyQuyenMdl-subMdl""> <ul> <li> <a id=""quanLyQuyenMdl-functionmdl-subMdlBtn"" href=""#quanLyQuyenMdl-subMdl-mdl1"">Quyền</a> </li> <li> <a id=""quanLyQuyenMdl-usermdl-subMdlBtn"" href=""#quanLyQuyenMdl-subMdl-mdl2"">Người dùng thuộc nhóm</a> </li> </ul> <div id=""quanLyQuyenMdl-subMdl-mdl1""> <div id=""quanLyQuyenMdl-functionmdl-roleFnMdl""> </div> </div> <div id=""quanLyQuyenMdl-subMdl-mdl2""> <div id=""quanLyQuyenMdl-functionmdl-UserInRoleMdl""> </div> </div> </div> "); sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>" , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.hethong.quanLyQuyen.JScript1.js") , "{quanLyQuyen.loadgrid();}"); sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(ListFn)); break; #endregion } writer.Write(sb.ToString()); base.Render(writer); }
public int CreateNewMember(Member member) { MemberDal memberDal = new MemberDal(); return(memberDal.Insert(member)); }
public static void TestFixtureSetUp(TestContext context) { _ = context; _dal = new MemberDal(); CreateInitialData(); }
protected override void Render(HtmlTextWriter writer) { StringBuilder sb = new StringBuilder(); ClientScriptManager cs = this.Page.ClientScript; string subAct = Request["subAct"]; switch (subAct) { case "menu": //List<Function> MenuList = getTree(FunctionDal.SelectByUser(Security.Username)); //List<jgridRow> ListRow = new List<jgridRow>(); //foreach (Function fn in MenuList) //{ // if (fn.Loai != 3) // { // ListRow.Add(new jgridRow(fn.ID.ToString(), new string[] { fn.ID.ToString(), fn.Ten, fn.Url, fn.Level.ToString(), fn.PID.ToString(), fn.Level == 1 ? "false" : "true", "false" })); // } //} //jgrid grid = new jgrid("1", "1", MenuList.Count.ToString(), ListRow); //sb.Append(JavaScriptConvert.SerializeObject(grid)); sb.AppendFormat(getTop(getTree(FunctionDal.SelectByUser(Security.Username, "0")))); break; case "desk": sb.AppendFormat(@"<script src=""{0}"" type=""text/javascript""></script>" , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.plugManager.admin.js")); sb.AppendFormat(@"<div id=""desktopMdl-content-head""> <a href=""javascript:;"" id=""desktopMdl-content-head-showbtn""> <span id=""desktopMdl-content-head-showbtn-title"" class=""ui-widget-content ui-corner-top""> Thêm Module </span> <span id=""desktopMdl-content-head-showbtn-box""> <span class=""ui-widget-content ui-corner-all"" id=""desktopMdl-content-head-showbtn-boxPnl""> <span class=""ui-widget-content ui-corner-all"" id=""desktopMdl-content-head-showbtn-boxPnl-content"">"); FunctionCollection UFC = FunctionDal.SelectByUser(Security.Username, "1"); foreach (Function ufcItem in UFC) { sb.AppendFormat(@"<span onclick=""myModule.add('{0}','{1}')"" class=""desktopMdl-content-head-showbtn-boxPnl-content-item""><span onclick=""myModule.add('{0}','{1}')"" class=""desktopMdl-content-button-add"">Add</span>{2}</span>", ufcItem.ID, ufcItem.Url, ufcItem.Ten); } sb.AppendFormat(@"</span> </span> </span> </a>"); Member mMember = MemberDal.SelectAllByUserName(Security.Username); sb.AppendFormat(@"<b id=""desktopMdl-content-head-title"">Phiên làm việc: {0} <span id=""desktopMdl-content-head-date"">{1}</span></b> </div>", mMember.Ten.ToString(), string.Format("{0:dd/MM/yyyy}", DateTime.Now)); sb.AppendFormat(@"<div id=""desktopMdl-content-body"">"); sb.Append("</div>"); break; case "Update": if (!string.IsNullOrEmpty(Request["layplug"])) { string layplug = Request["layplug"]; XmlDocument doc = new XmlDocument(); XmlNode node = doc.ImportNode(PlugHelper.RenderXml(toList(Request["iList"]), Request["plugtype"]), true); doc.AppendChild(node); UserFunction itemUpdate = UserFunctionDal.SelectById(Convert.ToInt32(layplug)); itemUpdate.Doc = linh.common.Lib.GetXmlString(doc); itemUpdate = UserFunctionDal.Update(itemUpdate); sb.Append(PlugHelper.RenderHtml(doc)); } break; case "ReOrder": if (!string.IsNullOrEmpty(Request["NewZoneIndex"])) { string layplug = Request["layplug"]; string layid = Request["NewZoneIndex"]; UserFunction itemUpdate = UserFunctionDal.SelectById(Convert.ToInt32(layplug)); itemUpdate.LAY_ID = Convert.ToInt32(layid); itemUpdate.ThuTu = Convert.ToInt32(Request["NewModuleIndex"]); itemUpdate = UserFunctionDal.Update(itemUpdate); UserFunctionDal.UpdateReorder(Request["NewZoneOrderList"]); } break; case "Remove": if (!string.IsNullOrEmpty(Request["layplug"])) { string layplug = Request["layplug"]; UserFunction itemRemove = UserFunctionDal.SelectById(Convert.ToInt32(layplug)); UserFunctionDal.DeleteById(itemRemove.ID); } break; case "Add": string _FN_ID = Request["FN_ID"]; string _Url = Request["Url"]; string _LayID = Request["LayID"]; string _DocValue = ""; try { XmlDocument doc = new XmlDocument(); XmlNode node = doc.ImportNode(PlugHelper.RenderXml(_Url), true); doc.AppendChild(node); _DocValue = linh.common.Lib.GetXmlString(doc); UserFunction ItemSave = new UserFunction(); ItemSave.FN_ID = Convert.ToInt32(_FN_ID); ItemSave.FN_Url = _Url; ItemSave.LAY_ID = Convert.ToInt32(_LayID); ItemSave.NgayTao = DateTime.Now; ItemSave.NguoiTao = Security.Username; ItemSave.Username = Security.Username; ItemSave.ThuTu = 1; ItemSave.RowId = Guid.NewGuid(); ItemSave.Doc = _DocValue; ItemSave = UserFunctionDal.Insert(ItemSave); sb.Append(PlugHelper.RenderHtml(doc.LastChild, ItemSave.ID)); } catch (Exception ex) { } break; default: break; } sb.AppendFormat(@"<script src=""{0}"" type=""text/javascript""></script>" , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.plugManager.admin.js")); writer.Write(sb.ToString()); base.Render(writer); }
public override void KhoiTao(SqlConnection con) { bool login = Security.IsAuthenticated(); Page _Page = new Page(); ClientScriptManager cs = _Page.ClientScript; StringBuilder sb = new StringBuilder(); HttpContext c = HttpContext.Current; string _Usr = c.Request["Usr"]; string _Pwd = c.Request["Pwd"]; string _Rem = c.Request["Rem"]; string _Ten = c.Request["Ten"]; string _Email = c.Request["Email"]; string _ActiveCode = c.Request["ActiveCode"]; string _GioiTinh = c.Request["GioiTinh"]; switch (subAct) { case "Login": #region Login sb.Append(Security.Login(_Usr, _Pwd, _Rem).ToString()); break; #endregion case "LogOut": #region LogOut Security.LogOut(); break; #endregion case "Reg": #region Reg: Đăng ký if (!string.IsNullOrEmpty(_Email) && !string.IsNullOrEmpty(_Usr)) { string activeCode = CaptchaImage.GenerateRandomCode(CaptchaType.Numeric, 6); User Item = new User(); Item.Active = false; Item.ActiveCode = activeCode; Item.Email = _Email; Item.NgayTao = DateTime.Now; Item.Ten = _Ten; Item.RowId = Guid.NewGuid(); Item.Username = _Usr; Item.GioiTinh = Convert.ToBoolean(_GioiTinh); Item.Pwd = linh.common.maHoa.EncryptString(_Usr, _Usr); Item = UserDal.Insert(Item); sendEmailDele dele = new sendEmailDele(omail.SendthongBao); IAsyncResult ar = dele.BeginInvoke(_Email, "Căng tin (cangtin.com) - Email kích hoạt", string.Format(emailActiveBody, _Ten, Item.ActiveCode , domain, _Email), null, null); sb.Append(Item.ID.ToString()); } break; #endregion case "ValidateEmail": #region ValidateEmail : Kiểm tra email if (!string.IsNullOrEmpty(_Email)) { sb.Append(MemberDal.ValidEmail(_Email).ToString()); } break; #endregion case "ActiveByCode": #region AciveByCode : Kiểm tra ActiveCode if (!string.IsNullOrEmpty(_ActiveCode)) { bool ok = UserDal.ValidActiveCode(_ActiveCode, Security.Username); if (!ok) { Security.Login(Security.Username, "True"); c.Session["c-user"] = null; } if (!string.IsNullOrEmpty(Request["type"])) { c.Response.Redirect(domain); } else { sb.Append(ok.ToString()); } } break; #endregion case "ReSendActiveEmail": #region ReSendActiveEmail : Gửi lại mail if (!string.IsNullOrEmpty(_Email)) { User Item = UserDal.SelectByUsername(Security.Username); if (_Email != Item.Email) { if (UserDal.ValidEmail(_Email)) { sb.Append("0"); } else { UserDal.UpdateEmail(Security.Username, _Email); } } sendEmailDele dele = new sendEmailDele(omail.SendthongBao); IAsyncResult ar = dele.BeginInvoke(_Email, "Căng tin (cangtin.com) - Email kích hoạt", string.Format(emailActiveBody, _Ten, Item.ActiveCode , domain, _Email), null, null); rendertext("1"); } break; #endregion case "ValidateUsername": #region ValidateUsername : Kiểm tra username if (!string.IsNullOrEmpty(_Usr)) { sb.Append(UserDal.ValidUsername(_Usr).ToString()); } break; #endregion case "scpt": #region Nạp js sb.AppendFormat(@"{0}" , cs.GetWebResourceUrl(typeof(authentication), "appStore.authorityStore.userMgr.js.js")); break; #endregion default: break; } Html = sb.ToString(); base.KhoiTao(con); }
protected override void Render(System.Web.UI.HtmlTextWriter writer) { string u = Request["u"]; string pwd = Request["p"]; string r = Request["r"]; string _code = Request["code"]; string _email = Request["email"]; StringBuilder sb = new StringBuilder(); string subact = Request["subact"]; switch (subact) { case "logout": Security.LogOut(); sb.AppendFormat("1"); break; case "changePass": #region changePass: Đổi mật khẩu if (!string.IsNullOrEmpty(u)) { pwd = maHoa.EncryptString(pwd, u); if (MemberDal.UpdatePasswordByCode(u, _code, pwd)) { sb.Append("1"); } else { sb.Append("0"); } } else { sb.Append("0"); } break; #endregion case "recovery": #region recovery: Lấy lại mật khẩu if (!string.IsNullOrEmpty(u)) { string e = MemberDal.SelectEmailByUserName(u).Email; if (!string.IsNullOrEmpty(e)) { string newPass = CaptchaImage.GenerateRandomCode(CaptchaType.Numeric, 5); MemberDal.UpdateCodeByUsername(u, newPass); sendEmailDele _dele = new sendEmailDele(sendmail); _dele.BeginInvoke(e, "Ma xac nhan", string.Format("Username:{0}<br/>Ma xac nhan: {1}", e, newPass), null, null); sb.Append("1"); } else { sb.Append("0"); } } else { sb.Append("0"); } break; #endregion default: bool ok = Security.Login(u, pwd, r.ToLower()); if (ok) { sb.AppendFormat(u); } else { sb.AppendFormat("0"); } break; } writer.Write(sb.ToString()); base.Render(writer); }
static void Main(string[] args) { List <Member> members = new List <Member>(); // Standart üyelikler için liste oluşturuldu. MernisServiceAdapter adapter = new MernisServiceAdapter(); MemberDal memberDal = new MemberDal(members, adapter); // Listelere ulaşımda gerekli olan MemberDal instance'ı oluşturuldu. AccountManager accountManager = new AccountManager(memberDal); // Hesap yönetimi için gerekli olan nihai araç, accountManager'a accountManager.SignUp(new Member() // Listeye başlangıç ataması için bir adet üye atandı. { DateOfBirth = new DateTime(1995, 3, 12), Id = 1, Name = "Yiğit", Lastname = "Arpacıoğlu", TC = 1111111111 // Hata alınmaması adına gerçek kullanıcı bilgileri girilmelidir. }); accountManager.ListAccounts(); // ait bir instance oluşturuldu. //accountManager.SignUp(new Member() //{ // DateOfBirth = new DateTime(1994, 2, 23), // Id = 2, // Name = "AAAA", // Lastname = "BBBBBB", // TC = 12345678912 //}); //accountManager.SignUp(new Member() //{ // DateOfBirth = new DateTime(1995, 9, 11), // Id = 3, // Name = "CCCCCC", // Lastname = "DDDDDDD", // TC = 98765432198 //}); // Yeni üyeler eklenebilir. Fakat hatalı üyelerin MERNIS'e takılabileceği göz önünde bulundurulmalıdır. accountManager.UpdateAccount(1, new Member() { DateOfBirth = new DateTime(1995, 3, 12), Id = 1, Name = "Yiğit", Lastname = "Arpacıoğlu", TC = 11111111111111 // Hata alınmaması adına gerçek kullanıcı bilgileri girilmelidir. });; // güncelleme işlemi yapıldı. // accountManager.DeleteAccount(3); // hesap silindi. accountManager.ListAccounts(); List <CampaignCoupon> coupons = new List <CampaignCoupon>() { new CampaignCoupon() { Id = 1, Discount = 35, Name = "Spring Deal" }, new CampaignCoupon() { Id = 2, Discount = 15, Name = "Halloween Deal" }, new CampaignCoupon() { Id = 3, Discount = 70, Name = "New eve coupon" } }; // Kampanyalar oluşturuldu. CampaignCouponDal campaignCouponDal = new CampaignCouponDal(coupons); CampaignCouponManager campaignCouponManager = new CampaignCouponManager(campaignCouponDal); campaignCouponManager.DefineNewCoupon(new CampaignCoupon() { Id = 4, Discount = 10, Name = "New membership discount(Valid for 15 days)" }); campaignCouponManager.DeleteCoupon(4); campaignCouponManager.ListCoupons(); List <GameEdition> gameEdition = new List <GameEdition>() { new GameEdition() { Id = 1, Name = "Basic", Price = 80, }, new GameEdition() { Id = 2, Name = "Premium", Price = 125, }, new GameEdition() { Id = 3, Name = "Legendary", Price = 155, } }; // oyun sürümleri tanımlandı. List <Sale> salesList = new List <Sale>(); // yeni bir satış listesi oluşturuldu List <Member> customers = new List <Member>(); // Satın alım yapan üyelikler için müşteri listesi tanımlandı. SaleManager saleManager = new SaleManager(salesList, customers, memberDal) { }; saleManager.ListSales(); // tüm elemanlar listelendi. int discount = saleManager.Discount(coupons[1]); // Discount fonksiyonu ile kupon seçimi yapıldı. // Liste elemanı ile seçim yapıldığı için sıralamanın 0'dan başladığı düşünülmelidir. saleManager.BuyGame(gameEdition[0], members[0], discount); // Yine liste elemanları ile satın alım gerçekleştirildi. saleManager.Refund(salesList[0]); // Satın alınan ürün geri iade edildi.tea }