Пример #1
0
 private void LoadData(string ID)
 {
     PersonInfoManager manager = new PersonInfoManager();
     PersonInfo code = manager.GetItemById(new Guid(ID));
     txtID.Value = code.ID.ToString();
     txtUserName.Value = code.UserName;
     txtEmail.Value = code.Email;
     txtRealName.Value = code.RealName;
     txtLocation.Value = code.Location;
     txtDetailedAddress.Value = code.DetailedAddress;
     txtSex.SelectedValue = code.Sex.ToString();
     txtTelphone.Value = code.Telphone;
     txtIDCardNumber.Value = code.IDCardNumber;
     hidBirthday.Value = code.Birthday.HasValue ? code.Birthday.Value.ToString("yyyy/MM/dd") : "";
     txtMarryStatus.SelectedValue = code.MarryStatus.HasValue ? code.MarryStatus.ToString() : "";
     txtNote.Value = code.Note;
     //获取默认部门
      DepartAndPerson dp=   manager.GetDefaultDepart(code.ID);
      if (dp!=null)
      {
      AdministrativeRegions ar = new AdministrativeRegionsManager().GetItemById(dp.DepartID);
      txtDepartID.Value = ar.ID.ToString();
      txtSocrceDepart.Value = ar.Name;
      }
 }
Пример #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest rp = context.Request;
            string msg = string.Empty;
            try
            {
                if (string.IsNullOrEmpty(rp["txtID"]))
                {
                    entity.ID = Guid.NewGuid();
                }
                else
                {
                    entity.ID = new Guid(rp["txtID"]);
                    entity.RecordStatus = StatusType.update;
                }
                List<BaseEntity> list = new List<BaseEntity>();
                PersonInfoManager manager = new PersonInfoManager();
                if (!string.IsNullOrEmpty(rp["txtDepartID"]))
                {
                    if (entity.RecordStatus == StatusType.update)
                    {
                        //先获取其默认部门
                        DepartAndPerson dp = manager.GetDefaultDepart(entity.ID);
                        if (dp == null)
                        {
                            AddDefault(rp, list);
                        }
                        else

                            if (dp.DepartID.ToString() != rp["txtDepartID"])
                            {
                                dp.IsDefault = false;
                                list.Add(dp);
                                //将单位单位设为默认ID
                                DepartAndPerson dpold = manager.GetOldDepart(entity.ID, rp["txtDepartID"]);
                                if (dpold == null)
                                {
                                    AddDefault(rp, list);
                                }
                                else
                                {
                                    dpold.IsDefault = true;
                                    list.Add(dpold);

                                }

                            }
                    }
                    else
                    {
                        //新增默认部门
                        AddDefault(rp, list);
                    }

                }

                entity.UserName = rp["txtUserName"];
                if (entity.RecordStatus == StatusType.add)
                {
                    entity.Pwd = entity.UserName;
                    entity.CreateDate = DateTime.Now;
                }

                entity.Email = rp["txtEmail"];

                entity.RealName = rp["txtRealName"];

                entity.Location = rp["txtLocation"];
                entity.DetailedAddress = rp["txtDetailedAddress"];
                entity.Sex = int.Parse(rp["txtSex"]);
                entity.Telphone = rp["txtTelphone"];
                entity.IDCardNumber = rp["txtIDCardNumber"];

                if (!string.IsNullOrEmpty(rp["txtBirthday"]))
                {
                    entity.Birthday = DateTime.Parse(rp["txtBirthday"]);
                }
                entity.MarryStatus = int.Parse(rp["txtMarryStatus"]);
                entity.UpdateDATE = DateTime.Now;
                entity.Note = rp["txtNote"];

                bool IsExit = manager.ExitCodeAndName(entity);//重复校验参考
                if (IsExit)
                {
                    msg = "已存在相同账户!";
                }
                else
                {
                    list.Add(entity);
                    manager.Save(list);
                    context.Response.Write("{\"success\":\"true\",\"ID\":\"" + entity.ID + "\"}");
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            if (!string.IsNullOrEmpty(msg))
            {
                byte[] bytes = Encoding.UTF8.GetBytes(msg.Replace("\r\n", "<br/>"));
                string encode = Convert.ToBase64String(bytes);
                context.Response.Write("{\"success\":\"false\",\"msg\":\"" + encode + "\"}");
            }
            context.Response.End();
        }