XPO实践总结

昨天做了XPO方面的相关实践。感觉刚开始用的时候不是太顺手,呵呵,很多东西都不熟悉。经过了近一天的努力终于基本上完成了。在这里总结一下。

一共就两个对象:KOL,FamilyMember 。两对象为主从关系。

ContractedBlock.gif ExpandedBlockStart.gif KOL
None.gifusing System;
None.gif
using System.Data;
None.gif
using System.Configuration;
None.gif
using System.Web;
None.gif
using System.Web.Security;
None.gif
using System.Web.UI;
None.gif
using System.Web.UI.WebControls;
None.gif
using System.Web.UI.WebControls.WebParts;
None.gif
using System.Web.UI.HtmlControls;
None.gif
using DevExpress.Xpo;
None.gif
namespace XPOTest
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    
public class KOL:XPBaseObject
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private Guid id;
InBlock.gif        [Key(
true)]
InBlock.gif        
public Guid ID
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn id; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ id = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string name;
InBlock.gif
InBlock.gif        
public string Name
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn name; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ name = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private bool gender;
InBlock.gif
InBlock.gif        
public bool Gender
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn gender; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ gender = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private byte[] photo;
InBlock.gif
InBlock.gif        
public byte[] Photo
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn photo; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ photo = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string hospital;
InBlock.gif
InBlock.gif        
public string Hospital
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn hospital; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ hospital = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string department;
InBlock.gif
InBlock.gif        
public string Department
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn department; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ department = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string city;
InBlock.gif
InBlock.gif        
public string City
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn city; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ city = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string postcode;
InBlock.gif
InBlock.gif        
public string Postcode
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn postcode; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ postcode = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string address;
InBlock.gif
InBlock.gif        
public string Address
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn address; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ address = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string phone;
InBlock.gif
InBlock.gif        
public string Phone
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn phone; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ phone = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string mobile;
InBlock.gif
InBlock.gif        
public string Mobile
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn mobile; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ mobile = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string email;
InBlock.gif
InBlock.gif        
public string Email
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn email; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ email = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string title;
InBlock.gif
InBlock.gif        
public string Title
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn title; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ title = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif        [Association(
"k-f"typeof(FamilyMember)), Aggregated]
InBlock.gif        
public XPCollection FamilyMember
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return GetCollection("FamilyMember");
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif
ContractedBlock.gif ExpandedBlockStart.gif FamilyMember
None.gifusing System;
None.gif
using System.Data;
None.gif
using System.Configuration;
None.gif
using System.Web;
None.gif
using System.Web.Security;
None.gif
using System.Web.UI;
None.gif
using System.Web.UI.WebControls;
None.gif
using System.Web.UI.WebControls.WebParts;
None.gif
using System.Web.UI.HtmlControls;
None.gif
using DevExpress.Xpo;
None.gif
namespace XPOTest
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    
public class FamilyMember:XPBaseObject
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private  Guid id;
InBlock.gif        [Key(
true)]
InBlock.gif        
public Guid ID
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn id; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ id = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string name;
InBlock.gif
InBlock.gif        
public string Name
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn name; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ name = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string relationship;
InBlock.gif
InBlock.gif        
public string Relationship
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn relationship; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ relationship = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string phone;
InBlock.gif
InBlock.gif        
public string Phone
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn phone; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ phone = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string birthday;
InBlock.gif
InBlock.gif        
public string Birthday
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn birthday; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ birthday = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string company;
InBlock.gif
InBlock.gif        
public string Company
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn company; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ company = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string title;
InBlock.gif
InBlock.gif        
public string Title
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn title; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ title = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string remarks;
InBlock.gif
InBlock.gif        
public string Remarks
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn remarks; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ remarks = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif        [Association(
"k-f")]
InBlock.gif        
public KOL KOL;
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif
ContractedBlock.gif ExpandedBlockStart.gif sqlConnectionString
None.gif   public class sqlconnstr
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif{
InBlock.gif        
public static string connstr=DevExpress.Xpo.DB.MSSqlConnectionProvider.GetConnectionString("Harry""sa""guodapeng""test");
ExpandedBlockEnd.gif    }
ContractedBlock.gif ExpandedBlockStart.gif Operation
None.gifusing System;
None.gif
using System.Data;
None.gif
using System.Configuration;
None.gif
using System.Collections;
None.gif
using System.Web;
None.gif
using System.Web.Security;
None.gif
using System.Web.UI;
None.gif
using System.Web.UI.WebControls;
None.gif
using System.Web.UI.WebControls.WebParts;
None.gif
using System.Web.UI.HtmlControls;
None.gif
using DevExpress.Xpo;
None.gif
using DevExpress.Data.Filtering;
None.gif
using System.IO;
None.gif
using System.Drawing;
None.gif
None.gif
namespace XPOTest
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    
public partial class _Default : System.Web.UI.Page
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
protected void Page_Load(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if (!Page.IsPostBack)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                showallkol();
InBlock.gif                showallfam();
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//添加讲师记录
InBlock.gif
        protected void btn_add_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if (kolexit())
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                DevExpress.Xpo.XpoDefault.ConnectionString 
= sqlconnstr.connstr;
InBlock.gif                KOL k1 
= new KOL();
InBlock.gif
InBlock.gif                k1.Name 
= this.txt_name.Text;
InBlock.gif                
if (this.rb_male.Checked)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    k1.Gender 
= true;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    k1.Gender 
= false;
ExpandedSubBlockEnd.gif                }

InBlock.gif
InBlock.gif                HttpPostedFile hpf 
= this.fileupload.PostedFile;
InBlock.gif                
byte[] file = new byte[hpf.ContentLength];
InBlock.gif                Stream ss 
= hpf.InputStream;
InBlock.gif                ss.Read(file, 
0, hpf.ContentLength);
InBlock.gif
InBlock.gif                k1.Photo 
= file;
InBlock.gif                Response.Write(file.Length);
InBlock.gif                k1.Hospital 
= this.txt_hospital.Text;
InBlock.gif                k1.Department 
= this.txt_department.Text;
InBlock.gif                k1.City 
= this.txt_city.Text;
InBlock.gif                k1.Postcode 
= this.txt_postcode.Text;
InBlock.gif                k1.Address 
= this.txt_address.Text;
InBlock.gif                k1.Phone 
= this.txt_phone.Text;
InBlock.gif                k1.Mobile 
= this.txt_mobile.Text;
InBlock.gif                k1.Email 
= this.txt_email.Text;
InBlock.gif                k1.Title 
= this.txt_title.Text;
InBlock.gif
InBlock.gif                k1.Save();
InBlock.gif                
InBlock.gif                
this.txt_name.Text = "";
InBlock.gif                
this.txt_hospital.Text = "";
InBlock.gif                
this.txt_department.Text = "";
InBlock.gif                
this.txt_city.Text = "";
InBlock.gif                
this.txt_postcode.Text = "";
InBlock.gif                
this.txt_address.Text = "";
InBlock.gif                
this.txt_phone.Text = "";
InBlock.gif                
this.txt_mobile.Text = "";
InBlock.gif                
this.txt_email.Text = "";
InBlock.gif                
this.txt_title.Text = "";
InBlock.gif                
InBlock.gif                showallkol();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                Response.Write(
"该ID讲师信息已经存在或为空,请重新添加!");
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//删除讲师记录
InBlock.gif
        protected void btn_del_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            DevExpress.Xpo.XpoDefault.ConnectionString 
= sqlconnstr.connstr;
InBlock.gif            XPCollection collection 
= new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(KOL), new BinaryOperator("Name",this.txt_name.Text, BinaryOperatorType.Equal));
InBlock.gif            DevExpress.Xpo.Session.DefaultSession.Delete(collection);
InBlock.gif            DevExpress.Xpo.Session.DefaultSession.PurgeDeletedObjects();
InBlock.gif                        
InBlock.gif            
this.txt_name.Text = "";
InBlock.gif            
this.txt_hospital.Text = "";
InBlock.gif            
this.txt_department.Text = "";
InBlock.gif            
this.txt_city.Text = "";
InBlock.gif            
this.txt_postcode.Text = "";
InBlock.gif            
this.txt_address.Text = "";
InBlock.gif            
this.txt_phone.Text = "";
InBlock.gif            
this.txt_mobile.Text = "";
InBlock.gif            
this.txt_email.Text = "";
InBlock.gif            
this.txt_title.Text = "";
InBlock.gif
InBlock.gif            showallkol();
InBlock.gif            showallfam();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//显示所有讲师的信息
InBlock.gif
        public void showallkol() 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{            
InBlock.gif            DevExpress.Xpo.XpoDefault.ConnectionString 
= sqlconnstr.connstr;
InBlock.gif            XPCollection kols 
= new XPCollection(typeof(KOL));
InBlock.gif            
this.dl_kol.DataSource = kols;
InBlock.gif            
this.dl_kol.DataBind();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//显示所有家属的信息
InBlock.gif
        public void showallfam()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
InBlock.gif            DevExpress.Xpo.XpoDefault.ConnectionString 
= sqlconnstr.connstr;
InBlock.gif            XPCollection familys 
= new XPCollection(typeof(FamilyMember));
InBlock.gif            
this.dl_fkol.DataSource = familys;
InBlock.gif            
this.dl_fkol.DataBind();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//根据ID查找讲师记录
InBlock.gif
        protected void btn_search_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            DevExpress.Xpo.XpoDefault.ConnectionString 
= sqlconnstr.connstr;
InBlock.gif
InBlock.gif            
if (this.txt_name.Text == "")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{ }
InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                XPCollection collection 
= new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(KOL), new BinaryOperator("Name",this.txt_name.Text, BinaryOperatorType.Equal));
InBlock.gif                
InBlock.gif                
if (collection.Count > 0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
foreach (KOL k1 in collection)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
this.txt_name.Text = k1.Name;
InBlock.gif                        
if (k1.Gender == true)
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            
this.rb_male.Checked = true;
ExpandedSubBlockEnd.gif                        }

InBlock.gif                        
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            
this.rb_female.Checked = true;
ExpandedSubBlockEnd.gif                        }

InBlock.gif
InBlock.gif                        
this.txt_hospital.Text = k1.Hospital;
InBlock.gif                        
this.txt_department.Text = k1.Department;
InBlock.gif                        
this.txt_city.Text = k1.City;
InBlock.gif                        
this.txt_postcode.Text = k1.Postcode;
InBlock.gif                        
this.txt_address.Text = k1.Address;
InBlock.gif                        
this.txt_phone.Text = k1.Phone;
InBlock.gif                        
this.txt_mobile.Text = k1.Mobile;
InBlock.gif                        
this.txt_email.Text = k1.Email;
InBlock.gif                        
this.txt_title.Text = k1.Title;
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
this.dl_kol.DataSource = collection;
InBlock.gif                    
this.dl_kol.DataBind();
InBlock.gif
InBlock.gif                    
this.dl_fkol.DataSource = ((KOL)collection[0]).FamilyMember;
InBlock.gif                    
this.dl_fkol.DataBind();
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//添加多个家属
InBlock.gif
        protected void Button1_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if (fexit())
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                DevExpress.Xpo.XpoDefault.ConnectionString 
= sqlconnstr.connstr;
InBlock.gif                XPCollection collection 
= new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(KOL), new BinaryOperator("Name",this.txt_name.Text, BinaryOperatorType.Equal));
InBlock.gif
InBlock.gif                FamilyMember f1 
= new FamilyMember();
InBlock.gif
InBlock.gif                f1.Name 
= this.txt_fname.Text;
InBlock.gif                f1.Relationship 
= this.txt_frelationship.Text;
InBlock.gif                f1.Phone 
= this.txt_fphone.Text;
InBlock.gif                f1.Birthday 
= this.txt_fbirthday.Text;
InBlock.gif                f1.Company 
= this.txt_fcompany.Text;
InBlock.gif                f1.Title 
= this.txt_ftitle.Text;
InBlock.gif                f1.Remarks 
= this.txt_fremarks.Text;
InBlock.gif                f1.KOL 
= (KOL)collection[0];
InBlock.gif
InBlock.gif                f1.Save();
InBlock.gif                                
InBlock.gif                
this.txt_fname.Text = "";
InBlock.gif                
this.txt_frelationship.Text = "";
InBlock.gif                
this.txt_fphone.Text = "";
InBlock.gif                
this.txt_fbirthday.Text = "";
InBlock.gif                
this.txt_fcompany.Text = "";
InBlock.gif                
this.txt_ftitle.Text = "";
InBlock.gif                
this.txt_fremarks.Text = "";
InBlock.gif
InBlock.gif                showallfam();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                Response.Write(
"该ID家属信息已经存在或为空或未选择讲师ID,请重新添加!");
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//删除家属信息
InBlock.gif
        protected void btn_fdel_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            DevExpress.Xpo.XpoDefault.ConnectionString 
= sqlconnstr.connstr;
InBlock.gif            XPCollection collection 
= new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(FamilyMember), new BinaryOperator("Name",this.txt_fname.Text, BinaryOperatorType.Equal));
InBlock.gif
InBlock.gif            ((FamilyMember)collection[
0]).Delete();
InBlock.gif
InBlock.gif            
this.txt_fname.Text = "";
InBlock.gif            
this.txt_frelationship.Text = "";
InBlock.gif            
this.txt_fphone.Text = "";
InBlock.gif            
this.txt_fbirthday.Text = "";
InBlock.gif            
this.txt_fcompany.Text = "";
InBlock.gif            
this.txt_ftitle.Text = "";
InBlock.gif            
this.txt_fremarks.Text = "";
InBlock.gif
InBlock.gif            showallfam();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//根据ID查找家属信息
InBlock.gif
        protected void btn_fsearch_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if (this.txt_fname.Text == "")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{ }
InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{                
InBlock.gif                DevExpress.Xpo.XpoDefault.ConnectionString 
= sqlconnstr.connstr;
InBlock.gif                XPCollection collection 
= new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(FamilyMember), new BinaryOperator("Name",this.txt_fname.Text, BinaryOperatorType.Equal));
InBlock.gif                
if (collection.Count > 0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    FamilyMember f 
= (FamilyMember)collection[0];
InBlock.gif                    
this.txt_fname.Text = f.Name;
InBlock.gif                    
this.txt_frelationship.Text = f.Relationship;
InBlock.gif                    
this.txt_fphone.Text = f.Phone;
InBlock.gif                    
this.txt_fbirthday.Text = f.Birthday;
InBlock.gif                    
this.txt_fcompany.Text = f.Company;
InBlock.gif                    
this.txt_ftitle.Text = f.Title;
InBlock.gif                    
this.txt_fremarks.Text = f.Remarks;
InBlock.gif
InBlock.gif                    
this.dl_fkol.DataSource = collection;
InBlock.gif                    
this.dl_fkol.DataBind();
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{ }
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//修改家属信息
InBlock.gif
        protected void btn_fmodify_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            DevExpress.Xpo.XpoDefault.ConnectionString 
= sqlconnstr.connstr;
InBlock.gif            XPCollection collection 
= new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(FamilyMember), new BinaryOperator("Name",this.txt_fname.Text, BinaryOperatorType.Equal));
InBlock.gif
InBlock.gif            FamilyMember f1 
= (FamilyMember)collection[0];
InBlock.gif
InBlock.gif            f1.Name 
= this.txt_fname.Text;
InBlock.gif            f1.Relationship 
= this.txt_frelationship.Text;
InBlock.gif            f1.Phone 
= this.txt_fphone.Text;
InBlock.gif            f1.Birthday 
= this.txt_fbirthday.Text;
InBlock.gif            f1.Company 
= this.txt_fcompany.Text;
InBlock.gif            f1.Title 
= this.txt_ftitle.Text;
InBlock.gif            f1.Remarks 
= this.txt_fremarks.Text;
InBlock.gif
InBlock.gif            f1.Save();
InBlock.gif
InBlock.gif            showallfam();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//修改讲师信息
InBlock.gif
        protected void btn_modify_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            DevExpress.Xpo.XpoDefault.ConnectionString 
= sqlconnstr.connstr;
InBlock.gif            XPCollection collection 
= new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(KOL), new BinaryOperator("Name"this.txt_name.Text, BinaryOperatorType.Equal));
InBlock.gif
InBlock.gif            KOL k1 
= (KOL)collection[0];              
InBlock.gif            k1.Name 
= this.txt_name.Text;
InBlock.gif            
if (this.rb_male.Checked)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                k1.Gender 
= true;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                k1.Gender 
= false;
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            HttpPostedFile hpf 
= this.fileupload.PostedFile;
InBlock.gif            
byte[] file = new byte[hpf.ContentLength];
InBlock.gif            Stream ss 
= hpf.InputStream;
InBlock.gif            ss.Read(file, 
0, hpf.ContentLength);
InBlock.gif
InBlock.gif            k1.Photo 
= file;
InBlock.gif            k1.Hospital 
= this.txt_hospital.Text;
InBlock.gif            k1.Department 
= this.txt_department.Text;
InBlock.gif            k1.City 
= this.txt_city.Text;
InBlock.gif            k1.Postcode 
= this.txt_postcode.Text;
InBlock.gif            k1.Address 
= this.txt_address.Text;
InBlock.gif            k1.Phone 
= this.txt_phone.Text;
InBlock.gif            k1.Mobile 
= this.txt_mobile.Text;
InBlock.gif            k1.Email 
= this.txt_email.Text;
InBlock.gif            k1.Title 
= this.txt_title.Text;
InBlock.gif
InBlock.gif            k1.Save();
InBlock.gif
InBlock.gif            showallkol();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//添加前根据讲师ID检查讲师信息是否已经存在
InBlock.gif
        public bool kolexit()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if (this.txt_name.Text == "")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return false;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                DevExpress.Xpo.XpoDefault.ConnectionString 
= sqlconnstr.connstr;
InBlock.gif                XPCollection collection 
= new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(KOL), new BinaryOperator("Name",this.txt_name.Text, BinaryOperatorType.Equal));
InBlock.gif                
if (collection.Count > 0 || this.txt_name.Text == "")
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return false;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return true;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
//添加前根据家属ID检查讲师家属信息是否已经存在
InBlock.gif
        public bool fexit()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if (this.txt_fname.Text == "")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return false;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                DevExpress.Xpo.XpoDefault.ConnectionString 
= sqlconnstr.connstr;
InBlock.gif                XPCollection collection 
= new XPCollection(DevExpress.Xpo.Session.DefaultSession, typeof(FamilyMember), new BinaryOperator("Name"this.txt_fname.Text, BinaryOperatorType.Equal));
InBlock.gif                
if (collection.Count > 0 || this.txt_fname.Text == "")
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return false;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return true;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public void databing()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif 
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}
感觉这个东西不是太好用,可能是我还没用习惯,呵呵.        


点这里下载源程序

转载于:https://www.cnblogs.com/guodapeng/archive/2007/04/20/720659.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值