Exemplo n.º 1
0
        public ContactInfo GetContactInfoById(int ContactId)
        {
            ContactInfo contactInfo  = null;//
            try
            {
                 contactInfo = new ContactInfo(ContactId);

            }
            catch (AppException)
            {
                return null;
            }

            return  contactInfo;
        }
Exemplo n.º 2
0
 //数据持久化
 internal static void SaveToDb(ContactInfo pContactInfo, Contact  pContact,bool pIsNew)
 {
     pContact.ContactId = pContactInfo.contactId;
      		pContact.Mobile = pContactInfo.mobile;
      		pContact.Officephone = pContactInfo.officephone;
      		pContact.PhoneExt = pContactInfo.phoneExt;
      		pContact.Homephone = pContactInfo.homephone;
      		pContact.Email = pContactInfo.email;
     pContact.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pContact.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(ContactInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pContactInfo.contactId = pContact.ContactId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(ContactInfo)))
     {
         ResetCache();
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< ContactInfo> pList, ContactCollection pCollection)
 {
     foreach (Contact contact in pCollection)
     {
         ContactInfo contactInfo = new ContactInfo();
         LoadFromDAL(contactInfo, contact );
         pList.Add(contactInfo);
     }
 }
Exemplo n.º 4
0
 //从后台获取数据
 internal static void LoadFromDAL(ContactInfo pContactInfo, Contact  pContact)
 {
     pContactInfo.contactId = pContact.ContactId;
      		pContactInfo.mobile = pContact.Mobile;
      		pContactInfo.officephone = pContact.Officephone;
      		pContactInfo.phoneExt = pContact.PhoneExt;
      		pContactInfo.homephone = pContact.Homephone;
      		pContactInfo.email = pContact.Email;
     pContactInfo.Loaded=true;
 }
Exemplo n.º 5
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(ContactInfo pContactInfoTo)
 {
     Copy(this,  pContactInfoTo);
 }
Exemplo n.º 6
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<ContactInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< ContactInfo> list = new List< ContactInfo>();

            Query q = Contact .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            ContactCollection  collection=new  ContactCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Contact  contact  in collection)
            {
                ContactInfo contactInfo = new ContactInfo();
                LoadFromDAL(contactInfo,   contact);
                list.Add(contactInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
Exemplo n.º 7
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<ContactInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(ContactInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< ContactInfo>;
     }
     else
     {
         List< ContactInfo>  list =new List< ContactInfo>();
         ContactCollection  collection=new  ContactCollection();
         Query qry = new Query(Contact.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(Contact contact in collection)
         {
             ContactInfo contactInfo= new ContactInfo();
             LoadFromDAL(contactInfo,contact);
             list.Add(contactInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(ContactInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }
Exemplo n.º 8
0
        public void DeleteById(ContactInfo pContactInfo)
        {
            ContactInfo contactInfo = new ContactInfo(pContactInfo.ContactId);

            contactInfo.Delete();
        }
Exemplo n.º 9
0
 public object SaveContactInfo(ContactInfo contactInfo)
 {
     contactInfo.Save();
     return contactInfo . ContactId;
 }
Exemplo n.º 10
0
 public void DeleteById(ContactInfo pContactInfo)
 {
     ContactInfo contactInfo = new ContactInfo(pContactInfo.ContactId);
     contactInfo.Delete();
 }
Exemplo n.º 11
0
 public object  SaveContactInfo(ContactInfo contactInfo)
 {
     contactInfo.Save();
     return(contactInfo.ContactId);
 }
Exemplo n.º 12
0
 public List <ContactInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
 {
     return(ContactInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount));
 }
Exemplo n.º 13
0
 public List <ContactInfo> GetContactInfoList()
 {
     return(ContactInfo.GetList());
 }
Exemplo n.º 14
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (IsPageValid())
            {
                try
                {
                    string strAddress = txtAddress.Text.Trim();
                    string strCertificate = txtCertificate.Text.Trim();
                    string strEmployeeName = txtEmployeeName.Text.Trim();
                    string strIdentyNum = txtIdentyNum.Text.Trim();
                    string strMajor = txtMajor.Text.Trim();
                    string strNativePlace = txtNativePlace.Text.Trim();
                    string strSchool = txtSchool.Text.Trim();

                    string strEmail = txtEmail.Text.Trim();
                    string strHomephone = txtHomephone.Text.Trim();
                    string strMobile = txtMobile.Text.Trim();
                    string strPhoneExt = txtPhoneExt.Text.Trim();
                    string strOfficephone = txtOfficephone.Text.Trim();

                    DateTime dtBirthday = DateTime.Parse(txtBirthday.Text.Trim());
                    DateTime dtJobTime = DateTime.Parse(txtJobTime.Text.Trim());
                    DateTime dtJoinTime = DateTime.Parse(txtJoinTime.Text.Trim());

                    ContactInfo contact = new ContactInfo();
                    contact.Email = strEmail;
                    contact.Homephone = strHomephone;
                    contact.Mobile = strMobile;
                    contact.PhoneExt = strPhoneExt;
                    contact.Officephone = strOfficephone;
                    contact.Save();

                    EmployeeInfo Em = new EmployeeInfo();

                    if (ddlDepart.SelectedValue != "")
                    {
                        Em.DepartId = Convert.ToInt32(ddlDepart.SelectedValue.ToString());
                    }
                    if (ddlEducation.SelectedValue != "")
                    {
                        Em.EducationId = Convert.ToInt32(ddlEducation.SelectedValue);
                    }
                    if (ddlLanguage.SelectedValue != "")
                    {
                        Em.LanguageId = Convert.ToInt32(ddlLanguage.SelectedValue.ToString());
                    }

                    if (ddlPosition.SelectedValue != "")
                    {
                        Em.PositionId = Convert.ToInt32(ddlPosition.SelectedValue.ToString());
                    }
                    if (rblSex.SelectedValue != "")
                    {
                        Em.Sex = Convert.ToInt32(rblSex.SelectedValue.ToString());
                    }
                    if (rbtnMarrage.SelectedValue != "")
                    {
                        int iMarrage = Convert.ToInt32(rbtnMarrage.SelectedValue.ToString());
                    }
                    if (rblState.SelectedValue != "")
                    {
                        int iState = Convert.ToInt32(rblState.SelectedValue.ToString());
                        Em.State = iState;
                        if (iState == 1)
                        {

                            Em.OffJobTime = Convert.ToDateTime(txtLeaveDate.Text.ToString());

                        }
                    }

                    if (ddlPolitics.SelectedValue != "")
                    {
                        Em.PoliticsId = Convert.ToInt32(ddlPolitics.SelectedValue.ToString());
                    }

                    Em.EmLevelId = Convert.ToInt32(ddlLevel.SelectedValue.ToString());
                    Em.EmDangId = Convert.ToInt32(ddlDang.SelectedValue.ToString());

                    Em.ContactId = contact.ContactId;
                    Em.Address = strAddress;
                    Em.Birthday = dtBirthday;
                    Em.Certificate = strCertificate;
                    Em.EmployeeName = strEmployeeName;
                    Em.IdentyNum = strIdentyNum;
                    Em.JobTime = dtJobTime;
                    Em.JoinTime = dtJoinTime;
                    Em.Major = strMajor;
                    Em.NativePlace = strNativePlace;
                    Em.School = strSchool;
                    Em.Image = "~/Photo/" + ViewState["ImgUrl"];
                    Em.Qq = txtQq.Text.ToString();
                    Em.TurnTime = txtTurntime.Text.ToString();
                    Em.Save();

                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('����û��ɹ���');</script>");

                }
                catch (Exception Ex)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('����û�ʧ�ܣ�" + Ex.Message + "');", true);

                }
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(ContactInfo pContactInfoFrom, ContactInfo pContactInfoTo)
 {
     pContactInfoTo.ContactId = pContactInfoFrom.contactId;
      		pContactInfoTo.Mobile = pContactInfoFrom.mobile;
      		pContactInfoTo.Officephone = pContactInfoFrom.officephone;
      		pContactInfoTo.PhoneExt = pContactInfoFrom.phoneExt;
      		pContactInfoTo.Homephone = pContactInfoFrom.homephone;
      		pContactInfoTo.Email = pContactInfoFrom.email;
     pContactInfoTo.Loaded=pContactInfoFrom.Loaded;
 }
Exemplo n.º 16
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(ContactInfo pContactInfoTo)
 {
     Copy(this, pContactInfoTo);
 }
Exemplo n.º 17
0
        private void EmployeeBind()
        {
            int Employeeid = Convert.ToInt32(Request.QueryString["Employeeid"].ToString());
            DataTable dt = EmployeeInfo.getEmployeeList(Employeeid);

            txtEmployeeName.Text = dt.Rows[0]["EmployeeName"].ToString();
            txtAddress.Text = dt.Rows[0]["Address"].ToString();
            txtBirthday.Text = dt.Rows[0]["Birthday"].ToString();
            txtCertificate.Text = dt.Rows[0]["Certificate"].ToString();
            txtIdentyNum.Text = dt.Rows[0]["IdentyNum"].ToString();
            txtJobTime.Text = dt.Rows[0]["JobTime"].ToString();
            txtJoinTime.Text =dt.Rows[0]["JoinTime"].ToString();
            txtMajor.Text = dt.Rows[0]["Major"].ToString();
            txtNativePlace.Text = dt.Rows[0]["NativePlace"].ToString();
            txtSchool.Text = dt.Rows[0]["School"].ToString();
            txtQq.Text = dt.Rows[0]["Qq"].ToString();
            ddlPolitics.SelectedValue = dt.Rows[0]["PoliticsId"].ToString();
            ddlPosition.SelectedValue = dt.Rows[0]["PositionId"].ToString();
            ddlDepart.SelectedValue = dt.Rows[0]["DepartId"].ToString();
            ddlEducation.SelectedValue = dt.Rows[0]["EducationId"].ToString();
            ddlLanguage.SelectedValue = dt.Rows[0]["LanguageId"].ToString();
            ddlLevel.SelectedValue = dt.Rows[0]["EmLevelId"].ToString();
            ddlDang.SelectedValue = dt.Rows[0]["EmDangId"].ToString();

            rblSex.SelectedValue=dt.Rows[0]["Sex"].ToString();
            rbtnMarrage.SelectedValue=dt.Rows[0]["Marrage"].ToString();
            rblState.SelectedValue = dt.Rows[0]["State"].ToString();
            int iState = Convert.ToInt32(dt.Rows[0]["State"].ToString());
            if (iState == 1)
            {
                txtLeaveDate.Text = dt.Rows[0]["OffJobTime"].ToString();
                txtLeaveDate.Enabled = true;
                txtLeaveDate.Visible = true;
            }

               Image1.ImageUrl = dt.Rows[0]["Image"].ToString();
               EmployeeInfo em=new EmployeeInfo(Employeeid);
               ContactInfo contact = new ContactInfo(Convert.ToInt32(em.ContactId));
               txtMobile.Text = contact.Mobile.ToString();
               txtHomephone.Text = contact.Homephone.ToString();
               txtOfficephone.Text = contact.Officephone.ToString();
               txtEmail.Text = contact.Email.ToString();
               txtPhoneExt.Text = contact.PhoneExt.ToString();
        }