Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BizParams param        = BizParamsList.Find(p => string.Equals(p.ParamKey, Consts.BIZ_PARAMS_CYCLECOUNTED));
            bool      cycleCounted = false;
            Toolbar1.Items[1].Visible = false;

            Toolbar1.Visible = (param != null && Boolean.TryParse(param.ParamValue, out cycleCounted) && !cycleCounted);

            UpdatedDetails = null;
            DeletedDetails = null;
        }
        AspPager1.PageNumberSelect += new BizDataMaintain_AspPager.PageNumberSelectEventHandler(AspPager1_PageNumberSelect);
    }
Exemple #2
0
    //protected void linkDelete_Click(object sender, EventArgs e)
    //{
    //    Details.Clear();
    //    BindDataControl(gvRequestParts, Details);
    //    pagerRequestParts.TotalRecord = 0;
    //    pagerRequestParts.CurrentPage = 1;
    //    if (RequestID != null)
    //    {
    //        NewStocktakeRequest request = new NewStocktakeRequest
    //        {
    //            Details = new List<NewStocktakeDetails>()
    //        };
    //        Service.UpdateCachedRequest(request, CacheKey, false, true);
    //    }
    //    if (gvParts.DataKeys[0].Value != null)
    //    {
    //        Query();
    //    }
    //}
    protected void valiCounts_ServerValidate(object source, ServerValidateEventArgs args)
    {
        SGM.ECount.DataModel.User user = CurrentUser.UserInfo;//Service.GetUserbyKey(CurrentUser.UserInfo);
        int          maxUserCount;
        int          currentCount;
        int          maxCount;
        int          currentAmount = 0;
        DropDownList ddlIsStatic   = dlRequest.Items[0].FindControl("ddlIsStatic") as DropDownList;

        if (ddlIsStatic.SelectedIndex > 0)
        {
            BizParams param = BizParamsList.Find(p => p.ParamKey == "MaxDynamic");
            maxCount      = int.Parse(param.ParamValue);
            maxUserCount  = user.UserGroup.MaxDynamicStocktake ?? 0;
            currentCount  = user.UserGroup.CurrentDynamicStocktake.Value;
            currentAmount = CurrentDynAmount;
            currentAmount = currentAmount - currentCount;
        }
        else
        {
            BizParams param = BizParamsList.Find(p => p.ParamKey == "MaxStatic");
            maxCount     = int.Parse(param.ParamValue);
            maxUserCount = user.UserGroup.MaxStaticStocktake.Value;

            currentCount  = user.UserGroup.CurrentStaticStocktake.Value;
            currentAmount = CurrentStAmount;
            currentAmount = currentAmount - currentCount;
        }

        int newPartsCount = 0;

        if (gvParts.DataKeys[0].Value != null)
        {
            //List<View_StocktakeDetails> newDetails = NewDetails;

            for (int i = 0; i < gvParts.Rows.Count; i++)
            {
                if (gvParts.DataKeys[i] != null)
                {
                    CheckBox cbSelect = gvParts.Rows[i].FindControl("cbSelect") as CheckBox;
                    if (cbSelect != null)//add selected item
                    {
                        int partID = (int)gvParts.DataKeys[i].Value;
                        if (cbSelect.Checked)
                        {
                            newPartsCount++;
                        }
                    }
                }
            }
        }

        currentCount += newPartsCount + RequestedDetails.Count; // ((OriginDetailCount == null) ? 0 : OriginDetailCount.Value);
        if (currentCount > maxUserCount)
        {
            valiCounts.Text = "已超过当前用户盘点数量上限!";
            args.IsValid    = false;
        }
        else
        {
            currentCount += currentAmount;
            if (currentCount > maxCount)
            {
                valiCounts.Text = "已超过盘点数量上限!";
                args.IsValid    = false;
            }
            else
            {
                args.IsValid = true;
            }
        }
    }
Exemple #3
0
    protected void ucFileUpload_Upload(object sender, EventArgs e)
    {
        UploadEventArgs ue        = e as UploadEventArgs;
        DataTable       dtDetails = ue.ContentTable;

        dtDetails.DefaultView.Sort = "零件号";
        dtDetails = dtDetails.DefaultView.ToTable();
        bool            isValid  = true;
        List <ViewPart> partList = new List <ViewPart>();

        //get part by code, plant, duns
        //for (int i = 0; i < dtDetails.Rows.Count; i++)
        //{
        //    ViewPart tmpPart = new ViewPart
        //    {
        //        PlantCode = dtDetails.Rows[i]["工厂代码"].ToString(),
        //        DUNS = dtDetails.Rows[i]["供应商DUNS"].ToString(),
        //        PartCode = dtDetails.Rows[i]["零件号"].ToString()
        //    };
        //    if (!partList.Exists(p => string.Equals(p.PartCode , tmpPart.PartCode, StringComparison.OrdinalIgnoreCase) && string.Equals(p.PlantCode ,tmpPart.PlantCode , StringComparison.OrdinalIgnoreCase)&& string.Equals(p.DUNS ,tmpPart.DUNS, StringComparison.OrdinalIgnoreCase)))
        //    {
        //        partList.Add(tmpPart);
        //    }
        //}

        List <View_StocktakeDetails> detailsList = new List <View_StocktakeDetails>();

        for (int i = 0; i < dtDetails.Rows.Count; i++)
        {
            bool hasError = false;
            View_StocktakeDetails details = new View_StocktakeDetails
            {
                RowNumber     = int.Parse(dtDetails.Rows[i]["序号"].ToString()),
                PartCode      = dtDetails.Rows[i]["零件号"].ToString(),
                DUNS          = dtDetails.Rows[i]["供应商DUNS"].ToString(),
                PartPlantCode = dtDetails.Rows[i]["工厂代码"].ToString(),
                TypeName      = dtDetails.Rows[i]["申请类别"].ToString(),
                PriorityName  = dtDetails.Rows[i]["紧急程度"].ToString(),
                Description   = dtDetails.Rows[i]["备注"].ToString()
            };
            string msg;
            if (i % 5000 == 0)
            {
                string startCode = details.PartCode;
                int    end       = i + 4999;
                if (end >= dtDetails.Rows.Count)
                {
                    end = dtDetails.Rows.Count - 1;
                }
                string endCode = dtDetails.Rows[end]["零件号"].ToString();
                partList = Service.QueryPartCodeScope(null, startCode, endCode);
            }
            ViewPart part = partList.FirstOrDefault(p => string.Equals(p.PartCode, details.PartCode, StringComparison.OrdinalIgnoreCase) && string.Equals(p.PlantCode, details.PartPlantCode, StringComparison.OrdinalIgnoreCase) && string.Equals(p.DUNS, details.DUNS, StringComparison.OrdinalIgnoreCase));
            if (part == null)//part is invalid
            {
                msg = string.Format("第{0}行,该零件不存在", i + 2);
                UCFileUpload1.AddErrorInfo(msg);
                hasError = true;
            }
            else
            {
                details.PartID = part.PartID;
            }
            StocktakePriority priority = Priorities.FirstOrDefault(p => string.Equals(p.PriorityName, details.PriorityName, StringComparison.OrdinalIgnoreCase));
            if (priority == null)
            {
                msg = string.Format("第{0}行,紧急程度信息非法", i + 2);
                UCFileUpload1.AddErrorInfo(msg);
                hasError = true;
            }
            else
            {
                details.Priority = priority.PriorityID;
            }
            StocktakeType type = StocktakeTypes.FirstOrDefault(t => string.Equals(t.TypeName, details.TypeName, StringComparison.OrdinalIgnoreCase));
            if (type == null)
            {
                msg = string.Format("第{0}行,申请类别信息非法", i + 2);
                UCFileUpload1.AddErrorInfo(msg);
                hasError = true;
            }
            else
            {
                details.StocktakeType = type.TypeID;
            }
            if (!hasError)
            {
                if (detailsList.Exists(d => string.Equals(d.TypeName, details.TypeName, StringComparison.OrdinalIgnoreCase) && string.Equals(d.PriorityName, details.PriorityName, StringComparison.OrdinalIgnoreCase) && string.Equals(d.PartPlantCode, details.PartPlantCode, StringComparison.OrdinalIgnoreCase) && string.Equals(d.DUNS, details.DUNS, StringComparison.OrdinalIgnoreCase) && string.Equals(d.PartCode, details.PartCode, StringComparison.OrdinalIgnoreCase)))
                {
                    msg = string.Format("第{0}行,数据重复", i + 2);
                    UCFileUpload1.AddErrorInfo(msg);
                    hasError = true;
                }
                else
                {
                    detailsList.Add(details);
                }
            }
            isValid = isValid && !hasError;
        }

        if (isValid)
        {
            NewStocktakeRequest newRequest = new NewStocktakeRequest
            {
                IsStatic     = (rblIsStatic.SelectedIndex == 1),
                RequestBy    = CurrentUser.UserInfo.UserID,
                IsCycleCount = false,
                Details      = (from d in detailsList
                                select new NewStocktakeDetails
                {
                    PartID = d.PartID.ToString(),
                    StocktakePriority = d.Priority.Value,
                    StocktakeTypeID = d.StocktakeType.Value,
                    Description = d.Description
                }).ToList()
            };
            int currentDynAmount = 0;
            int currentStAmount  = 0;
            foreach (var item in UserGroups)
            {
                currentDynAmount += item.CurrentDynamicStocktake ?? 0;
                currentStAmount  += item.CurrentStaticStocktake ?? 0;
            }
            int maxUserCount;
            int currentCount;
            int maxCount;
            if (!newRequest.IsStatic)
            {
                BizParams param = BizParamsList.Find(p => p.ParamKey == "MaxDynamic");
                maxCount     = int.Parse(param.ParamValue);
                maxUserCount = CurrentUser.UserInfo.UserGroup.MaxDynamicStocktake ?? 0;
                currentCount = CurrentUser.UserInfo.UserGroup.CurrentDynamicStocktake.Value;
                int dynOverflowAmount = currentCount + newRequest.Details.Count - maxUserCount;
                if (dynOverflowAmount > 0)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "maxOverflow", "alert('超过当前用户组动态盘点上限" + dynOverflowAmount + "个')", true);
                    return;
                }
                dynOverflowAmount = currentDynAmount + newRequest.Details.Count - maxCount;
                if (dynOverflowAmount > 0)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "maxOverflow", "alert('超过动态盘点总数上限" + dynOverflowAmount + "个')", true);
                    return;
                }
            }

            if (newRequest.IsStatic)
            {
                BizParams param = BizParamsList.Find(p => p.ParamKey == "MaxStatic");
                maxCount     = int.Parse(param.ParamValue);
                maxUserCount = CurrentUser.UserInfo.UserGroup.MaxStaticStocktake.Value;

                currentCount = CurrentUser.UserInfo.UserGroup.CurrentStaticStocktake.Value;
                int stOverflowAmount = currentCount + newRequest.Details.Count - maxUserCount;
                if (stOverflowAmount > 0)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "maxOverflow", "alert('超过当前用户组静态盘点上限" + stOverflowAmount + "个')", true);
                    return;
                }

                stOverflowAmount = currentStAmount + newRequest.Details.Count - maxCount;
                if (stOverflowAmount > 0)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "maxOverflow", "alert('超过静态盘点总数上限" + stOverflowAmount + "个')", true);
                    return;
                }
            }
            //fill in items
            StocktakeRequest request = Service.RequestStocktake(newRequest);
            BindDataControl(gvResult, detailsList);
            CurrentUser.RefreshUserProfile();
            CacheHelper.RemoveCache(Consts.CACHE_KEY_USER_GROUPS);
            //show information
            this.UCFileUpload1.AddSuccessInfo("盘点申请成功,申请单号" + request.RequestNumber, string.Empty, string.Empty);
        }
    }