Пример #1
0
 /// <summary>
 /// 添加警员
 /// </summary>
 public void AddPCStaff(PCStaffInfo pcInfo)
 {
     StaticPCStaffDAL.Insert(pcInfo);
 }
Пример #2
0
 /// <summary>
 /// 修改警员
 /// </summary>
 public void ModifyPCStaff(PCStaffInfo pcInfo)
 {
     StaticPCStaffDAL.Update(pcInfo);
 }
Пример #3
0
    private PCStaffInfo GetPcInfo(UserInfo loginedUser)
    {
        // 检查用户的输入情况
        if (string.IsNullOrEmpty(txtName.Text.Trim()))
        {
            lblError.Text = "请输入警员名称!";
            return(null);
        }

        if (string.IsNullOrEmpty(ddlRank.SelectedValue))
        {
            lblError.Text = "请选择警员的警衔!";
            return(null);
        }

        if (string.IsNullOrEmpty(txtPCNum.Text.Trim()))
        {
            lblError.Text = "请输入警员的警号!";
            return(null);
        }

        //if (string.IsNullOrEmpty(Request["id"]))  //警员添加时,必须上传Icon
        //{
        //    if (!fileIcon.HasFile)
        //    {
        //        lblError.Text = "请上传警员的头像!";
        //        return null;
        //    }
        //}

        if (string.IsNullOrEmpty(txtTel.Text.Trim()))
        {
            lblError.Text = "请输入警号的电话!";
            return(null);
        }

        if (string.IsNullOrEmpty(txtWechat.Text.Trim()))
        {
            lblError.Text = "请输入警员的微信号!";
            return(null);
        }

        if (string.IsNullOrEmpty(txtOrder.Text.Trim()) || !ValidationUtility.IsNumric(txtOrder.Text.Trim()))
        {
            lblError.Text = "请输入正确格式的排序数值!";
            return(null);
        }

        var ret = new PCStaffInfo
        {
            Id            = 0,
            CreatedByID   = loginedUser.ID,
            CreatedByName = loginedUser.Alias,
            CreatedDate   = DateTime.Now
        };

        // 如果是修改,则获取要修改的对象
        if (!string.IsNullOrEmpty(Request["id"]))
        {
            var pcInfo = _staffBLL.GetPCStaff(Convert.ToInt32(Request["id"]));
            if (pcInfo == null)
            {
                return(null);
            }

            ret = pcInfo;
        }

        if (fileIcon.HasFile)
        {
            var fileExt = FileUtility.GetExtension(fileIcon.FileName);
            if (fileExt.ToLower() != ".jpg" && fileExt.ToLower() != ".png")
            {
                lblError.Text = "请输入jpg或png图片!";
                return(null);
            }

            var filePath     = FileUtility.GetNewFileName(Path.GetFileName(fileIcon.FileName));
            var filePathThum = FileUtility.GetNewFileName(filePath);

            FileUtility.FileSave(FileUtility.GetPhysicAbsoluteFullFileName(FileUtility.ConstPCStaffIcon, filePath),
                                 this.fileIcon.PostedFile, 60, 60,
                                 FileUtility.GetPhysicAbsoluteFullFileName(FileUtility.ConstPCStaffIcon, filePathThum));

            ret.Icon     = filePath;
            ret.IconThum = filePathThum;
        }

        ret.Name     = txtName.Text.Trim();
        ret.PcRankId = Convert.ToInt32(ddlRank.SelectedValue);
        ret.PcRank   = ddlRank.SelectedItem.Text;
        ret.PCNum    = txtPCNum.Text.Trim();
        ret.Tel      = txtTel.Text.Trim();
        ret.Wechat   = txtWechat.Text.Trim();

        if (loginedUser.OrganizationId != null)
        {
            ret.OrganizationId = loginedUser.OrganizationId.Value;
        }

        ret.OrganizationName = loginedUser.OrganizationName;

        ret.DisplayOrder = int.Parse(txtOrder.Text.Trim());

        ret.LastUpdByID   = loginedUser.ID;
        ret.LastUpdByName = loginedUser.Alias;
        ret.LastUpdDate   = DateTime.Now;

        return(ret);
    }