public override void InitControl() { hfValue.Value = lblValue.Text = (Value ?? "").ToString(); IAccountHelper accountHelper = AccountFactory.CreateInstance(); Account account = accountHelper.GetAccount(hfValue.Value, null); if (account == null) { ltlText.Text = ""; } else { string data = Control.Params[We7.Model.Core.UI.Constants.DATA]; if (!string.IsNullOrEmpty(data) && data == "admin") { //ShopPlugin.AdvanceUser DataTable dt = ModelDBHelper.Create("ShopPlugin.AdvanceUser").Query(new Criteria(CriteriaType.Equals, "UserID", hfValue.Value), new List <Order>() { new Order("ID", OrderMode.Desc) }, 0, 0); if (dt != null && dt.Rows.Count > 0) { ltlText.Text = "<a href='/admin/AddIns/ModelEditor.aspx?notiframe=1&model=ShopPlugin.AdvanceUser&ID=" + dt.Rows[0]["ID"].ToString() + "'>" + account.LoginName + "</a>"; } else { ltlText.Text = "<a href='/admin/Permissions/AccountEdit.aspx?id=" + account.ID + "'>" + account.LoginName + "</a>"; } } else { ltlText.Text = account.LoginName; } } }
/// <summary> /// 验证用户 /// </summary> void Authenticate() { if (String.Compare(LoginName, SiteConfigs.GetConfig().AdministratorName, false) == 0) { if (CDHelper.AdminPasswordIsValid(Password)) { Security.SetAccountID(We7Helper.EmptyGUID); UserName = SiteConfigs.GetConfig().AdministratorName; IsSignIn = true; } else { IsSignIn = false; Message = "密码错误"; } } else { if (Request["Authenticator"] != null && Request["accountID"] != null) { SSORequest ssoRequest = SSORequest.GetRequest(HttpContext.Current); string actID = ssoRequest.AccountID; if (Authentication.ValidateEACToken(ssoRequest) && !string.IsNullOrEmpty(actID) && We7Helper.IsGUID(actID)) { Security.SetAccountID(actID, IsPersist); UserName = ssoRequest.UserName; IsSignIn = true; } else if (Request["message"] != null) { Message = Request["message"]; IsSignIn = false; return; } } else { IAccountHelper AccountHelper = AccountFactory.CreateInstance(); string[] result = AccountHelper.Login(LoginName, Password); if (result[0] == "false") { Message = result[1]; IsSignIn = false; } else { IsSignIn = true; UserName = AccountHelper.GetAccount(result[1], new string[] { "LoginName" }).LoginName; Response.Redirect(ReturnUrl); } } } }
void bttnUpload_Click(object sender, EventArgs e) { string message = string.Empty; if (!fuPhoto.HasFile) { message = "上传图片不能为空"; } else { string ext = Path.GetExtension(fuPhoto.FileName); if (!string.IsNullOrEmpty(ext)) { ext = ext.ToLower(); if (ext == ".jpg" || ext == ".png" || ext == ".gif") { string fileName = GetImageUrl(fuPhoto.FileName); string filePath = Server.MapPath(fileName); FileInfo fi = new FileInfo(filePath); if (!fi.Directory.Exists) { fi.Directory.Create(); } fuPhoto.SaveAs(Server.MapPath(fileName)); string thumbfileName = GetThumbUrl(fileName); string thumbPath = Server.MapPath(thumbfileName); ImageUtils.MakeThumbnail(filePath, thumbPath, 120, 120, "HW"); imgPhoto.ImageUrl = thumbfileName; IAccountHelper helper = AccountFactory.CreateInstance(); Account act = helper.GetAccount(Security.CurrentAccountID, null); act.Photo = thumbfileName; helper.UpdateAccount(act, new string[] { "Photo" }); message = "上传成功"; } else { message = "上传文件格式不对"; } } else { message = "上传文件格式不对"; } } ScriptManager.RegisterStartupScript(Page, Page.GetType(), "message", "alert('" + message + "')", true); }
public string GetText(object dataItem, ColumnInfo columnInfo) { string v = ModelControlField.GetValue(dataItem, columnInfo.Name); IAccountHelper accountHelper = AccountFactory.CreateInstance(); Account account = accountHelper.GetAccount(v, null); if (account == null) { return(""); } else { if (v == We7Helper.EmptyGUID) { return("admin"); } return("<a href='" + GetUrl(columnInfo) + v + "'>" + account.LoginName + "</a>"); } //return }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Cache.SetNoStore(); context.Response.Clear(); string action = context.Request["action"]; string msg = "success"; if (!String.IsNullOrEmpty(action)) { IAccountHelper helper = AccountFactory.CreateInstance(); string key = context.Request["value"]; action = action.Trim().ToLower(); Account act = null; if (action == "user") { act = helper.GetAccountByLoginName(key); if (act != null) { context.Response.Write("当前用户已存在"); return; } } if (action == "email") { act = helper.GetAccountByEmail(key); if (act != null) { context.Response.Write("当前Email已被注册"); return; } } if (action == "validate") { act = helper.GetAccount(context.Request["AccountID"], null); if (act == null) { context.Response.Write("验证帐号不存在,请重新申请帐号!"); } else { act.EmailValidate = 1; act.State = 1; helper.UpdateAccount(act, new string[] { "EmailValidate", "State" }); } } if (action == "submit") { Account newAccout = new Account(); newAccout.LoginName = context.Request["name"]; newAccout.Password = context.Request["pwd"]; if (SiteConfigs.GetConfig().IsPasswordHashed) { newAccout.Password = Security.Encrypt(newAccout.Password); } newAccout.Email = context.Request["email"]; newAccout.UserType = 1; newAccout.Created = DateTime.Now; try { helper.AddAccount(newAccout); if (SendEmail(newAccout, context.Request)) { msg += ":email"; } } catch (Exception ex) { context.Response.Write(ex.Message); return; } } } context.Response.Write(msg); }
public Voucher Save(VoucherViewModel vmVoucher) { Voucher voucher = new Voucher(); if (vmVoucher.VId > 0) { //修改凭证 voucher = this.GetMyVoucher(vmVoucher.VId); if (voucher == null) { return(null); } voucher.CertificateWord = _ledger.CertificateWords.Where(cw => cw.CwId == vmVoucher.CwId).FirstOrDefault(); voucher.CertWordSN = vmVoucher.CertWordSN; voucher.VoucherYear = vmVoucher.VoucherDate.Year; voucher.VoucherMonth = vmVoucher.VoucherDate.Month; voucher.VoucherDate = vmVoucher.VoucherDate; voucher.PaymentTerms = string.Format("{0}{1:D2}", voucher.VoucherYear, voucher.VoucherMonth); voucher.InvoiceCount = vmVoucher.InvoiceCount; foreach (VoucherDetailViewModel vd in vmVoucher.VoucherDetails) { VoucherDetail vDetail = new VoucherDetail(); if (vd.VdId > 0) { vDetail = voucher.VoucherDetails.Where(d => d.VdId == vd.VdId).FirstOrDefault(); } else { voucher.VoucherDetails.Add(vDetail); } vDetail.Abstract = vd.Abstract; vDetail.Account = _account.GetAccount(vd.AccId.Value); vDetail.AccountCode = vDetail.Account.AccCode; vDetail.AccountName = vDetail.Account.AccName; vDetail.Quantity = vd.Quantity; vDetail.Price = vd.Price; if (vDetail.Account.Direction == "借") { vDetail.Debit = vd.Debit; vDetail.Credit = vd.Credit * (-1); } else { vDetail.Debit = vd.Debit * (-1); vDetail.Credit = vd.Credit; } vDetail.InitialBalance = vDetail.Account.InitialBalance; vDetail.InitialQuantity = vDetail.Account.InitialQuantity; vDetail.YtdBeginBalance = vDetail.Account.YtdBeginBalance; vDetail.YtdBeginBalanceQuantity = vDetail.Account.YtdBeginBalanceQuantity; if (vDetail.Account.Direction == "借") { vDetail.YtdDebit = vDetail.Account.YtdDebit + vDetail.Debit; vDetail.YtdDebitQuantity = vDetail.Account.YtdDebitQuantity + vDetail.Quantity; } else { vDetail.YtdCredit = vDetail.Account.YtdCredit + vDetail.Credit; vDetail.YtdCreditQuantity = vDetail.Account.YtdCreditQuantity + vDetail.Quantity; } } } else { //新增凭证 voucher.CertificateWord = _ledger.CertificateWords.Where(cw => cw.CwId == vmVoucher.CwId).FirstOrDefault(); voucher.CertWordSN = vmVoucher.CertWordSN; voucher.VoucherYear = vmVoucher.VoucherDate.Year; voucher.VoucherMonth = vmVoucher.VoucherDate.Month; voucher.VoucherDate = vmVoucher.VoucherDate; voucher.PaymentTerms = string.Format("{0}{1:D2}", voucher.VoucherYear, voucher.VoucherMonth); voucher.InvoiceCount = vmVoucher.InvoiceCount; voucher.State = VoucherState.PaddingAudit; voucher.AccountBook = _acctBook.GetCurrentBook(); voucher.Creator = ((ClaimsIdentity)_context.User.Identity).Claims.Where(c => c.Type == "name").FirstOrDefault().Value; voucher.CreateTime = DateTime.Now; voucher.VoucherDetails = new List <VoucherDetail>(); foreach (VoucherDetailViewModel vd in vmVoucher.VoucherDetails) { VoucherDetail vDetail = new VoucherDetail(); vDetail.Abstract = vd.Abstract; vDetail.Account = _account.GetAccount(vd.AccId.Value); vDetail.AccountCode = vDetail.Account.AccCode; vDetail.AccountName = vDetail.Account.AccName; vDetail.Quantity = vd.Quantity; vDetail.Price = vd.Price; //vDetail.Debit = vd.Debit; //vDetail.Credit = vd.Credit; if (vDetail.Account.Direction == "借") { vDetail.Debit = vd.Debit; vDetail.Credit = vd.Credit * (-1); } else { vDetail.Debit = vd.Debit * (-1); vDetail.Credit = vd.Credit; } vDetail.InitialBalance = vDetail.Account.InitialBalance; vDetail.InitialQuantity = vDetail.Account.InitialQuantity; vDetail.YtdBeginBalance = vDetail.Account.YtdBeginBalance; vDetail.YtdBeginBalanceQuantity = vDetail.Account.YtdBeginBalanceQuantity; if (vDetail.Account.Direction == "借") { vDetail.YtdDebit = vDetail.Account.YtdDebit + vDetail.Debit; vDetail.YtdDebitQuantity = vDetail.Account.YtdDebitQuantity + vDetail.Quantity; } else { vDetail.YtdCredit = vDetail.Account.YtdCredit + vDetail.Credit; vDetail.YtdCreditQuantity = vDetail.Account.YtdCreditQuantity + vDetail.Quantity; } voucher.VoucherDetails.Add(vDetail); } _ledger.Vouchers.Add(voucher); } if (_ledger.SaveChanges() > 0) { //科目统计数据 this.RecalculateAllAccount(); return(voucher); } return(null); }
/// <summary> /// 添加评论 /// </summary> protected void SubmitComment() { try { SiteSettingHelper CDHelper = HelperFactory.GetHelper <SiteSettingHelper>(); IAccountHelper AccountHelper = AccountFactory.CreateInstance(); CommentsHelper CommentsHelper = HelperFactory.GetHelper <CommentsHelper>(); Comments cm = new Comments(); DateTime Createdtime = DateTime.Now; if (ArticleIDByRedirect != "") { cm.ArticleID = ArticleIDByRedirect; } else { cm.ArticleID = ArticleID; } if (CDHelper.Config.IsAuditComment) { cm.State = 0; } else { cm.State = 1; } if (IsSignin) { string actID = CurrentAccount; if (We7Helper.IsEmptyID(actID)) { cm.Author = "系统管理员"; } else { Account act = AccountHelper.GetAccount(CurrentAccount, new string[] { "FirstName", "LastName", "LoginName" }); cm.Author = String.Format("{0} {1}({2})", act.LastName, act.FirstName, act.LoginName); } cm.AccountID = actID; } else { cm.Author = Author; cm.AccountID = ""; } cm.Content = Content; cm.Created = Createdtime; cm.ID = We7Helper.CreateNewID(); cm.ArticleName = Title; CommentsHelper.AddComments(cm); Message = CDHelper.Config.IsAuditComment ? "评论发表成功,等待系统审核!" : "发表成功!"; Content = ""; } catch (Exception ex) { Message = ex.Message; } }