public Boolean Update(ProductDetailsENT entProductDetails) { ProductDetailsDAL dalProductDetails = new ProductDetailsDAL(); if (dalProductDetails.Update(entProductDetails)) { return(true); } else { Message = dalProductDetails.Message; return(false); } }
private void InsertProductDetails() { if (rblCalendarSize.SelectedItem == null || rblCanvasSize.SelectedItem == null || rblTshirtSize.SelectedItem == null) { lblMessage.Text = "Select Size"; divMessage.Visible = true; } ProductDetailsENT entProductDetails = new ProductDetailsENT(); ProductDetailsBAL balProductDetails = new ProductDetailsBAL(); if (Request.QueryString["ProductID"] != null) { entProductDetails.ProductID = Convert.ToInt32(Request.QueryString["ProductID"].ToString()); } if (rblCalendarSize.SelectedItem != null) { entProductDetails.Size = rblCalendarSize.SelectedItem.ToString(); } else if (rblCanvasSize.SelectedItem != null) { entProductDetails.Size = rblCanvasSize.SelectedItem.ToString(); } else if (rblTshirtSize.SelectedItem != null) { entProductDetails.Size = rblTshirtSize.SelectedItem.ToString(); } if (Session["UserID"] != null) { entProductDetails.UserID = Convert.ToInt32(Session["UserID"]); } if (balProductDetails.Insert(entProductDetails)) { rblCalendarSize.SelectedValue = null; rblCanvasSize.SelectedValue = null; rblTshirtSize.SelectedValue = null; tempProductDetailsID = entProductDetails.ProductDetailsID.Value; } else { lblMessage.Text = balProductDetails.Message; divMessage.Visible = true; } }
public Boolean Insert(ProductDetailsENT entProductDetails) { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { #region prepare Command objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_ProductDetails_Insert"; objCmd.Parameters.Add("@ProductDetailsID", SqlDbType.Int, 4).Direction = ParameterDirection.Output; objCmd.Parameters.Add("@productID", SqlDbType.Int).Value = entProductDetails.ProductID; objCmd.Parameters.Add("@Size", SqlDbType.VarChar).Value = entProductDetails.Size; objCmd.Parameters.Add("@UserID", SqlDbType.Int).Value = entProductDetails.UserID; #endregion prepare Command objCmd.ExecuteNonQuery(); if (objCmd.Parameters["@ProductDetailsID"] != null) { entProductDetails.ProductDetailsID = Convert.ToInt32(objCmd.Parameters["@ProductDetailsID"].Value); } return(true); } catch (SqlException sqlex) { Message = sqlex.InnerException.Message; return(false); } catch (Exception ex) { Message = ex.InnerException.Message; return(false); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }
public Boolean Update(ProductDetailsENT entProductDetails) { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { #region prepare Command objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_ProductDetails_Update"; objCmd.Parameters.AddWithValue("@ProductDetailsID", entProductDetails.ProductDetailsID); objCmd.Parameters.AddWithValue("@productID", entProductDetails.ProductID); objCmd.Parameters.AddWithValue("@Size", entProductDetails.Size); objCmd.Parameters.AddWithValue("@UserID", entProductDetails.UserID); #endregion prepare Command objCmd.ExecuteNonQuery(); return(true); } catch (SqlException sqlex) { Message = sqlex.InnerException.Message; return(false); } catch (Exception ex) { Message = ex.InnerException.Message; return(false); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }
public ProductDetailsENT SelectByPK(SqlInt32 ProductDetailsID) { using (SqlConnection objConn = new SqlConnection(ConnectionString)) { objConn.Open(); using (SqlCommand objCmd = objConn.CreateCommand()) { try { #region prepare Command objCmd.CommandType = CommandType.StoredProcedure; objCmd.CommandText = "PR_ProductDetails_SelectByPK"; objCmd.Parameters.AddWithValue("@ProductDetailsID", ProductDetailsID); #endregion prepare Command #region ReadData and Set Controls ProductDetailsENT entProductDetails = new ProductDetailsENT(); using (SqlDataReader objSDR = objCmd.ExecuteReader()) { while (objSDR.Read()) { if (!objSDR["ProductDetailsID"].Equals(DBNull.Value)) { entProductDetails.ProductDetailsID = Convert.ToInt32(objSDR["ProductDetailsID"]); } if (!objSDR["ProductID"].Equals(DBNull.Value)) { entProductDetails.ProductID = Convert.ToInt32(objSDR["ProductID"]); } if (!objSDR["Size"].Equals(DBNull.Value)) { entProductDetails.Size = Convert.ToString(objSDR["Size"]); } } } return(entProductDetails); #endregion ReadData and Set Controls } catch (SqlException sqlex) { Message = sqlex.InnerException.Message; return(null); } catch (Exception ex) { Message = ex.InnerException.Message; return(null); } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } } } } }