コード例 #1
0
//-------------------------------------------------------------------------------------------
    protected void MakePayment_Click(object sender, EventArgs e)
    {
        using (WeavverEntityContainer data = new WeavverEntityContainer())
        {
            DateTime postAtDate = DateTime.UtcNow;
            if (DateTime.TryParse(PostAt.Text, out postAtDate))
            {
                postAtDate = postAtDate.ToUniversalTime();
            }

            Logistics_Organizations accountFrom = (from accounts in data.Logistics_Organizations
                                                   where accounts.Id == new Guid(FromAccount.SelectedValue)
                                                   select accounts).FirstOrDefault();

            Accounting_Accounts accountTo = (from toAccounts in data.Accounting_Accounts
                                             where toAccounts.Id == new Guid(ToAccount.SelectedValue)
                                             select toAccounts).FirstOrDefault();

            Guid transactionId = Guid.NewGuid();

            Accounting_LedgerItems creditFinancialAccount = new Accounting_LedgerItems();
            creditFinancialAccount.OrganizationId = SelectedOrganization.Id;
            creditFinancialAccount.TransactionId  = transactionId;
            creditFinancialAccount.PostAt         = postAtDate;
            creditFinancialAccount.AccountId      = accountFrom.Id;
            creditFinancialAccount.LedgerType     = LedgerType.Receivable.ToString();
            creditFinancialAccount.Code           = CodeType.Deposit.ToString();
            creditFinancialAccount.Memo           = String.Format("Check {0} to {1}", CheckNum.Text, accountTo.Name);
            creditFinancialAccount.Amount         = Decimal.Parse(Amount.Text);
            data.Accounting_LedgerItems.AddObject(creditFinancialAccount);

            Accounting_LedgerItems creditReceivableAccount = new Accounting_LedgerItems();
            creditReceivableAccount.OrganizationId = SelectedOrganization.Id;
            creditReceivableAccount.TransactionId  = transactionId;
            creditReceivableAccount.PostAt         = postAtDate;
            creditReceivableAccount.LedgerType     = accountTo.LedgerType;
            creditReceivableAccount.AccountId      = new Guid(ToAccount.SelectedValue);
            creditReceivableAccount.Code           = CodeType.Payment.ToString();
            creditReceivableAccount.Memo           = String.Format("Check {0} from {1}", CheckNum.Text, accountFrom.Name);
            creditReceivableAccount.Amount         = Decimal.Parse(Amount.Text);
            data.Accounting_LedgerItems.AddObject(creditReceivableAccount);

            data.SaveChanges();

            Response.Redirect("~/Accounting_LedgerItems/List.aspx?TransactionId=" + transactionId.ToString());
        }
    }
コード例 #2
0
ファイル: Register.ascx.cs プロジェクト: MikeKMiller/weavver
//-------------------------------------------------------------------------------------------
    protected void CaptchaStepNext_Click(object sender, EventArgs e)
    {
        if (Request["checkingout"] == "true" ||
            Request["recaptcha_response_field"] == ConfigurationManager.AppSettings["recaptcha_bypasskey"] ||
            Weavver.Vendors.Google.reCAPTCHA.Verify(ConfigurationManager.AppSettings["recaptcha_privatekey"],
                                                    Request.UserHostAddress,
                                                    Request["recaptcha_challenge_field"],
                                                    Request["recaptcha_response_field"]))
        {
            string emailaddress = ((TextBox)GetControlFromWizard(UserInfoStep, "EmailAddress")).Text;
            string username     = ((TextBox)GetControlFromWizard(UserInfoStep, "UserName")).Text;
            string password     = ((TextBox)GetControlFromWizard(UserInfoStep, "Password")).Text;
            string firstname    = ((TextBox)GetControlFromWizard(UserInfoStep, "FirstName")).Text;
            string lastname     = ((TextBox)GetControlFromWizard(UserInfoStep, "LastName")).Text;
            string orgname      = ((TextBox)GetControlFromWizard(UserInfoStep, "OrganizationName")).Text;
            string referredby   = (Session["ReferredBy"] == null) ? null : Session["referredby"].ToString();
            WeavverMembershipProvider provider = (WeavverMembershipProvider)System.Web.Security.Membership.Provider;
            MembershipCreateStatus    status   = MembershipCreateStatus.Success;
            MembershipUser            user     = provider.CreateUser(username, Session["UserPassword"].ToString(), emailaddress, "NONE", "", false, Guid.NewGuid(), Request.UserHostAddress, referredby, out status);
            if (status == MembershipCreateStatus.Success)
            {
                using (WeavverEntityContainer data = new WeavverEntityContainer())
                {
                    System_Users newUser = provider.GetUser(username);

                    Logistics_Organizations newOrg = new Logistics_Organizations();
                    newOrg.Id               = Guid.NewGuid();
                    newOrg.OrganizationId   = new Guid(ConfigurationManager.AppSettings["default_organizationid"]);
                    newOrg.OrganizationType = OrganizationTypes.Personal.ToString();
                    newOrg.Name             = (!String.IsNullOrEmpty(orgname)) ? orgname : firstname + " " + lastname;
                    newOrg.EIN              = "";
                    newOrg.Founded          = DateTime.UtcNow;
                    newOrg.Bio              = "My bio";
                    newOrg.CreatedAt        = DateTime.UtcNow;
                    newOrg.CreatedBy        = newUser.Id;
                    newOrg.UpdatedAt        = DateTime.UtcNow;
                    newOrg.UpdatedBy        = newUser.Id;
                    data.Logistics_Organizations.AddObject(newOrg);

                    data.System_Users.Attach(newUser);
                    newUser.OrganizationId = newOrg.Id;
                    newUser.FirstName      = firstname;
                    newUser.LastName       = lastname;

                    int changedRows = data.SaveChanges();
                    if (changedRows > 0)
                    {
                        // add this user as an administrator to their ORG
                        string oldAppName = Roles.ApplicationName;
                        Roles.ApplicationName = newOrg.Id.ToString();
                        Roles.CreateRole("Administrators");
                        Roles.AddUserToRole(newUser.Username, "Administrators");
                        Roles.ApplicationName = oldAppName;
                    }
                }
                //newOrg.Commit();

                MailMessage mNewUser = new MailMessage("*****@*****.**", System.Configuration.ConfigurationManager.AppSettings["admin_address"]);
                mNewUser.Subject = "New user";
                //mm.Body = CreateUserWizard1.Email;
                mNewUser.Body = "User: "******"\r\n"
                                + "Created At: " + DateTime.Now.ToString() + "\r\n"
                                + "By IP: " + Request.UserHostAddress + "\r\n"
                                + "Referred By: " + Session["ReferredBy"];

                SmtpClient client2 = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["smtp_server"]);
                client2.Send(mNewUser);

                FormsAuthentication.SetAuthCookie(username, true);
                if (Request.QueryString["checkingout"] == "true")
                {
                    Response.Redirect("~/workflows/sales_orderplace");
                }
                else
                {
                    provider.SendUserActivationInstructions(user.UserName, Request.Url.Scheme + "://" + Request.Url.Host);
                    Wizard1.ActiveStepIndex++;
                }
            }
            else
            {
                throw new Exception("We could not create your account. Please try again later.");
            }
        }
        else
        {
            ReloadCaptcha();
            ((Literal)GetControlFromWizard(CaptchaStep, "CaptchaError")).Text = "Please try again.";
        }
    }