当前位置: 首页>>代码示例>>C#>>正文


C# Logic.CreatePerson方法代码示例

本文整理汇总了C#中Logic.CreatePerson方法的典型用法代码示例。如果您正苦于以下问题:C# Logic.CreatePerson方法的具体用法?C# Logic.CreatePerson怎么用?C# Logic.CreatePerson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Logic的用法示例。


在下文中一共展示了Logic.CreatePerson方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnCreate_Click

    protected void btnCreate_Click(object sender, EventArgs e)
    {
        try
        {
            TaskManagerModelContainer db = new TaskManagerModelContainer();
            Logic lo = new Logic();
            List<string> users = (from d in db.People select d.Username).ToList();

            string uname, fname, lname, pword;
            uname = txtUsername.Text;
            lname = txtLastname.Text;
            fname = txtFirstname.Text;
            pword = txtPassword.Text;

            if (uname.Length == 0 || lname.Length == 0 || fname.Length == 0 || pword.Length == 0)
            {
                Label lb = new Label();
                lb.Text = "Empty Fields Are Not Allowed.";
                Panel1.CssClass = "divError";
                icon.CssClass = "img";
                icon.ImageUrl = "~/assets/icons/error3.png";
                icon.Visible = true;
                PlaceHolder1.Controls.Add(lb);
            }
            else if (uname.Length != 0 && lname.Length != 0 && fname.Length != 0 && pword.Length != 0)
            {
                if (users.Contains(uname))
                {
                    Label lb = new Label();
                    lb.Text = "Username Already Taken";
                    Panel1.CssClass = "divError";
                    icon.CssClass = "img";
                    icon.ImageUrl = "~/assets/icons/error3.png";
                    icon.Visible = true;
                    PlaceHolder1.Controls.Add(lb);
                }
                else if (!users.Contains(uname))
                {
                    Person p = new Person();
                    p.Firstname = fname;
                    p.Lastname = lname;
                    p.Username = uname;
                    p.Password = pword;
                    p.DateCreated = DateTime.Now;
                    if (lo.CreatePerson(p))
                    {
                        Label lb = new Label();
                        lb.Text = "Account Created Successfully";
                        Panel1.CssClass = "divSuccess";
                        icon.CssClass = "img";
                        icon.ImageUrl = "~/assets/icons/success3.png";
                        icon.Visible = true;
                        PlaceHolder1.Controls.Add(lb);
                    }
                    else if (!lo.CreatePerson(p))
                    {
                        Label lb = new Label();
                        lb.Text = "Account Creation Failed";
                        Panel1.CssClass = "divError";
                        icon.CssClass = "img";
                        icon.ImageUrl = "~/assets/icons/error3.png";
                        icon.Visible = true;
                        PlaceHolder1.Controls.Add(lb);
                    }
                }
            }
        }
        catch (ArgumentException ar)
        {
            Label lb = new Label();
            lb.Text = ar.Message; //"Registration Failed";
            Panel1.CssClass = "divError";
            icon.CssClass = "img";
            icon.ImageUrl = "~/assets/icons/error3.png";
            icon.Visible = true;
            PlaceHolder1.Controls.Add(lb);
        }
    }
开发者ID:imostom,项目名称:TaskManager,代码行数:78,代码来源:Register.aspx.cs


注:本文中的Logic.CreatePerson方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。