昨天做了XPO方面的相关实践。感觉刚开始用的时候不是太顺手,呵呵,很多东西都不熟悉。经过了近一天的努力终于基本上完成了。在这里总结一下。
一共就两个对象:KOL,FamilyMember 。两对象为主从关系。
KOL
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DevExpress.Xpo;
namespace XPOTest
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
{
public class KOL:XPBaseObject
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
private Guid id;
[Key(true)]
public Guid ID
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return id; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ id = value; }
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
private string name;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Name
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return name; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ name = value; }
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
private bool gender;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public bool Gender
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return gender; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ gender = value; }
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
private byte[] photo;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public byte[] Photo
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return photo; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ photo = value; }
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
private string hospital;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Hospital
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return hospital; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ hospital = value; }
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
private string department;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Department
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return department; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ department = value; }
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
private string city;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string City
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return city; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ city = value; }
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
private string postcode;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Postcode
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return postcode; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ postcode = value; }
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
private string address;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Address
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return address; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ address = value; }
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
private string phone;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Phone
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return phone; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ phone = value; }
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
private string mobile;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Mobile
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return mobile; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ mobile = value; }
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
private string email;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Email
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return email; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ email = value; }
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
private string title;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Title
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return title; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ title = value; }
}
[Association("k-f", typeof(FamilyMember)), Aggregated]
public XPCollection FamilyMember
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return GetCollection("FamilyMember");
}
}
}
}
FamilyMember
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DevExpress.Xpo;
namespace XPOTest
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
{
public class FamilyMember:XPBaseObject
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
private Guid id;
[Key(true)]
public Guid ID
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return id; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ id = value; }
}
private string name;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Name
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return name; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ name = value; }
}
private string relationship;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Relationship
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return relationship; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ relationship = value; }
}
private string phone;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Phone
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return phone; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ phone = value; }
}
private string birthday;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Birthday
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return birthday; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ birthday = value; }
}
private string company;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Company
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return company; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ company = value; }
}
private string title;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Title
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return title; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ title = value; }
}
private string remarks;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public string Remarks
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{ return remarks; }
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
set
{ remarks = value; }
}
[Association("k-f")]
public KOL KOL;
}
}
sqlConnectionString
public class sqlconnstr
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
public static string connstr=DevExpress.Xpo.DB.MSSqlConnectionProvider.GetConnectionString("Harry", "sa", "guodapeng", "test");
}
Operation
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DevExpress.Xpo;
using DevExpress.Data.Filtering;
using System.IO;
using System.Drawing;
![None.gif](/Images/OutliningIndicators/None.gif)
namespace XPOTest
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
{
public partial class _Default : System.Web.UI.Page
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
protected void Page_Load(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (!Page.IsPostBack)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
showallkol();
showallfam();
}
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
//添加讲师记录
protected void btn_add_Click(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (kolexit())
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DevExpress.Xpo.XpoDefault.ConnectionString = sqlconnstr.connstr;
KOL k1 = new KOL();
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
k1.Name = this.txt_name.Text;
if (this.rb_male.Checked)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
k1.Gender = true;
}
else
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
k1.Gender = false;
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
HttpPostedFile hpf = this.fileupload.PostedFile;
byte[] file = new byte[hpf.ContentLength];
Stream ss = hpf.InputStream;
ss.Read(file, 0, hpf.ContentLength);
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
k1.Photo = file;
Response.Write(file.Length);
k1.Hospital = this.txt_hospital.Text;
k1.Department = this.txt_department.Text;
k1.City = this.txt_city.Text;
k1.Postcode = this.txt_postcode.Text;
k1.Address = this.txt_address.Text;
k1.Phone = this.txt_phone.Text;
k1.Mobile = this.txt_mobile.Text;
k1.Email = this.txt_email.Text;
k1.Title = this.txt_title.Text;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
k1.Save();
this.txt_name.Text = "";
this.txt_hospital.Text = "";
this.txt_department.Text = "";
this.txt_city.Text = "";
this.txt_postcode.Text = "";
this.txt_address.Text = "";
this.txt_phone.Text = "";
this.txt_mobile.Text = "";
this.txt_email.Text = "";
this.txt_title.Text = "";
showallkol();
}
else
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Response.Write("该ID讲师信息已经存在或为空,请重新添加!");
}
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
//删除讲师记录
protected void btn_del_Click(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DevExpress.Xpo.XpoDefault.ConnectionString = sqlconnstr.connstr;
XPCollection collection = new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(KOL), new BinaryOperator("Name",this.txt_name.Text, BinaryOperatorType.Equal));
DevExpress.Xpo.Session.DefaultSession.Delete(collection);
DevExpress.Xpo.Session.DefaultSession.PurgeDeletedObjects();
this.txt_name.Text = "";
this.txt_hospital.Text = "";
this.txt_department.Text = "";
this.txt_city.Text = "";
this.txt_postcode.Text = "";
this.txt_address.Text = "";
this.txt_phone.Text = "";
this.txt_mobile.Text = "";
this.txt_email.Text = "";
this.txt_title.Text = "";
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
showallkol();
showallfam();
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
//显示所有讲师的信息
public void showallkol()
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DevExpress.Xpo.XpoDefault.ConnectionString = sqlconnstr.connstr;
XPCollection kols = new XPCollection(typeof(KOL));
this.dl_kol.DataSource = kols;
this.dl_kol.DataBind();
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
//显示所有家属的信息
public void showallfam()
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DevExpress.Xpo.XpoDefault.ConnectionString = sqlconnstr.connstr;
XPCollection familys = new XPCollection(typeof(FamilyMember));
this.dl_fkol.DataSource = familys;
this.dl_fkol.DataBind();
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
//根据ID查找讲师记录
protected void btn_search_Click(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DevExpress.Xpo.XpoDefault.ConnectionString = sqlconnstr.connstr;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
if (this.txt_name.Text == "")
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{ }
else
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
XPCollection collection = new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(KOL), new BinaryOperator("Name",this.txt_name.Text, BinaryOperatorType.Equal));
if (collection.Count > 0)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
foreach (KOL k1 in collection)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.txt_name.Text = k1.Name;
if (k1.Gender == true)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.rb_male.Checked = true;
}
else
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.rb_female.Checked = true;
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
this.txt_hospital.Text = k1.Hospital;
this.txt_department.Text = k1.Department;
this.txt_city.Text = k1.City;
this.txt_postcode.Text = k1.Postcode;
this.txt_address.Text = k1.Address;
this.txt_phone.Text = k1.Phone;
this.txt_mobile.Text = k1.Mobile;
this.txt_email.Text = k1.Email;
this.txt_title.Text = k1.Title;
}
this.dl_kol.DataSource = collection;
this.dl_kol.DataBind();
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
this.dl_fkol.DataSource = ((KOL)collection[0]).FamilyMember;
this.dl_fkol.DataBind();
}
else
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
}
}
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
//添加多个家属
protected void Button1_Click(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (fexit())
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DevExpress.Xpo.XpoDefault.ConnectionString = sqlconnstr.connstr;
XPCollection collection = new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(KOL), new BinaryOperator("Name",this.txt_name.Text, BinaryOperatorType.Equal));
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
FamilyMember f1 = new FamilyMember();
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
f1.Name = this.txt_fname.Text;
f1.Relationship = this.txt_frelationship.Text;
f1.Phone = this.txt_fphone.Text;
f1.Birthday = this.txt_fbirthday.Text;
f1.Company = this.txt_fcompany.Text;
f1.Title = this.txt_ftitle.Text;
f1.Remarks = this.txt_fremarks.Text;
f1.KOL = (KOL)collection[0];
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
f1.Save();
this.txt_fname.Text = "";
this.txt_frelationship.Text = "";
this.txt_fphone.Text = "";
this.txt_fbirthday.Text = "";
this.txt_fcompany.Text = "";
this.txt_ftitle.Text = "";
this.txt_fremarks.Text = "";
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
showallfam();
}
else
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Response.Write("该ID家属信息已经存在或为空或未选择讲师ID,请重新添加!");
}
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
//删除家属信息
protected void btn_fdel_Click(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DevExpress.Xpo.XpoDefault.ConnectionString = sqlconnstr.connstr;
XPCollection collection = new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(FamilyMember), new BinaryOperator("Name",this.txt_fname.Text, BinaryOperatorType.Equal));
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
((FamilyMember)collection[0]).Delete();
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
this.txt_fname.Text = "";
this.txt_frelationship.Text = "";
this.txt_fphone.Text = "";
this.txt_fbirthday.Text = "";
this.txt_fcompany.Text = "";
this.txt_ftitle.Text = "";
this.txt_fremarks.Text = "";
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
showallfam();
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
//根据ID查找家属信息
protected void btn_fsearch_Click(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (this.txt_fname.Text == "")
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{ }
else
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DevExpress.Xpo.XpoDefault.ConnectionString = sqlconnstr.connstr;
XPCollection collection = new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(FamilyMember), new BinaryOperator("Name",this.txt_fname.Text, BinaryOperatorType.Equal));
if (collection.Count > 0)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
FamilyMember f = (FamilyMember)collection[0];
this.txt_fname.Text = f.Name;
this.txt_frelationship.Text = f.Relationship;
this.txt_fphone.Text = f.Phone;
this.txt_fbirthday.Text = f.Birthday;
this.txt_fcompany.Text = f.Company;
this.txt_ftitle.Text = f.Title;
this.txt_fremarks.Text = f.Remarks;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
this.dl_fkol.DataSource = collection;
this.dl_fkol.DataBind();
}
else
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{ }
}
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
//修改家属信息
protected void btn_fmodify_Click(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DevExpress.Xpo.XpoDefault.ConnectionString = sqlconnstr.connstr;
XPCollection collection = new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(FamilyMember), new BinaryOperator("Name",this.txt_fname.Text, BinaryOperatorType.Equal));
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
FamilyMember f1 = (FamilyMember)collection[0];
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
f1.Name = this.txt_fname.Text;
f1.Relationship = this.txt_frelationship.Text;
f1.Phone = this.txt_fphone.Text;
f1.Birthday = this.txt_fbirthday.Text;
f1.Company = this.txt_fcompany.Text;
f1.Title = this.txt_ftitle.Text;
f1.Remarks = this.txt_fremarks.Text;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
f1.Save();
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
showallfam();
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
//修改讲师信息
protected void btn_modify_Click(object sender, EventArgs e)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DevExpress.Xpo.XpoDefault.ConnectionString = sqlconnstr.connstr;
XPCollection collection = new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(KOL), new BinaryOperator("Name", this.txt_name.Text, BinaryOperatorType.Equal));
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
KOL k1 = (KOL)collection[0];
k1.Name = this.txt_name.Text;
if (this.rb_male.Checked)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
k1.Gender = true;
}
else
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
k1.Gender = false;
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
HttpPostedFile hpf = this.fileupload.PostedFile;
byte[] file = new byte[hpf.ContentLength];
Stream ss = hpf.InputStream;
ss.Read(file, 0, hpf.ContentLength);
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
k1.Photo = file;
k1.Hospital = this.txt_hospital.Text;
k1.Department = this.txt_department.Text;
k1.City = this.txt_city.Text;
k1.Postcode = this.txt_postcode.Text;
k1.Address = this.txt_address.Text;
k1.Phone = this.txt_phone.Text;
k1.Mobile = this.txt_mobile.Text;
k1.Email = this.txt_email.Text;
k1.Title = this.txt_title.Text;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
k1.Save();
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
showallkol();
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
//添加前根据讲师ID检查讲师信息是否已经存在
public bool kolexit()
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (this.txt_name.Text == "")
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return false;
}
else
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DevExpress.Xpo.XpoDefault.ConnectionString = sqlconnstr.connstr;
XPCollection collection = new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(KOL), new BinaryOperator("Name",this.txt_name.Text, BinaryOperatorType.Equal));
if (collection.Count > 0 || this.txt_name.Text == "")
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return false;
}
else
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return true;
}
}
}
//添加前根据家属ID检查讲师家属信息是否已经存在
public bool fexit()
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (this.txt_fname.Text == "")
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return false;
}
else
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DevExpress.Xpo.XpoDefault.ConnectionString = sqlconnstr.connstr;
XPCollection collection = new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(FamilyMember), new BinaryOperator("Name", this.txt_fname.Text, BinaryOperatorType.Equal));
if (collection.Count > 0 || this.txt_fname.Text == "")
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return false;
}
else
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return true;
}
}
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
public void databing()
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
}
}
}
感觉这个东西不是太好用,可能是我还没用习惯,呵呵.
点这里下载源程序