本文整理汇总了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);
}
}