public string InsertDie(DieDescription objMod) { string result = "Error Creating Die"; try { var connection = gConnection.Connection(); connection.Open(); string sqlstr = "uspDieDescription"; SqlCommand cmd = new SqlCommand(sqlstr, GlobalVariables.gConn); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", "Insert"); cmd.Parameters.AddWithValue("@DieNo", objMod.DieNo.Trim()); cmd.Parameters.AddWithValue("@customerName", objMod.CustomerName.Trim()); cmd.Parameters.AddWithValue("@PartName", objMod.PartName.Trim()); cmd.Parameters.AddWithValue("@InternalCutWeight", objMod.InternalCutWeight); cmd.ExecuteNonQuery(); connection.Close(); result = "Die Created Successfully!"; } catch (Exception ex) { Global.ErrorHandlerClass.LogError(ex); } return(result); }
public List <DieDescription> GetAllDieDescription() { List <DieDescription> objtempList = new List <DieDescription>(); try { var connection = gConnection.Connection(); connection.Open(); string sqlstr = "uspDieDescription"; SqlCommand cmd = new SqlCommand(sqlstr, connection); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", "GetAllDieDescription"); SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { DieDescription objtemp = new DieDescription(); objtemp.DieNo = (sdr["DieNo"].ToString()); objtemp.CustomerName = sdr["Name"].ToString(); objtemp.PartName = (sdr["PartName"].ToString()); objtemp.InternalCutWeight = Convert.ToDecimal(sdr["InternalCutWeight"].ToString()); objtempList.Add(objtemp); } connection.Close(); } catch (Exception ex) { ErrorHandlerClass.LogError(ex); } return(objtempList); }
public ActionResult AddDie(DieDescription objMod) { try { string result = DieData.InsertDie(objMod); return(RedirectToAction("AllDieDescription", "DieDescription")); } catch (Exception ex) { Global.ErrorHandlerClass.LogError(ex); @ViewBag.HideClass = "alert alert-danger"; @ViewBag.Message = "Inquiry Not Saved!"; } return(View(objMod)); }