Ejemplo n.º 1
0
    protected void gvParts_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        RefreshSelectedDetails(SelectedReqDetails, gvRequestParts);
        RefreshRequestedDetails();
        valiCounts.Validate();
        if (!valiCounts.IsValid)
        {
            return;
        }

        View_StocktakeDetails detail = GetDetailsByRow(gvParts.Rows[e.RowIndex]);

        detail.PartID = int.Parse(gvParts.DataKeys[e.RowIndex].Value.ToString());
        List <Part> relatedParts = Service.GetRelatedParts(detail.PartID.ToString());

        foreach (var item in relatedParts)
        {
            View_StocktakeDetails tmpDetail = new View_StocktakeDetails();
            tmpDetail.CreateViewByPart(item);
            tmpDetail.StocktakeType = detail.StocktakeType; //stocktakeTypeID;
            //tmpDetail.TypeName = detail.TypeName;//ddlStocktakeType.SelectedItem.Text;
            tmpDetail.Priority = detail.Priority;           // stocktakePriorityID;
            //tmpDetail.PriorityName = detail.PriorityName; //ddlStocktakePriority.SelectedItem.Text;
            if (!RequestedDetails.Exists(d => d.PartID == tmpDetail.PartID))
            {
                RequestedDetails.Add(tmpDetail);
            }
            if (RequestID != null)
            {
                int index = RemovedDetails.FindIndex(d => d.PartID == tmpDetail.PartID);
                if (index >= 0)
                {
                    RemovedDetails.RemoveAt(index);
                }
            }
            int idx = SelectedDetails.FindIndex(d => d.PartID == tmpDetail.PartID);
            if (idx >= 0)
            {
                SelectedDetails.RemoveAt(idx);
            }
        }
        //int index = RemovedDetails.FindIndex(d => d.PartID == detail.PartID);
        //if (index >= 0)
        //{
        //    RemovedDetails.RemoveAt(index);
        //}
        //RequestedDetails.Add(detail);
        BindData();
    }
Ejemplo n.º 2
0
 protected void btnAddPart_Click(object sender, EventArgs e)
 {
     RefreshSelectedDetails(SelectedDetails, gvParts);
     RefreshRequestedDetails();
     valiCounts.Validate();
     if (!valiCounts.IsValid)
     {
         return;
     }
     for (int i = SelectedDetails.Count - 1; i >= 0; i--)
     {
         View_StocktakeDetails detail       = SelectedDetails[i];
         List <Part>           relatedParts = Service.GetRelatedParts(detail.PartID.ToString());
         foreach (var item in relatedParts)
         {
             View_StocktakeDetails tmpDetail = new View_StocktakeDetails();
             tmpDetail.CreateViewByPart(item);
             tmpDetail.StocktakeType = detail.StocktakeType; //stocktakeTypeID;
             tmpDetail.Priority      = detail.Priority;      // stocktakePriorityID;
             if (!RequestedDetails.Exists(d => d.PartID == tmpDetail.PartID))
             {
                 RequestedDetails.Add(tmpDetail);
             }
             if (RequestID != null)
             {
                 int index = RemovedDetails.FindIndex(d => d.PartID == tmpDetail.PartID);
                 if (index >= 0)
                 {
                     RemovedDetails.RemoveAt(index);
                 }
             }
         }
         SelectedDetails.RemoveAt(i);
     }
     BindData();
 }
Ejemplo n.º 3
0
    protected void btnAddPart_Click(object sender, EventArgs e)
    {
        if (Page.IsValid && gvParts.Rows.Count > 0)
        {
            //load stocktake details from session
            List <View_StocktakeDetails> details = this.Details;

            //parts to be added to stocktake request
            List <View_StocktakeDetails> newDetails = new List <View_StocktakeDetails>();
            List <ViewPart> parts = this.QueryParts;
            for (int i = gvParts.Rows.Count - 1; i >= 0; i--)
            {
                CheckBox ckSelect = gvParts.Rows[i].Cells[0].FindControl("cbSelect") as CheckBox;
                //move part from parts list into stocktake request
                if (ckSelect.Checked)
                {
                    // gvParts.Rows[i].Cells[11].Text;
                    string partID = gvParts.DataKeys[i].Value.ToString();
                    bool   exists = details.Exists(d => d.PartID.ToString() == partID);
                    if (!exists)//part not in request list
                    {
                        DropDownList ddlStocktakeType     = gvParts.Rows[i].Cells[1].FindControl("ddlStocktakeType") as DropDownList;
                        int          stocktakeTypeID      = Convert.ToInt32(ddlStocktakeType.SelectedValue);
                        DropDownList ddlStocktakePriority = gvParts.Rows[i].Cells[2].FindControl("ddlPriority") as DropDownList;
                        int          stocktakePriorityID  = Convert.ToInt32(ddlStocktakePriority.SelectedValue);
                        //ViewStockTakeRequest newDetail = new ViewStockTakeRequest();
                        //newDetail.CreateViewByPart(this.QueryParts[i]);

                        //newDetail.PartID = new Guid(partID);
                        //newDetail.PartCode = ((HyperLink)gvParts.Rows[i].Cells[3].FindControl("linkPartCode")).Text;
                        //newDetail.PartChineseName = this.QueryParts[i].PartChineseName;// gvParts.Rows[i].Cells[4].Text;
                        //newDetail.PlantName = this.QueryParts[i].Plant.PlantName;// ((Label)gvParts.Rows[i].Cells[5].FindControl("lblPlant")).Text;
                        //newDetail.DUNS = this.QueryParts[i].Supplier.DUNS;// ((Label)gvParts.Rows[i].Cells[6].FindControl("lblDUNS")).Text;
                        //newDetail.FollowUp = this.QueryParts[i].FollowUp;// gvParts.Rows[i].Cells[7].Text;
                        //newDetail.CategoryName = ((Label)gvParts.Rows[i].Cells[8].FindControl("lblPartCategory")).Text;
                        //newDetail.LevelName = ((Label)gvParts.Rows[i].Cells[9].FindControl("lblCycleCountLevel")).Text;
                        //newDetail.StatusName = ((Label)gvParts.Rows[i].Cells[10].FindControl("lblPartStatus")).Text;

                        //newDetail.TypeName = ddlStocktakeType.SelectedItem.Text;
                        //newDetail.StocktakeType = stocktakeTypeID;
                        //newDetail.Priority = stocktakePriorityID;
                        //newDetail.PriorityName = ddlStocktakePriority.SelectedItem.Text;
                        //newDetails.Add(newDetail);

                        List <Part> relatedParts = Service.GetRelatedParts(partID);
                        foreach (var item in relatedParts)
                        {
                            View_StocktakeDetails tmpDetail = new View_StocktakeDetails();
                            tmpDetail.CreateViewByPart(item);
                            tmpDetail.StocktakeType = stocktakeTypeID;
                            tmpDetail.TypeName      = ddlStocktakeType.SelectedItem.Text;
                            tmpDetail.Priority      = stocktakePriorityID;
                            tmpDetail.PriorityName  = ddlStocktakePriority.SelectedItem.Text;
                            newDetails.Add(tmpDetail);
                        }
                    }
                    parts.RemoveAt(i);
                }
            }
            BindDataControl(gvParts, parts);

            details.AddRange(newDetails);
            Details = details;
            BindDataControl(gvRequestParts, details);
        }
    }