/// <summary> /// Add new a row /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Product_Insert(Product entity) { using (SqlConnection connection = new SqlConnection(AppConfiguration.ConnectionString)) { try { SqlCommand command = new SqlCommand("Product_Insert", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@Company_Id", SqlDbType.UniqueIdentifier); command.Parameters["@Company_Id"].Value = entity.Company_Id; command.Parameters.Add("@Category_Id", SqlDbType.UniqueIdentifier); command.Parameters["@Category_Id"].Value = entity.Category_Id; command.Parameters.Add("@Product_Name", SqlDbType.NVarChar); command.Parameters["@Product_Name"].Value = entity.Product_Name; command.Parameters.Add("@Product_Type", SqlDbType.NVarChar); command.Parameters["@Product_Type"].Value = entity.Product_Type; command.Parameters.Add("@Product_Price", SqlDbType.NVarChar); command.Parameters["@Product_Price"].Value = entity.Product_Price; command.Parameters.Add("@Product_Description", SqlDbType.NVarChar); command.Parameters["@Product_Description"].Value = entity.Product_Description; command.Parameters.Add("@Product_Image", SqlDbType.NVarChar); command.Parameters["@Product_Image"].Value = entity.Product_Image; command.Parameters.Add("@Product_ManufactureDate", SqlDbType.SmallDateTime); command.Parameters["@Product_ManufactureDate"].Value = entity.Product_ManufactureDate; command.Parameters.Add("@Product_ExpiryDate", SqlDbType.SmallDateTime); command.Parameters["@Product_ExpiryDate"].Value = entity.Product_ExpiryDate; connection.Open(); return command.ExecuteNonQuery(); } catch (Exception) { throw; } finally { connection.Dispose(); } } }
/// <summary> /// edit a row /// </summary> /// <param name="entitys"></param> /// <returns></returns> public int Product_Update(Product entitys) { return entity.Product_Update(entitys); }
/// <summary> /// Add new a row /// </summary> /// <param name="entitys"></param> /// <returns></returns> public bool Product_Insert(Product entitys) { return entity.Product_Insert(entitys) > 0; }