protected void Page_Load(object sender, EventArgs e)
    {

        Owen.Model.Model_UserInfo model = new Owen.BLL.BLL_UserInfo().IsRoles((int)Owen.Common.RolesValue.Distributor);

        if (model == null)
        {
            Owen.Common.JSHelper.Alert(this, "对不起,您没有权限创建/修改员工档案!", "../Center.aspx");
            return;
        }
        Owen.Model.Model_Distributor mDistributor =
                    new Owen.BLL.BLL_Distributor().GetEntity(string.Format(" Mobile = '{0}' ", model.UserName));
        if (mDistributor == null)
        {
            Owen.Common.JSHelper.Alert(this, "对不起,经销商信息不存在!", "../Center.aspx");
            return;
        }
        distributorID = mDistributor.DistributorID;

        employeesId = Owen.Common.Utils.GetQueryInt("employeesId");
        action = Owen.Common.Utils.GetQueryString("action");
        if (!Page.IsPostBack)
        {
            OnStart(sender, e);
        }
    }
Пример #2
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public bool Register(string userName, string pwd)
        {
            bool b = false;
            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(pwd))
                return b;

            Owen.Model.Model_UserInfo modelUserInfo = new Model.Model_UserInfo();
            modelUserInfo.UserName = userName;
            //密码已加密,所以,此处不用再加密
            modelUserInfo.Password = pwd;
            modelUserInfo.Age = 0;
            modelUserInfo.Address = string.Empty;
            modelUserInfo.Birth = string.Empty;
            modelUserInfo.Email = string.Empty;
            modelUserInfo.Gender = 0;
            modelUserInfo.Phone = string.Empty;
            modelUserInfo.Status = 0;
            modelUserInfo.UserType = 0;
            modelUserInfo.ZipCode = string.Empty;

            using (TransactionScope tranScope = new TransactionScope())
            {
                int id = dataFactory.UserInfoDal.AddEntity(modelUserInfo).UserID;

                Owen.Model.Model_UserGroupRole mUserGroupRole = new Model.Model_UserGroupRole();

                mUserGroupRole.UserID = id;
                mUserGroupRole.Remark = string.Empty;
                mUserGroupRole.State = 0;

                int rolesId = 0;
                //查询医生表
                Owen.Model.Model_Doctor mDoctor = new BLL_Doctor().GetEntity(string.Format(" Mobile = '{0}' ", userName));
                //查询经销商表
                Owen.Model.Model_Distributor mDistributor = new BLL_Distributor().GetEntity(string.Format(" Mobile = '{0}'", userName));
                //查询经销商员工表
                Owen.Model.Model_Employees mEmployees = new BLL_Employees().GetEntity(string.Format(" Mobile = '{0}'", userName));



                if (mDoctor != null)
                    rolesId = (int)Owen.Common.RolesValue.Doctor; //医生
                else if (mDistributor != null)
                    rolesId = (int)Owen.Common.RolesValue.Distributor; //经销商
                else if (mDistributor != null)
                    rolesId = (int)Owen.Common.RolesValue.Employees; //经销商员工
                else
                    rolesId = (int)Owen.Common.RolesValue.Patient; //病人


                mUserGroupRole.RolesID = rolesId;
                new BLL_UserGroupRole().AddEntity(mUserGroupRole);

                tranScope.Complete();
                b = true;
            }

            return b;
        }
   protected void Page_Load(object sender, EventArgs e)
   {
       Owen.Model.Model_UserInfo userInfo = null;
       //先判断是不是经销商员工
       userInfo = new Owen.BLL.BLL_UserInfo().IsRoles((int)Owen.Common.RolesValue.Employees);
       //不是经销商员工
       if (userInfo == null)
       {
           //再判断是不是经销商管理员
           userInfo = new Owen.BLL.BLL_UserInfo().IsRoles((int)Owen.Common.RolesValue.Distributor);
           if (userInfo == null)
           {
               Owen.Common.JSHelper.Alert(this, "对不起,您没有权限创建/修改病历!", "../Center.aspx");
               return;
           }
           Owen.Model.Model_Distributor mDistributor =
                       new Owen.BLL.BLL_Distributor().GetEntity(string.Format(" Mobile = '{0}' ", userInfo.UserName));
           if (mDistributor == null)
           {
               Owen.Common.JSHelper.Alert(this, "对不起,经销商信息不存在!", "../Center.aspx");
               return;
           }
           distributorID = mDistributor.DistributorID;
       }
       else
       {
           Owen.Model.Model_Employees mEmployess =
                   new Owen.BLL.BLL_Employees().GetEntity(string.Format(" Mobile = '{0}' ", userInfo.UserName));
           if (mEmployess == null)
           {
               Owen.Common.JSHelper.Alert(this, "对不起,经销商员工信息不存在!", "../Center.aspx");
               return;
           }
           employessID = mEmployess.EmployeesID;
           distributorID = mEmployess.DistributorID;

       }



       medicalId = Owen.Common.Utils.GetQueryInt("medicalId");
       action = Owen.Common.Utils.GetQueryString("action");
       if (action.Equals("add"))
           btnSave.Text = "立即创建";
       if (action.Equals("edit"))
           btnSave.Text = "保存";
       if (!Page.IsPostBack)
       {
           BindHospital(distributorID);
           OnStart(sender, e);
       }
   }
    /// <summary>
    /// 初始加载
    /// </summary>
    private void OnStart(object sender, EventArgs e)
    {
        Owen.Model.Model_Distributor model = new Owen.BLL.BLL_Distributor().GetEntity(distributorId);

        if (model == null) return;

        txtContact.Text = model.Contact;
        txtName.Text = model.DistributorName;
        txtMobile.Text = model.Mobile;
        txtAddress.Text = model.Address;
        txtContent.Value = model.Memo;



        //医院Id
        int hosId = model.DistributorID;

        //根据医院Id得到所属的城市Id
        Owen.Model.Model_Distributor mDistributor = new Owen.BLL.BLL_Distributor().GetEntity(hosId);
        if (mDistributor == null) return;
        int cityId = mDistributor.CityID;

        //根据城市Id得到省(直辖市)Id
        Owen.Model.Model_City mCity = new Owen.BLL.BLL_City().GetEntity(cityId);
        if (mCity == null) return;
        int province = mCity.ProvinceID;

        ddlProvince.SelectedValue = province.ToString();
        ddlProvince_SelectedIndexChanged(sender, e);

        
        ddlCity.SelectedValue = cityId.ToString();
        ddlCity_SelectedIndexChanged(select, e);

        IList<Owen.Model.Model_DistributorRelation> distributorLists =
                new Owen.BLL.BLL_DistributorRelation().GetEntities(string.Format(" DistributorID = {0} ", hosId));

        foreach (var v in distributorLists)
        {
            //选择
            foreach (ListItem li in this.cblHos.Items)
            {
                if (v.HospitalID.ToString().Equals(li.Value))
                {
                    li.Selected = true;
                }
            }
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Owen.BLL.BLL_Distributor bllDistributor = new Owen.BLL.BLL_Distributor();

        Owen.Model.Model_Distributor entity = bllDistributor.GetEntity(distributorId);

        if (entity == null)
            entity = new Owen.Model.Model_Distributor();

        if (string.IsNullOrEmpty(ddlProvince.SelectedValue))
        {
            JSHelper.Alert(this, "请选择省(直辖市)!");
            return;
        }
        if (string.IsNullOrEmpty(ddlCity.SelectedValue))
        {
            JSHelper.Alert(this, "请选择城市!");
            return;
        }
       


        entity.CityID = int.Parse(ddlCity.SelectedValue);

        entity.Contact = txtContact.Text;
        entity.DistributorName = txtName.Text.Trim();
        entity.Mobile = txtMobile.Text.Trim();
        entity.Address = txtAddress.Text.Trim();
        entity.Memo = txtContent.Value;

        switch (action)
        {
            case "add":
                new Owen.BLL.BLL_Distributor().AddEntity(entity, cblHos);
                JSHelper.Alert(this, "保存成功!", "DistributorList.aspx");
                break;
            case "edit":
                entity.DistributorID = distributorId;
                new Owen.BLL.BLL_Distributor().UpdateEntity(entity, cblHos);
                JSHelper.Alert(this, "保存成功!", "DistributorList.aspx");
                break;
        }

    }