Пример #1
0
 private void RefreshDetails()
 {
     for (int i = 0; i < gvParts.Rows.Count; i++)
     {
         GridViewRow row      = gvParts.Rows[i];
         TextBox     txtDesc  = row.FindControl("txtDesc") as TextBox;
         CheckBox    cbDelete = row.FindControl("cbDelete") as CheckBox;
         int         partID   = (int)gvParts.DataKeys[i].Value;
         if (cbDelete != null)
         {
             View_StocktakeDetails details = DeletedDetails.Find(d => d.PartID == partID);
             if (cbDelete.Checked && details == null)
             {
                 details = new View_StocktakeDetails {
                     PartID = partID
                 };
                 DeletedDetails.Add(details);
                 return;
             }
             else
             {
                 if (!cbDelete.Checked && details != null)
                 {
                     DeletedDetails.Remove(details);
                 }
             }
         }
         if (txtDesc != null && !string.IsNullOrEmpty(txtDesc.Text.Trim()))
         {
             View_StocktakeDetails details = UpdatedDetails.Find(d => d.PartID == partID);
             if (details != null)
             {
                 details.DetailsDesc = txtDesc.Text;
             }
             else
             {
                 details = new View_StocktakeDetails {
                     PartID = partID, DetailsDesc = txtDesc.Text
                 };
                 UpdatedDetails.Add(details);
             }
         }
     }
 }
Пример #2
0
 protected void gvParts_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         int partID = (int)gvParts.DataKeys[e.Row.RowIndex].Value;
         View_StocktakeDetails delItem = DeletedDetails.Find(d => d.PartID == partID);
         View_StocktakeDetails updItem = UpdatedDetails.Find(d => d.PartID == partID);
         CheckBox cbDelete             = e.Row.FindControl("cbDelete") as CheckBox;
         if (cbDelete != null)
         {
             cbDelete.Checked = (delItem != null);
         }
         TextBox txtDesc = e.Row.FindControl("txtDesc") as TextBox;
         if (txtDesc != null && updItem != null)
         {
             txtDesc.Text = updItem.DetailsDesc;
         }
     }
 }