public bool Update([FromBody] SpareMaster _oSpareMaster)
        {
            try
            {
                int output;
                using (var context = new DB001Core())
                {
                    var input = context.SpareMasters
                                .Where(s => s.SpareID == _oSpareMaster.SpareID)
                                .FirstOrDefault();
                    //  var input = context.SpareMasters.First<SpareMaster>();

                    input.SpareName = _oSpareMaster.SpareName;
                    input.Stock     = _oSpareMaster.Stock;

                    output = context.SaveChanges();
                }
                return(Convert.ToBoolean(output));
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                context = null;
            }
        }
 protected void btn_submit_Click(object sender, ImageClickEventArgs e)
 {
     objcontext = new QualitySheetdclassDataContext();
     objspare   = new SpareMaster()
     {
         ToolNumber = ddl_toolnumber.SelectedValue.ToString(),
         Maximum    = txt_maximum.Value.ToString(),
         Minimum    = txt_minimum.Value.ToString(),
         TotalCount = txt_sparecount.Value.ToString()
     };
     objcontext.SpareMasters.InsertOnSubmit(objspare);
     objcontext.SubmitChanges();
     loadgrid();
     BindToolNumber();
     txt_maximum.Value    = "";
     txt_minimum.Value    = "";
     txt_sparecount.Value = "";
 }
 public bool Add([FromBody] SpareMaster _oSpareMaster)
 {
     try
     {
         int output;
         using (var context = new DB001Core())
         {
             context.SpareMasters.Add(_oSpareMaster);
             output = context.SaveChanges();
         }
         return(Convert.ToBoolean(output));
     }
     catch (Exception ex)
     {
         throw;
     }
     finally
     {
         context = null;
     }
 }