コード例 #1
0
    public override bool ChangePassword(string username, string oldPassword, string newPassword)
    {
        ECountBasePage p = new ECountBasePage();

        SGM.ECount.DataModel.User user = p.Service.GetUserbyName(username);
        if (user == null || user.Password != oldPassword || newPassword.IndexOf(username) != -1)
        {
            return(false);
        }
        else
        {
            //SGM.ECount.DataModel.User newUser = new SGM.ECount.DataModel.User();
            //newUser.UserID = user.UserID;
            //newUser.UserName = user.UserName;
            //newUser.UserGroup = user.UserGroup;
            //newUser.Password = newPassword;
            //newUser.Available = user.Available;
            //newUser.ConsignmentDUNS = user.ConsignmentDUNS;
            //newUser.CreateDate = user.CreateDate;
            //newUser.DUNS = user.DUNS;
            //newUser.Plant = user.Plant;
            //newUser.RepairDUNS = user.RepairDUNS;
            //newUser.Segment = user.Segment;
            //newUser.Workshop = user.Workshop;
            //p.Service.UpdateUser(newUser);
            user.Password     = newPassword;
            user.LastModified = DateTime.Now;
            p.Service.UpdateUser(user);
            return(true);
        }
    }
コード例 #2
0
    /// <summary>
    /// bind data to GridView
    /// </summary>
    /// <param name="part"></param>
    private void bindGridView()
    {
        Supplier model = new Supplier();

        if (!string.IsNullOrEmpty(this.txtDUNS.Text))
        {
            model.DUNS = this.txtDUNS.Text.Trim();
        }
        if (!string.IsNullOrEmpty(this.txtSupplierName.Text))
        {
            model.SupplierName = this.txtSupplierName.Text.Trim();
        }
        if (this.Page != null)
        {
            int             pageCount;
            int             itemCount;
            ECountBasePage  pagebase = this.Page as ECountBasePage;
            List <Supplier> ms       = pagebase.Service.QuerySuppliersByPage(model, AspPager1.PageSize, AspPager1.SelectPageNumber, out pageCount, out itemCount);
            this.AspPager1.TotalPage   = pageCount;
            this.AspPager1.TotalRecord = itemCount;
            this.GridView1.DataSource  = ms;
            this.GridView1.DataBind();
        }
    }
コード例 #3
0
    public override bool ValidateUser(string username, string password)
    {
        ECountBasePage p = new ECountBasePage();

        SGM.ECount.DataModel.User user = p.Service.GetUserbyName(username);
        if (user == null || !user.Available)
        {
            return(false);
        }
        if (user.Password != password)
        {
            if (user.RetryTimes >= 5)
            {
                user.Available = false;
                p.Service.UpdateUser(user);
            }
            else
            {
                user.RetryTimes += 1;
                p.Service.UpdateUser(user);
            }
            return(false);
        }
        else
        {
            System.Web.HttpContext.Current.Session["ECountUser"] = user;
            //ECountIdentity identity = new ECountIdentity(user);
            //ECountPrincipal principal = new ECountPrincipal(identity);
            //Thread.CurrentPrincipal = principal;
            //System.Web.HttpContext.Current.User = principal;
            user.RetryTimes = 0;
            user.LastLogon  = DateTime.Now;
            p.Service.UpdateUser(user);
            return(true);
        }
    }
コード例 #4
0
    public void BindData(Part part)
    {
        if (this.Page != null)
        {
            ECountBasePage pagebase = this.Page as ECountBasePage;
            pagebase.BindDropDownList(this.ddlPlantID, DropDownType.Plant);
            pagebase.BindDropDownList(this.ddlCategoryID, DropDownType.PartCategory);
            pagebase.BindDropDownList(this.ddlPartStatus, DropDownType.PartStatus);
            pagebase.BindDropDownList(this.ddlCycleCountLevel, DropDownType.CycleCountLevel);

            if (part != null)
            {
                ddlPlantID.SelectedValue = part.Plant != null?part.Plant.PlantID.ToString() : "";

                if (part.PartCategory != null && part.PartCategory.CategoryID != DefaultValue.INT)
                {
                    ddlCategoryID.SelectedValue = part.PartCategory.CategoryID.ToString();
                }
                ddlPartStatus.SelectedValue = part.PartStatus != null?part.PartStatus.StatusID.ToString() : "";

                ddlCycleCountLevel.SelectedValue = part.CycleCountLevel != null?part.CycleCountLevel.LevelID.ToString() : "";

                //ddlPartGroup.SelectedValue = part.PartGroup != null ? part.PartGroup.GroupID.ToString() : "";

                this.hidPartID.Value         = part.PartID.ToString();
                this.txtPartCode.Text        = part.PartCode;        //.ToString();
                this.txtPartEnglishName.Text = part.PartEnglishName; //.ToString();
                this.txtPartChineseName.Text = part.PartChineseName; //.ToString();
                this.hidSupplierID.Value     = part.Supplier.SupplierID.ToString();
                this.txtSupplier.Text        = part.Supplier.DUNS;
                txtWorkshops.Text            = part.Workshops;
                txtSegments.Text             = part.Segments;

                //显示当前所选车间的所有工段
                if (part.Workshops != null)
                {
                    List <String>  workshopcode = new List <String>();
                    List <Segment> segment      = new List <Segment>();
                    string[]       split        = part.Workshops.Split(',');
                    foreach (string s in split)
                    {
                        if (!string.IsNullOrEmpty(s.Trim()))
                        {
                            workshopcode.Add(s);
                        }
                    }
                    segment = Service.GetSegmentsByWorkshopCodes(workshopcode);
                }

                if (!string.IsNullOrEmpty(part.WorkLocation))
                {
                    string[] strs = part.WorkLocation.Split(',');
                    for (int i = 1; i <= strs.Length; i++)
                    {
                        (FindControl("txtWorkLocation" + i) as TextBox).Text = strs[i - 1];
                    }
                }
                if (!string.IsNullOrEmpty(part.Dloc))
                {
                    string[] strs = part.Dloc.Split(',');
                    for (int i = 1; i <= strs.Length; i++)
                    {
                        (FindControl("txtDloc" + i) as TextBox).Text = strs[i - 1];
                    }
                }
                this.txtFollowUp.Text        = part.FollowUp == null ? "" : part.FollowUp.ToString();
                this.txtCycleCountTimes.Text = part.CycleCountTimes.ToString();
                this.txtSpecs.Text           = part.Specs == null ? "" : part.Specs.ToString();
                this.txtDescription.Text     = part.Description == null ? "" : part.Description;
                if (part.Groups.Count > 0)
                {
                    List <PartGroup> groups = Service.GetGroupsByPart(part);

                    foreach (GridViewRow row in gvGroup.Rows)
                    {
                        if (gvGroup.DataKeys[row.RowIndex]["GroupID"] == null)
                        {
                            continue;
                        }
                        int groupID = (int)gvGroup.DataKeys[row.RowIndex]["GroupID"];
                        if (groups.Exists(g => g.GroupID == groupID))
                        {
                            CheckBox cbSelect = row.FindControl("cbSelect") as CheckBox;
                            if (cbSelect != null)
                            {
                                cbSelect.Checked = true;
                            }
                        }
                    }
                }
            }
        }
    }