public bool AddMStockItemsIngredient(MStockItemsIngredient mstockitemsingredient) { SqlCommand cmd; cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "AddMStockItemsIngredient"; cmd.Parameters.AddWithValue("@PkSrNo", mstockitemsingredient.PkSrNo); cmd.Parameters.AddWithValue("@IngredientValue", mstockitemsingredient.IngredientValue); cmd.Parameters.AddWithValue("@NutritionHeadValue", mstockitemsingredient.NutritionHeadValue); cmd.Parameters.AddWithValue("@ReceipeHead1", mstockitemsingredient.ReceipeHead1); cmd.Parameters.AddWithValue("@ReceipeHead2", mstockitemsingredient.ReceipeHead2); cmd.Parameters.AddWithValue("@ReceipeHead3", mstockitemsingredient.ReceipeHead3); cmd.Parameters.AddWithValue("@LangReceipeHead1", mstockitemsingredient.LangReceipeHead1); cmd.Parameters.AddWithValue("@LangReceipeHead2", mstockitemsingredient.LangReceipeHead2); cmd.Parameters.AddWithValue("@LangReceipeHead3", mstockitemsingredient.LangReceipeHead3); cmd.Parameters.AddWithValue("@ItemNo", mstockitemsingredient.ItemNo); cmd.Parameters.AddWithValue("@UserID", mstockitemsingredient.UserID); cmd.Parameters.AddWithValue("@UserDate", mstockitemsingredient.UserDate); cmd.Parameters.AddWithValue("@CompanyNo", mstockitemsingredient.CompanyNo); SqlParameter outParameter = new SqlParameter(); outParameter.ParameterName = "@ReturnID"; outParameter.Direction = ParameterDirection.Output; outParameter.DbType = DbType.Int32; cmd.Parameters.Add(outParameter); commandcollection.Add(cmd); return(true); }
public MStockItemsIngredient ModifyMStockItemsIngredientByID(long ID) { SqlConnection Con = new SqlConnection(CommonFunctions.ConStr); string sql; SqlCommand cmd; sql = "Select * from MStockItemsIngredient where PkSrNo =" + ID; cmd = new SqlCommand(sql, Con); cmd.Connection = Con; Con.Open(); cmd.CommandType = CommandType.Text; SqlDataReader dr; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (dr.HasRows) { MStockItemsIngredient MM = new MStockItemsIngredient(); while (dr.Read()) { MM.PkSrNo = Convert.ToInt32(dr["PkSrNo"]); if (!Convert.IsDBNull(dr["IngredientValue"])) { MM.IngredientValue = Convert.ToString(dr["IngredientValue"]); } if (!Convert.IsDBNull(dr["NutritionHeadValue"])) { MM.NutritionHeadValue = Convert.ToString(dr["NutritionHeadValue"]); } if (!Convert.IsDBNull(dr["ReceipeHead1"])) { MM.ReceipeHead1 = Convert.ToString(dr["ReceipeHead1"]); } if (!Convert.IsDBNull(dr["ReceipeHead2"])) { MM.ReceipeHead2 = Convert.ToString(dr["ReceipeHead2"]); } if (!Convert.IsDBNull(dr["ReceipeHead3"])) { MM.ReceipeHead3 = Convert.ToString(dr["ReceipeHead3"]); } if (!Convert.IsDBNull(dr["LangReceipeHead1"])) { MM.LangReceipeHead1 = Convert.ToString(dr["LangReceipeHead1"]); } if (!Convert.IsDBNull(dr["LangReceipeHead2"])) { MM.LangReceipeHead2 = Convert.ToString(dr["LangReceipeHead2"]); } if (!Convert.IsDBNull(dr["LangReceipeHead3"])) { MM.LangReceipeHead3 = Convert.ToString(dr["LangReceipeHead3"]); } if (!Convert.IsDBNull(dr["ItemNo"])) { MM.ItemNo = Convert.ToInt64(dr["ItemNo"]); } if (!Convert.IsDBNull(dr["UserID"])) { MM.UserID = Convert.ToInt64(dr["UserID"]); } if (!Convert.IsDBNull(dr["UserDate"])) { MM.UserDate = Convert.ToDateTime(dr["UserDate"]); } if (!Convert.IsDBNull(dr["CompanyNo"])) { MM.CompanyNo = Convert.ToInt64(dr["CompanyNo"]); } if (!Convert.IsDBNull(dr["StatusNo"])) { MM.StatusNo = Convert.ToInt32(dr["StatusNo"]); } } dr.Close(); return(MM); } else { dr.Close(); } return(new MStockItemsIngredient()); }