public Product Insert(string productCode, int? productGroupId, int? customerId,
     int? supplierId, string name, string description, decimal? weight, string image,
     decimal? outerDiameter, decimal? innerDiameter, decimal? height, decimal? width,
     decimal? length, DateTime? dateCreated, DateTime? dateModified, string createdBy,
     string modifiedBy, string remarks)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         Product item = new Product();
         if (!String.IsNullOrEmpty(productCode))
         {
             item.ProductCode = productCode;
         }
         if (CheckNull(productGroupId))
         {
             item.ProductGroupId = productGroupId;
         }
         if (CheckNull(customerId))
         {
             item.CustomerId = customerId;
         }
         if (CheckNull(supplierId))
         {
             item.SupplierId = supplierId;
         }
         if (!String.IsNullOrEmpty(name))
         {
             item.Name = name;
         }
         if (!String.IsNullOrEmpty(description))
         {
             item.Description = description;
         }
         if (CheckNull(weight))
         {
             item.Weight = weight;
         }
         if (!String.IsNullOrEmpty(image))
         {
             item.Image = image;
         }
         if (CheckNull(outerDiameter))
         {
             item.OuterDiameter = outerDiameter;
         }
         if (CheckNull(innerDiameter))
         {
             item.InnerDiameter = innerDiameter;
         }
         if (CheckNull(height))
         {
             item.Height = height;
         }
         if (CheckNull(width))
         {
             item.Width = width;
         }
         if (CheckNull(length))
         {
             item.Length = length;
         }
         if (CheckNull(dateCreated))
         {
             item.DateCreated = dateCreated;
         }
         if (CheckNull(dateModified))
         {
             item.DateModified = dateModified;
         }
         if (!String.IsNullOrEmpty(createdBy))
         {
             item.CreatedBy = createdBy;
         }
         if (!String.IsNullOrEmpty(modifiedBy))
         {
             item.ModifiedBy = modifiedBy;
         }
         if (!String.IsNullOrEmpty(remarks))
         {
             item.Remarks = remarks;
         }
         ctx.AddToProduct(item);
         ctx.SaveChanges();
         return item;
     }
 }
 protected void gvProducts_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     int id = Convert.ToInt32(e.CommandArgument);
     Product item = new Product();
     item = items.FirstOrDefault(P => P.Id == id);
     if (e.CommandName == "Select")
     {
         hfId.Value = item.Id.ToString();
         txtProductName.Text = item.Name;
         txtDescription.Text = item.Description;
         txtOuterDiameter.Text = item.OuterDiameter.ToString();
         txtInnerDiameter.Text = item.InnerDiameter.ToString();
         txtWeight.Text = item.Weight.ToString();
         txtHeight.Text = item.Height.ToString();
         txtWidth.Text = item.Width.ToString();
         txtLength.Text = item.Length.ToString();
         txtModificationRemarks.Text = item.ModificationRemarks;
         Helper.EnableControls(false, action);
     }
 }